Skip to content

Commit

Permalink
finish crawler example, and add test to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sword-jin committed Jul 20, 2024
1 parent 9215cf1 commit 40bbd7c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 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": {}
}
}
4 changes: 3 additions & 1 deletion .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 @@ -28,3 +28,5 @@ jobs:
run: cargo test --locked --all-features --doc
- name: Run e2e
run: make e2e
- name: Run examples
run: make run-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 40bbd7c

Please sign in to comment.