From a2964b6f5ac5de2e62400f066517a23a25c080f3 Mon Sep 17 00:00:00 2001 From: PN Scripts Date: Sun, 8 Nov 2026 19:39:02 +0200 Subject: [PATCH] CI on every push and pull request, pinned actions, govulncheck The checks ran only when a version was tagged. CI now runs gofmt, vet, the tests and govulncheck on every push to main and every pull request, with a read-only token. The release workflow, which holds a write token and the Docker Hub login, runs govulncheck before it builds and pins every action to a commit hash (checkout 7.0.1, setup-go 7.0.0, the Docker actions at the newest release of the majors already used). Dependabot proposes action updates weekly, grouped, and security updates at once. Checked locally: gofmt, make test, govulncheck (code affected by 0). Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 21 +++++++++++++++++++ .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 19 +++++++++++------- 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6197b91 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +# Updates for the actions the workflows run. The program has no Go +# dependencies; govulncheck in CI covers the standard library it is built with. +# Minor and patch updates come once a week in one pull request; security +# updates as soon as they are published. +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + day: monday + time: '06:00' + timezone: Europe/Sofia + open-pull-requests-limit: 5 + groups: + actions: + applies-to: version-updates + update-types: [minor, patch] + actions-security: + applies-to: security-updates + patterns: ['*'] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bf37024 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +# Every push to main and every pull request: the tests, vet and known +# vulnerabilities. Until this existed the checks ran only when a version was +# tagged, after the work rather than during it. +on: + push: + branches: [main] + pull_request: + +# Read, and nothing else. +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + steps: + # Actions are pinned to commit hashes, so a moved tag cannot change what runs here. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + # The newest 1.26 patch release, as the release workflow builds with, + # so the standard library carries every published fix. + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version: '1.26' + cache: false + - name: gofmt + run: test -z "$(gofmt -l .)" || { echo "not formatted:"; gofmt -l .; exit 1; } + - name: vet and tests + run: make test + - name: govulncheck + run: | + go install golang.org/x/vuln/cmd/govulncheck@latest + "$(go env GOPATH)/bin/govulncheck" ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4fb1bf7..aaa65ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,15 @@ jobs: binaries: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version: "1.26" + cache: false + - name: govulncheck + run: | + go install golang.org/x/vuln/cmd/govulncheck@latest + "$(go env GOPATH)/bin/govulncheck" ./... - run: make test dist VERSION=${GITHUB_REF_NAME#v} - run: gh release create "$GITHUB_REF_NAME" dist/* --title "Tickwright Lite ${GITHUB_REF_NAME#v}" --notes-file CHANGELOG.md env: @@ -25,14 +30,14 @@ jobs: if: ${{ vars.DOCKERHUB_USERNAME != '' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 + - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 + - uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - uses: docker/build-push-action@v6 + - uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 with: context: . platforms: linux/amd64,linux/arm64