Skip to content

Commit

Permalink
finish crawler example, and add test to ci (#73)
Browse files Browse the repository at this point in the history
* finish crawler example, and add test to ci

* separate run-examples job
  • Loading branch information
sword-jin authored Jul 20, 2024
1 parent 9215cf1 commit 3ee9463
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"features": {
"ghcr.io/devcontainers/features/git:1": "os-provided",
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/devcontainers-contrib/features/protoc:1": {}
}
}
19 changes: 15 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -21,10 +21,21 @@ jobs:
run: cargo clippy -- -D warnings
- name: Build
run: make build
- name: cargo test --locked
- name: unit test
run: cargo test --locked --all-targets
# https://github.com/rust-lang/cargo/issues/6669
- name: cargo test --doc
- name: doc test
run: cargo test --locked --all-features --doc
- name: Run e2e
- name: e2e test
run: make e2e
run-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: examples test
run: make test-examples
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ debug = []
[[example]]
name = "crawler"
path = "examples/crawler.rs"
required-features = ["full"]
required-features = ["util"]

[[test]]
name = "lib"
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ ifeq ($(ENABLE_TOKIO_CONSOLE), 1)
FEATURES += "debug"
endif

EXAMPLES = \
crawler

.PHONY: build
build:
RUSTFLAGS=$(RUSTFLAGS) cargo build $(if $(FEATURES),--features $(FEATURES))
Expand Down Expand Up @@ -57,6 +60,18 @@ check-version:
build-examples:
DOCKER_BUILDKIT=1 docker build -t crawler:$(IMAGE_VERSION) -f go.Dockerfile .

.PHONY: test-examples
test-examples: build-examples build-docker
$(MAKE) -C examples stop
$(MAKE) -C examples start
$(MAKE) run-examples

.PHONY: run-examples
run-examples:
for example in $(EXAMPLES); do \
$(MAKE) -C examples run-example EXAMPLE=$$example; \
done

.PHONY: clean
clean:
rm -rf target
7 changes: 6 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ apply:
stop: $(KIND)
$(KIND) delete cluster --name $(KIND_CLUSTER)

EXAMPLE ?= crawler
.PHONY: run-example
run-example:
KUBECTL_BIN=$(KUBECTL) cargo run --package castled --example $(EXAMPLE) --features="full"

$(KIND):
mkdir -p $(BIN_DIR)
curl -sSLf -o $@ https://github.com/kubernetes-sigs/kind/releases/download/$(KIND_VERSION)/kind-$(DL_OS)-$(DL_ARCH)
Expand All @@ -65,4 +70,4 @@ $(KUBECTL):
$(ISTIOCTL):
mkdir -p $(BIN_DIR)
curl -sSLf https://github.com/istio/istio/releases/download/$(ISTIO_VERSION)/istioctl-$(ISTIO_VERSION)-$(DL_OSALT)-$(DL_ARCH).tar.gz \
| tar -C $(BIN_DIR) -xzf -
| tar -C $(BIN_DIR) -xzf -
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pub mod client;
pub mod debug;
pub mod server;

#[cfg(not(feature = "util"))]
#[cfg(feature = "util")]
pub mod util;

0 comments on commit 3ee9463

Please sign in to comment.