Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,8 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# The VM set-up's parts are fragments of one script (vm/kali.sh defines `$keep`): each
# composition the launcher makes must parse, with the player's account between the toolset
# and the desktop.
- name: The VM set-up parses
run: |
set -euo pipefail
for parts in "vm/kali.sh vm/toolset.sh" "vm/kali.sh vm/toolset.sh vm/desktop.sh" "vm/kali.sh vm/desktop.sh"; do
# shellcheck disable=SC2086
{ cat $parts; } | sh -n
done
- name: shellcheck
run: shellcheck player-account.sh smoke-test.sh
# The VM set-up's compositions parse, and shellcheck (check.sh, as a contributor runs it).
- run: ./check.sh scripts

smoke:
strategy:
Expand All @@ -61,11 +51,9 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# The image is large (~14 GB unpacked): Docker keeps its data on the runner's scratch disk.
- uses: ./.github/actions/scratch-disk-docker
# No registry, no secrets: a plain local build, so pull requests from forks run it too.
- name: Build
run: docker build --pull -t attack-box:smoke .
- name: Smoke test
run: ./smoke-test.sh attack-box:smoke
# No registry, no secrets: a plain local build and its smoke test (check.sh), so pull
# requests from forks run it too.
- run: ./check.sh image

build:
needs: [scripts, smoke]
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ The launcher assembles one `sh` script from these parts, in this order:
## Building and testing

```sh
docker build --pull -t attack-box:local .
./smoke-test.sh attack-box:local
./check.sh # the scripts: the VM set-up's compositions parse, shellcheck
./check.sh image # the image built locally and smoke-tested
./check.sh all # both
```

The workflow builds and smoke-tests every pull request on amd64 and arm64; a push to `main`, the
The workflow runs the same command: it checks the scripts, and builds and smoke-tests every pull request on amd64 and arm64; a push to `main`, the
weekly run or a manual run publishes, only once both pass, then pulls the published digest and
smoke-tests it again before pinning it in the launcher.

Expand Down
34 changes: 34 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# The attack box's check, the command CI runs (.github/workflows/image.yml) and a contributor runs:
#
# ./check.sh the scripts: the VM set-up's compositions parse, shellcheck passes
# ./check.sh image the image built locally (no registry, no secrets) and smoke-tested
# ./check.sh all both
#
# The VM set-up's parts are fragments of one script (vm/kali.sh defines `$keep`): each composition
# the launcher makes must parse, with the player's account between the toolset and the desktop.
set -euo pipefail
cd "$(dirname "$0")"

scripts() {
local parts
for parts in "vm/kali.sh vm/toolset.sh" "vm/kali.sh vm/toolset.sh vm/desktop.sh" "vm/kali.sh vm/desktop.sh"; do
# shellcheck disable=SC2086 # the list is the files, split on purpose
if ! cat $parts | sh -n; then echo "check: the VM set-up doesn't parse as $parts" >&2; return 1; fi
done
shellcheck check.sh player-account.sh smoke-test.sh
echo "check: scripts ok"
}

image() {
docker build --pull -t attack-box:smoke .
./smoke-test.sh attack-box:smoke
echo "check: image ok"
}

case "${1:-scripts}" in
scripts) scripts ;;
image) image ;;
all) scripts && image ;;
*) echo "usage: ./check.sh [scripts|image|all]" >&2; exit 2 ;;
esac