diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..7d09cbf --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,25 @@ +name: Continuous testing + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - name: Test client + run: make client_test + - name: Build server + run: make build + - name: Test server + run: make test diff --git a/Makefile b/Makefile index 1fa7253..22c31e7 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,23 @@ MAIN_RS_SRCS := $(shell find src -type f -regex '^.*\.rs$$') Cargo.toml \ SEARCH_REPLACE := lib/search_and_replace/target/release/search_and_replace +DEV_DB := $(shell jq -r .dev.db config.json) +DEV_BIND := $(shell jq -r .dev.bind_to config.json) +PROD_DB := $(shell jq -r .prod.db config.json) +PROD_SOCK_PATH := $(shell jq -r .prod.sock_path config.json) + .PHONY: run run: $(MAIN_RS_SRCS) - DB_PATH="$$(jq -r .dev.db config.json)" \ - BIND_TO="$$(jq -r .dev.bind_to config.json)" \ + DB_PATH="$(DEV_DB)" \ + BIND_TO="$(DEV_BIND)" \ cargo run --features dev +.PHONY: test +test: target/release/zmp24 + DB_PATH="$(DEV_DB)" \ + BIND_TO="$(DEV_BIND)" \ + cargo test --release + .PHONY: clean clean: client_clean cargo clean @@ -29,13 +40,13 @@ include client/client.mk include image/image.mk target/release/zmp24: $(MAIN_RS_SRCS) - DB_PATH="$$(jq -r .prod.db config.json)" \ - BIND_TO="$$(jq -r .prod.sock_path config.json)" \ + DB_PATH="$(PROD_DB)" \ + BIND_TO="$(PROD_BIND)" \ cargo build --release target/$(ARCH)-unknown-linux-musl/release/zmp24: $(MAIN_RS_SRCS) - DB_PATH="$$(jq -r .prod.db config.json)" \ - BIND_TO="$$(jq -r .prod.sock_path config.json)" \ + DB_PATH="$(PROD_DB)" \ + BIND_TO="$(PROD_BIND)" \ cargo build --target $(ARCH)-unknown-linux-musl --release $(SEARCH_REPLACE): lib/search_and_replace/src/main.rs lib/search_and_replace/Cargo.toml diff --git a/client/client.mk b/client/client.mk index 101ee82..dda22ce 100644 --- a/client/client.mk +++ b/client/client.mk @@ -27,6 +27,10 @@ client/dst/%.js: client/src/%.ts client/node_modules client/dst client/dst/%.css: client/src/%.scss client/node_modules client/dst cat $< | bun run --cwd client sass --stdin --style compressed > $@ +.PHONY: client_test +client_test: client/node_modules + bun test --pwd client + .PHONY: client_clean client_clean: rm -rf client/dst