From 99075eb140673e76a745f5d9353078f28f58012e Mon Sep 17 00:00:00 2001 From: Alice Wong Date: Thu, 12 Nov 2026 16:52:17 +0000 Subject: [PATCH 1/3] Update check recipe The "@" silencers are inherited from the old recipe. Place the image versions in the base file rather than inline in the recipe. It makes it easier to bump these in the future, be it manually or via Renovate. --- justfile | 18 ++++++++++++++---- justfile.base | 12 ++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 justfile.base diff --git a/justfile b/justfile index bd03b18..65ffb43 100644 --- a/justfile +++ b/justfile @@ -1,3 +1,5 @@ +import 'justfile.base' + set dotenv-load := true export UBUNTU_PRO_TOKEN_FILE := env_var_or_default('UBUNTU_PRO_TOKEN_FILE', justfile_directory() + "/.secrets/ubuntu_pro_token") @@ -41,13 +43,21 @@ update version *args="": render version *args: docker compose --env-file {{ version }}/env run --rm -v $PWD:/workspace python ./scripts/render.py {{ args }} > {{ version }}/packages.md +@lint-docker: + {{ docker_run_safe }} -i ghcr.io/hadolint/hadolint:{{ hadolint_version }} < Dockerfile + +@shellcheck: + {{ docker_run_safe }} -v "$PWD:/mnt:ro" koalaman/shellcheck:{{ shellcheck_version }} scripts/*.sh + +@lint-actions: + {{ docker_run_safe }} -v $(pwd):/repo:ro --workdir /repo kjanat/actionlint:{{ actionlint_version }} -color + # run linters check: - @docker run --rm -i hadolint/hadolint:v2.14.0 < Dockerfile - @ls scripts/*.sh | xargs docker run --rm -v "$PWD:/mnt:ro" koalaman/shellcheck:v0.11.0 - @docker run --rm -v "$PWD:/repo:ro" --workdir /repo rhysd/actionlint:1.7.10 -color - + -just lint-docker + -just shellcheck + -just lint-actions # publish version (dry run by default - pass "true" to perform publish) publish version publish="false": diff --git a/justfile.base b/justfile.base new file mode 100644 index 0000000..20b3fca --- /dev/null +++ b/justfile.base @@ -0,0 +1,12 @@ +######## Tooling versions ######## + +actionlint_version := "1.17.0@sha256:d484cccadf56b6a356466ade9af4c8e05c5dce1badaf0a9ecd0d7639d68d9c92" + +shellcheck_version := "v0.11.0@sha256:61862eba1fcf09a484ebcc6feea46f1782532571a34ed51fedf90dd25f925a8d" + +hadolint_version := "v2.15.1-alpine@sha256:a1d49ae1a4e83c1dbad26b8c1ad7588c8bd1e04f4866b34ad3cac50335198552" + +######## Reusable variables ######## +# Run Docker with minimim possible privileges. Note that if you mount any directories in +# you must still ensure these are mounted read-only. +docker_run_safe := 'docker run --rm --network none --read-only --cap-drop ALL --security-opt no-new-privileges:true --user 65534:65534' \ No newline at end of file From dff95f771cb286794ea365684f5ae082e289318d Mon Sep 17 00:00:00 2001 From: Alice Wong Date: Thu, 12 Nov 2026 16:55:52 +0000 Subject: [PATCH 2/3] Run just --fmt --unstable --- justfile | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/justfile b/justfile index 65ffb43..4dd46b5 100644 --- a/justfile +++ b/justfile @@ -4,35 +4,37 @@ set dotenv-load := true export UBUNTU_PRO_TOKEN_FILE := env_var_or_default('UBUNTU_PRO_TOKEN_FILE', justfile_directory() + "/.secrets/ubuntu_pro_token") export DOCKER_BUILDKIT := "1" + # technically, these could differ by 1 seconds, but thats unlikely and doesn't matter # human readable, used as label in docker image + export BUILD_DATE := `date +'%y-%m-%dT%H:%M:%S.%3NZ'` + # monotonic, used as label in docker image *and* in docker tag + export BUILD_NUMBER := `date +'%y%m%d%H%M%S'` export REVISION := `git rev-parse --short HEAD` ensure-pro-token: - #!/bin/bash - set -euo pipefail - token_file="{{ UBUNTU_PRO_TOKEN_FILE }}" - if test -z "${UBUNTU_PRO_TOKEN:-}"; then - echo "UBUNTU_PRO_TOKEN is required to create $token_file" >&2 - exit 1 - fi - mkdir -p "$(dirname "$token_file")" - umask 077 - printf '%s' "$UBUNTU_PRO_TOKEN" > "$token_file" + #!/bin/bash + set -euo pipefail + token_file="{{ UBUNTU_PRO_TOKEN_FILE }}" + if test -z "${UBUNTU_PRO_TOKEN:-}"; then + echo "UBUNTU_PRO_TOKEN is required to create $token_file" >&2 + exit 1 + fi + mkdir -p "$(dirname "$token_file")" + umask 077 + printf '%s' "$UBUNTU_PRO_TOKEN" > "$token_file" # build docker image for version build version target="python" *args="": ensure-pro-token docker compose --env-file {{ version }}/env build --pull {{ args }} {{ target }} - # test docker image for version test version *args="tests -v": (build version) docker compose --env-file {{ version }}/env run --rm -v $PWD:/workspace python pytest {{ args }} - # run pip-compile to add new dependencies, or update existing ones with --upgrade update version *args="": docker compose --env-file {{ version }}/env run --rm -v $PWD:/workspace base pip-compile {{ args }} {{ version }}/requirements.in -o {{ version }}/requirements.txt @@ -52,7 +54,6 @@ render version *args: @lint-actions: {{ docker_run_safe }} -v $(pwd):/repo:ro --workdir /repo kjanat/actionlint:{{ actionlint_version }} -color - # run linters check: -just lint-docker From 2d1706c13c94748a1b44f542b3fa015e3de08f93 Mon Sep 17 00:00:00 2001 From: Alice Wong Date: Thu, 12 Nov 2026 17:30:02 +0000 Subject: [PATCH 3/3] Simplify check recipe --- justfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/justfile b/justfile index 4dd46b5..a174679 100644 --- a/justfile +++ b/justfile @@ -55,10 +55,7 @@ render version *args: {{ docker_run_safe }} -v $(pwd):/repo:ro --workdir /repo kjanat/actionlint:{{ actionlint_version }} -color # run linters -check: - -just lint-docker - -just shellcheck - -just lint-actions +check: lint-docker shellcheck lint-actions # publish version (dry run by default - pass "true" to perform publish) publish version publish="false":