-
Notifications
You must be signed in to change notification settings - Fork 0
Scaffold initial backend and PWA #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,42 +1,30 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| name: CI | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||||||||||||
| branches: [main] | ||||||||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||||||||
| branches: [main] | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| name: ci | ||||||||||||||||||||||||||||||||||||||||||||
| on: [push, pull_request] | ||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||
| build-test: | ||||||||||||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||
| CARGO_TERM_COLOR: always | ||||||||||||||||||||||||||||||||||||||||||||
| BUILD_PROFILE: debug | ||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Setup Rust | ||||||||||||||||||||||||||||||||||||||||||||
| uses: leynos/shared-actions/.github/actions/setup-rust@c6559452842af6a83b83429129dccaf910e34562 | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Show Ninja version | ||||||||||||||||||||||||||||||||||||||||||||
| run: ninja --version | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Format | ||||||||||||||||||||||||||||||||||||||||||||
| run: make check-fmt | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Lint | ||||||||||||||||||||||||||||||||||||||||||||
| run: make lint | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Test | ||||||||||||||||||||||||||||||||||||||||||||
| run: make test | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Test and Measure Coverage | ||||||||||||||||||||||||||||||||||||||||||||
| uses: leynos/shared-actions/.github/actions/generate-coverage@c6559452842af6a83b83429129dccaf910e34562 | ||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||
| output-path: lcov.info | ||||||||||||||||||||||||||||||||||||||||||||
| format: lcov | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Upload coverage data to CodeScene | ||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||
| CS_ACCESS_TOKEN: ${{ secrets.CS_ACCESS_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||
| if: ${{ env.CS_ACCESS_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||
| uses: leynos/shared-actions/.github/actions/upload-codescene-coverage@c6559452842af6a83b83429129dccaf910e34562 | ||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||
| format: lcov | ||||||||||||||||||||||||||||||||||||||||||||
| access-token: ${{ env.CS_ACCESS_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||
| installer-checksum: ${{ vars.CODESCENE_CLI_SHA256 }} | ||||||||||||||||||||||||||||||||||||||||||||
| - uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||||||||||||||||||
| with: { node-version: '22' } | ||||||||||||||||||||||||||||||||||||||||||||
| - uses: oven-sh/setup-bun@v1 | ||||||||||||||||||||||||||||||||||||||||||||
| with: { bun-version: '1.1.x' } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Backend | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Rust build | ||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get update && sudo apt-get install -y musl-tools | ||||||||||||||||||||||||||||||||||||||||||||
| rustup target add x86_64-unknown-linux-musl | ||||||||||||||||||||||||||||||||||||||||||||
| cargo build --manifest-path backend/Cargo.toml --release --target x86_64-unknown-linux-musl | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Install a Rust toolchain before invoking cargo. The runner does not ship with Rust by default; cargo will fail with “command not found”. Install the toolchain and the MUSL target explicitly. Apply this diff to insert a toolchain setup step before the build: - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: x86_64-unknown-linux-musl
- uses: actions/setup-node@v4
- with: { node-version: '22' }
+ with:
+ node-version: '22'
- uses: oven-sh/setup-bun@v1
- with: { bun-version: '1.1.x' }
+ with:
+ bun-version: '1.1.x'
# Backend
- name: Rust build
run: |
sudo apt-get update && sudo apt-get install -y musl-tools
- rustup target add x86_64-unknown-linux-musl
cargo build --manifest-path backend/Cargo.toml --release --target x86_64-unknown-linux-musl📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # OpenAPI dump (at runtime or via a small bin) | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Run backend to extract OpenAPI | ||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||
| # In real CI, run a small bin that prints ApiDoc JSON to stdout | ||||||||||||||||||||||||||||||||||||||||||||
| echo "{}" > spec/openapi.json | ||||||||||||||||||||||||||||||||||||||||||||
|
leynos marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Frontend | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Build tokens & PWA | ||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||
| cd packages/tokens && bun install && bun run build | ||||||||||||||||||||||||||||||||||||||||||||
| cd ../../frontend-pwa && bun install && bun run build | ||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Rust | ||
| **/target/ | ||
| /target | ||
|
|
||
| # Node | ||
| node_modules/ | ||
| /frontend-pwa/node_modules/ | ||
| /packages/tokens/node_modules/ | ||
| /frontend-pwa/dist/ | ||
| /packages/tokens/dist/ | ||
|
|
||
| # Misc | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,42 +1,36 @@ | ||||||
| .PHONY: help all clean test build release lint fmt check-fmt markdownlint nixie | ||||||
| .PHONY: be fe openapi gen docker-up docker-down fmt lint test check-fmt markdownlint | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Declare all, clean, and audit phony targets. Satisfy checkmake warnings and add a top-level audit to support the PR’s testing commands. Apply this diff: -.PHONY: be fe openapi gen docker-up docker-down fmt lint test check-fmt markdownlint
+.PHONY: all clean audit be fe openapi gen docker-up docker-down fmt lint test check-fmt markdownlint📝 Committable suggestion
Suggested change
🧰 Tools🪛 checkmake (0.2.2)[warning] 1-1: Missing required phony target "all" (minphony) [warning] 1-1: Missing required phony target "clean" (minphony) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| APP ?= wildside | ||||||
| CARGO ?= cargo | ||||||
| BUILD_JOBS ?= | ||||||
| CLIPPY_FLAGS ?= --all-targets --all-features -- -D warnings | ||||||
| MDLINT ?= markdownlint | ||||||
| NIXIE ?= nixie | ||||||
| be: | ||||||
| cargo run --manifest-path backend/Cargo.toml | ||||||
|
|
||||||
| build: target/debug/$(APP) ## Build debug binary | ||||||
| release: target/release/$(APP) ## Build release binary | ||||||
| fe: | ||||||
| cd frontend-pwa && bun dev | ||||||
|
|
||||||
| all: release ## Default target builds release binary | ||||||
| openapi: | ||||||
| # Replace with a bin that prints OpenAPI | ||||||
| curl -s http://localhost:8080/api-docs/openapi.json > spec/openapi.json | ||||||
|
|
||||||
| clean: ## Remove build artifacts | ||||||
| $(CARGO) clean | ||||||
| gen: | ||||||
| cd frontend-pwa && bunx orval --config orval.config.yaml | ||||||
|
|
||||||
| test: ## Run tests with warnings treated as errors | ||||||
| RUSTFLAGS="-D warnings" $(CARGO) test --all-targets --all-features $(BUILD_JOBS) | ||||||
| docker-up: | ||||||
| cd deploy && docker compose up --build -d | ||||||
|
|
||||||
| target/%/$(APP): ## Build binary in debug or release mode | ||||||
| $(CARGO) build $(BUILD_JOBS) $(if $(findstring release,$(@)),--release) --bin $(APP) | ||||||
| docker-down: | ||||||
| cd deploy && docker compose down | ||||||
|
|
||||||
| lint: ## Run Clippy with warnings denied | ||||||
| $(CARGO) clippy $(CLIPPY_FLAGS) | ||||||
| fmt: | ||||||
| cargo fmt --manifest-path backend/Cargo.toml --all | ||||||
|
|
||||||
| fmt: ## Format Rust and Markdown sources | ||||||
| $(CARGO) fmt --all | ||||||
| mdformat-all | ||||||
|
|
||||||
| check-fmt: ## Verify formatting | ||||||
| $(CARGO) fmt --all -- --check | ||||||
| lint: | ||||||
| cargo clippy --manifest-path backend/Cargo.toml --all-targets --all-features -- -D warnings | ||||||
|
|
||||||
| markdownlint: ## Lint Markdown files | ||||||
| find . -type f -name '*.md' -not -path './target/*' -print0 | xargs -0 -- $(MDLINT) | ||||||
| test: | ||||||
| RUSTFLAGS="-D warnings" cargo test --manifest-path backend/Cargo.toml --all-targets --all-features | ||||||
|
|
||||||
| nixie: ## Validate Mermaid diagrams | ||||||
| find . -type f -name '*.md' -not -path './target/*' -print0 | xargs -0 -n 1 -- $(NIXIE) | ||||||
| check-fmt: | ||||||
| cargo fmt --manifest-path backend/Cargo.toml --all -- --check | ||||||
|
|
||||||
| help: ## Show available targets | ||||||
| @grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | \ | ||||||
| awk 'BEGIN {FS=":"; printf "Available targets:\n"} {printf " %-20s %s\n", $$1, $$2}' | ||||||
| markdownlint: | ||||||
| find . -type f -name '*.md' -not -path './target/*' -print0 | xargs -0 -- markdownlint | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Fix YAMLlint "truthy" warning for the on key.
Quote on to placate yamllint, or expand to a mapping. This keeps Actions happy and silences the linter.
Apply one of these diffs (either is fine):
Option A (quote the key):
Option B (expand triggers and quote key):
🧰 Tools
🪛 YAMLlint (1.37.1)
[warning] 2-2: truthy value should be one of [false, true]
(truthy)
🤖 Prompt for AI Agents