From 977cfcb26f29642c014fcee988dfd3d037fdb279 Mon Sep 17 00:00:00 2001 From: Leynos Date: Mon, 4 Aug 2025 23:58:28 +0100 Subject: [PATCH 1/3] Add Netsukefile build workflow --- .github/workflows/netsukefile-test.yml | 33 ++++++++++++++++++++++++++ docs/roadmap.md | 4 ++-- scripts/assert-file-exists.sh | 11 +++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/netsukefile-test.yml create mode 100755 scripts/assert-file-exists.sh diff --git a/.github/workflows/netsukefile-test.yml b/.github/workflows/netsukefile-test.yml new file mode 100644 index 00000000..0eacf6f7 --- /dev/null +++ b/.github/workflows/netsukefile-test.yml @@ -0,0 +1,33 @@ +name: Netsukefile Build Test + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + netsukefile: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - name: Setup Rust + uses: leynos/shared-actions/.github/actions/setup-rust@c6559452842af6a83b83429129dccaf910e34562 + - name: Build Netsuke + run: make build + - name: Create Netsukefile + run: | + cat <<'MANIFEST' > Netsukefile + netsuke_version: "1.0.0" + targets: + - name: generated.txt + recipe: + kind: command + command: "bash -c 'if [ ! -f generated.txt ]; then touch generated.txt; fi'" + MANIFEST + - name: Run Netsuke + run: ./target/debug/netsuke build generated.txt + - name: Assert artefact exists + run: scripts/assert-file-exists.sh generated.txt diff --git a/docs/roadmap.md b/docs/roadmap.md index 22038c39..0260dda1 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -66,9 +66,9 @@ compilation pipeline from parsing to execution. - **Success Criterion:** - - [ ] Netsuke can successfully take a Netsukefile without any Jinja syntax, + - [x] Netsuke can successfully take a Netsukefile without any Jinja syntax, compile it to a `build.ninja` file, and execute it via the ninja subprocess - to produce the correct build artifacts. + to produce the correct build artefacts. *(validated via CI workflow)* ## Phase 2: The Dynamic Engine ✨ diff --git a/scripts/assert-file-exists.sh b/scripts/assert-file-exists.sh new file mode 100755 index 00000000..8860af6b --- /dev/null +++ b/scripts/assert-file-exists.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Ensures the Netsuke build produced the expected artefact. +# Fails fast if the given file is missing. +set -euo pipefail + +file="$1" + +if [[ ! -f "$file" ]]; then + echo "Expected build artefact '$file' to exist." >&2 + exit 1 +fi From d83990dd73f8402464791f1d3f3f063109abf487 Mon Sep 17 00:00:00 2001 From: Leynos Date: Tue, 5 Aug 2025 00:11:56 +0100 Subject: [PATCH 2/3] Simplify Netsukefile command --- .github/workflows/netsukefile-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/netsukefile-test.yml b/.github/workflows/netsukefile-test.yml index 0eacf6f7..f17f889d 100644 --- a/.github/workflows/netsukefile-test.yml +++ b/.github/workflows/netsukefile-test.yml @@ -25,7 +25,7 @@ jobs: - name: generated.txt recipe: kind: command - command: "bash -c 'if [ ! -f generated.txt ]; then touch generated.txt; fi'" + command: "touch generated.txt" MANIFEST - name: Run Netsuke run: ./target/debug/netsuke build generated.txt From c50192e3b0078968fb9d25224c025f4d8f8b6fe7 Mon Sep 17 00:00:00 2001 From: Leynos Date: Tue, 5 Aug 2025 00:52:02 +0100 Subject: [PATCH 3/3] Pin workflow actions and validate artefact helper arguments --- .github/workflows/netsukefile-test.yml | 17 ++++++++++++++--- scripts/assert-file-exists.sh | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/netsukefile-test.yml b/.github/workflows/netsukefile-test.yml index f17f889d..edb726d1 100644 --- a/.github/workflows/netsukefile-test.yml +++ b/.github/workflows/netsukefile-test.yml @@ -8,18 +8,29 @@ on: jobs: netsukefile: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: contents: read steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Setup Rust uses: leynos/shared-actions/.github/actions/setup-rust@c6559452842af6a83b83429129dccaf910e34562 + - name: Cache Cargo + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- - name: Build Netsuke run: make build - name: Create Netsukefile run: | - cat <<'MANIFEST' > Netsukefile + cat <<-'MANIFEST' > Netsukefile netsuke_version: "1.0.0" targets: - name: generated.txt diff --git a/scripts/assert-file-exists.sh b/scripts/assert-file-exists.sh index 8860af6b..82c9d2ed 100755 --- a/scripts/assert-file-exists.sh +++ b/scripts/assert-file-exists.sh @@ -3,6 +3,11 @@ # Fails fast if the given file is missing. set -euo pipefail +if [[ $# -ne 1 ]]; then + echo "Usage: $(basename "$0") " >&2 + exit 64 # EX_USAGE +fi + file="$1" if [[ ! -f "$file" ]]; then