Add Gitea Actions CI: tests on Python 3.10-3.13 and shellcheck #7
No files matched your search
@@ -0,0 +1,41 @@
|
||||
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
|
||||
# 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
|
||||
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
|
||||
@@ -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 server/install.sh server/kernelwatch.sh
|
||||
shellcheck agent/kernelwatch-agent agent/install.sh agent/deploy.sh server/install.sh server/kernelwatch.sh
|
||||
@@ -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
|
||||
|
||||
+5
-2
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user