From 3cbb04f512b07388a45da608dfb25eb8d99a960e Mon Sep 17 00:00:00 2001 From: Snider Date: Sun, 1 Feb 2026 11:05:26 +0000 Subject: [PATCH] ci: use core CLI for QA and standardize workflows - ci.yml: Download latest dev release, run `core go qa`, build matrix - release.yml: Use go-version-file, consistent artifact handling - dev-release.yml: Add checksums, cleaner version string - coverage.yml: Standardize setup-go version, add CLI verification All workflows now use: - go-version-file for consistent Go version - upload-artifact@v4 / download-artifact@v4 - Proper version injection via ldflags Co-Authored-By: Claude Opus 4.5 --- .github/workflows/ci.yml | 73 ++++++++++++++++++++++++++----- .github/workflows/coverage.yml | 57 ++++++++++++------------ .github/workflows/dev-release.yml | 19 ++++---- .github/workflows/release.yml | 18 +++----- 4 files changed, 109 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fddf39dc..76931245 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,23 +2,72 @@ name: CI on: push: - branches: ["main"] + branches: [dev, main] pull_request: - branches: ["main"] + branches: [dev, main] jobs: - build: + test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v6 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.22 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' - - name: Install dependencies - run: go mod tidy + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev - - name: Run tests - run: go test ./... + - name: Download core CLI + run: | + curl -sL "https://github.com/host-uk/core/releases/download/dev/core-linux-amd64" -o core + chmod +x core + sudo mv core /usr/local/bin/core + core --version + + - name: Run QA + run: core go qa + + build: + runs-on: ubuntu-latest + needs: test + strategy: + matrix: + include: + - goos: linux + goarch: amd64 + - goos: darwin + goarch: arm64 + - goos: windows + goarch: amd64 + + steps: + - uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Build CLI + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: '0' + run: | + EXT="" + if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi + VERSION="${GITHUB_REF_NAME:-dev}-$(git rev-parse --short HEAD)" + go build -trimpath \ + -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" \ + -o core-${GOOS}-${GOARCH}${EXT} . + + - name: Verify build + if: matrix.goos == 'linux' + run: | + chmod +x core-linux-amd64 + ./core-linux-amd64 --version diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c51d1134..65b567c7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -10,37 +10,40 @@ jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v6 - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version-file: 'go.mod' + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' - - name: Setup Task - uses: arduino/setup-task@v2 + - name: Setup Task + uses: arduino/setup-task@v2 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev - - name: Build CLI - run: | - go generate ./pkg/updater/... - task cli:build - echo "$(pwd)/bin" >> $GITHUB_PATH + - name: Build CLI + run: | + go generate ./pkg/updater/... + task cli:build + echo "$(pwd)/bin" >> $GITHUB_PATH - - name: Run coverage - run: task cov + - name: Verify CLI + run: bin/core --version - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} + - name: Run coverage + run: task cov - - name: Upload coverage report - uses: actions/upload-artifact@v6 - with: - name: coverage-report - path: coverage.txt + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.txt diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 17fc9901..8a460c3d 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -33,8 +33,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.24' - check-latest: true + go-version-file: 'go.mod' - name: Build CLI env: @@ -45,10 +44,12 @@ jobs: EXT="" if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi VERSION="dev-$(git rev-parse --short HEAD)" - go build -trimpath -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" -o core-${GOOS}-${GOARCH}${EXT} . + go build -trimpath \ + -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" \ + -o core-${GOOS}-${GOARCH}${EXT} . - name: Upload artifact - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v4 with: name: core-${{ matrix.goos }}-${{ matrix.goarch }} path: core-* @@ -65,8 +66,11 @@ jobs: path: artifacts merge-multiple: true - - name: List artifacts - run: ls -la artifacts/ + - name: Generate checksums + run: | + cd artifacts + sha256sum core-* > CHECKSUMS.txt + cat CHECKSUMS.txt - name: Delete existing dev release env: @@ -79,13 +83,12 @@ jobs: - name: Create dev release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMMIT_SHA: ${{ github.sha }} run: | gh release create dev \ --title "Development Build" \ --notes "Latest development build from the dev branch. - **Commit:** ${COMMIT_SHA} + **Commit:** ${{ github.sha }} **Built:** $(date -u +'%Y-%m-%d %H:%M:%S UTC') This is a pre-release for testing. Use tagged releases for production." \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 447718d2..d6e140ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,27 +33,23 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.24' - check-latest: true - - - name: Get version from tag - id: version - run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + go-version-file: 'go.mod' - name: Build CLI env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: '0' + VERSION: ${{ github.ref_name }} run: | EXT="" if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi go build -trimpath \ - -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${{ steps.version.outputs.VERSION }}" \ + -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" \ -o core-${GOOS}-${GOARCH}${EXT} . - name: Upload artifact - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v4 with: name: core-${{ matrix.goos }}-${{ matrix.goarch }} path: core-* @@ -73,14 +69,14 @@ jobs: - name: Generate checksums run: | cd artifacts - sha256sum core-* > checksums.txt - cat checksums.txt + sha256sum core-* > CHECKSUMS.txt + cat CHECKSUMS.txt - name: Create release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create ${{ github.ref_name }} \ - --title "${{ github.ref_name }}" \ + --title "Release ${{ github.ref_name }}" \ --generate-notes \ artifacts/*