From 792161edaadacd35d024f39647c12a0ec9bc688a Mon Sep 17 00:00:00 2001 From: patrick Date: Sat, 17 Oct 2026 15:26:50 -0400 Subject: [PATCH 1/2] Add Gitea Actions CI: tests on Python 3.10-3.13 and shellcheck The matrix covers the Python versions on Ubuntu 22.04/24.04 and Debian 12/13. make lint now includes deploy.sh, and its token check is rewritten as an if statement to satisfy shellcheck SC2015. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 2 +- README.md | 4 ++++ agent/deploy.sh | 7 +++++-- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..0c91440 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + name: tests (Python ${{ matrix.python }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # Ubuntu 22.04, Debian 12, Ubuntu 24.04, Debian 13 + python: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - run: python3 --version + - run: make test + + lint: + runs-on: ubuntu-latest + env: + SHELLCHECK_VERSION: v0.10.0 + steps: + - uses: actions/checkout@v4 + - name: Install shellcheck + run: | + curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" \ + | tar -xJ -C /tmp + echo "/tmp/shellcheck-${SHELLCHECK_VERSION}" >> "$GITHUB_PATH" + - run: shellcheck --version + - run: make lint diff --git a/Makefile b/Makefile index cb938c2..e08dc17 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,4 @@ test: python3 -m unittest discover -s tests lint: - shellcheck agent/kernelwatch-agent agent/install.sh server/install.sh server/kernelwatch.sh + shellcheck agent/kernelwatch-agent agent/install.sh agent/deploy.sh server/install.sh server/kernelwatch.sh diff --git a/README.md b/README.md index 51db3c1..648bf47 100644 --- a/README.md +++ b/README.md @@ -393,6 +393,10 @@ make test # unit + integration tests (stdlib unittest) make lint # shellcheck, if available ``` +Gitea Actions (`.gitea/workflows/ci.yml`) runs both on every push to `main` +and every pull request: the tests on Python 3.10–3.13 (the versions on the +supported Ubuntu and Debian releases) and shellcheck on the shell scripts. + The tests run a real server on an ephemeral port. They also run the real agent script against stubbed `dpkg-query`/`apt-get`/`needrestart`/`uname` and a fake filesystem root (`KERNELWATCH_ROOT`), including one end-to-end agent → server diff --git a/agent/deploy.sh b/agent/deploy.sh index 4012a5d..050fb0f 100755 --- a/agent/deploy.sh +++ b/agent/deploy.sh @@ -126,8 +126,11 @@ deploy_one() { if [[ $mode != upgrade ]]; then # 2. Get a token from the dashboard and hand it over on stdin, never argv. say " $mode $name on $DASHBOARD" - token=$(fetch_token "$name" | tr -d '[:space:]') && [[ -n $token ]] || - { echo " could not get a token for $name" >&2; cleanup; return 1; } + if ! token=$(fetch_token "$name" | tr -d '[:space:]') || [[ -z $token ]]; then + echo " could not get a token for $name" >&2 + cleanup + return 1 + fi printf '%s\n' "$token" | ssh -T "$target" "umask 077 && cat > '$dir/token'" || { cleanup; return 1; } install+=(--server "$SERVER_URL" --token-file "$dir/token") From 0628dc515aacd46fab529913376a9c4464bb8df3 Mon Sep 17 00:00:00 2001 From: patrick Date: Sat, 17 Oct 2026 15:28:34 -0400 Subject: [PATCH 2/2] CI: install Python with uv instead of setup-python setup-python only ships builds for real Ubuntu releases and failed on the runner's ubuntu-latest image. uv's standalone builds work on any glibc Linux. make test now takes PYTHON=. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/ci.yml | 14 +++++++++----- Makefile | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0c91440..52a06bc 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -16,11 +16,15 @@ jobs: python: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - run: python3 --version - - run: make test + # setup-python only has builds for real Ubuntu releases, and the runner's + # ubuntu-latest image isn't one. uv's standalone builds run on any glibc Linux. + - uses: astral-sh/setup-uv@v6 + - name: Install Python ${{ matrix.python }} + run: | + uv python install ${{ matrix.python }} + echo "PYTHON=$(uv python find ${{ matrix.python }})" >> "$GITHUB_ENV" + - run: $PYTHON --version + - run: make test PYTHON="$PYTHON" lint: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index e08dc17..f0db517 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ .PHONY: test lint +PYTHON ?= python3 + test: - python3 -m unittest discover -s tests + $(PYTHON) -m unittest discover -s tests lint: shellcheck agent/kernelwatch-agent agent/install.sh agent/deploy.sh server/install.sh server/kernelwatch.sh