Skip to content

Refactor CLI build handling into helper functions #86

Refactor CLI build handling into helper functions

Refactor CLI build handling into helper functions #86

name: Netsukefile Build Test
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
netsukefile:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- 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: Clean build artefacts
run: make clean
- name: Build Netsuke
run: make build
- name: Create Netsukefile
run: |
cat <<- 'MANIFEST' > Netsukefile
netsuke_version: "1.0.0"
targets:
- name: base.txt
command: "touch base.txt"
- name: dependent.txt
command: "cp base.txt dependent.txt"
sources: ["base.txt"]
- name: inline-command.txt
command: "touch inline-command.txt"
- name: inline-script.txt
script: |
#!/bin/sh
touch inline-script.txt
actions:
- name: say-hello
command: "touch action-called.txt"
- name: unused-action
command: "touch unused.txt"
MANIFEST
- name: Build dependent and inline targets
run: ./target/debug/netsuke --verbose build --emit build.ninja dependent.txt inline-command.txt inline-script.txt
- name: Assert dependent artefacts exist
env:
NINJA_MANIFEST: build.ninja
run: |
scripts/assert-file-exists.sh base.txt
scripts/assert-file-exists.sh dependent.txt
- name: Assert inline command artefact exists
env:
NINJA_MANIFEST: build.ninja
run: scripts/assert-file-exists.sh inline-command.txt
- name: Assert inline script artefact exists
env:
NINJA_MANIFEST: build.ninja
run: scripts/assert-file-exists.sh inline-script.txt
- name: Run action target
run: ./target/debug/netsuke --verbose build --emit action.ninja say-hello
- name: Assert action artefact exists
env:
NINJA_MANIFEST: action.ninja
run: scripts/assert-file-exists.sh action-called.txt
- name: Assert unused action artefact absent
env:
NINJA_MANIFEST: action.ninja
run: scripts/assert-file-absent.sh unused.txt