From f6b8be123d82cce34da4d026b157e4d9188186b7 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:00:18 +0100 Subject: [PATCH 01/14] feat(CF-4): add semantic release and commit lint configuration --- .github/workflows/ci.yaml | 270 ++++++++++++++++++++------------------ commitlint.config.js | 6 +- 2 files changed, 144 insertions(+), 132 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c5b3e7e..447c220 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,149 +12,165 @@ permissions: pull-requests: write jobs: - lint_commit: - name: Lint Commit Message + # lint: + # name: Lint (all modules) + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Go + # uses: actions/setup-go@v5 + # with: + # go-version: 1.24.3 + # - name: Cache Go modules & build + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('go.work.sum','**/go.sum') }} + # restore-keys: | + # ${{ runner.os }}-go- + # - name: Sync workspace + # run: go work sync + # - name: go fmt + # run: | + # ( cd shuttle && go fmt ./... ) + # ( cd weaver && go fmt ./... ) + # - name: go vet + # env: + # GOFLAGS: -mod=readonly + # run: go vet ./shuttle/... ./weaver/... + # - name: go mod tidy check + # run: | + # ( cd shuttle && go mod tidy ) + # ( cd weaver && go mod tidy ) + # - name: golangci-lint + # uses: golangci/golangci-lint-action@v8 + # with: + # version: v2.1 + # args: ./shuttle/... ./weaver/... --timeout 5m + + # test: + # name: Test ${{ matrix.app }} + # needs: lint + # runs-on: ubuntu-latest + # strategy: + # matrix: + # app: [shuttle, weaver] + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Go + # uses: actions/setup-go@v5 + # with: + # go-version: 1.24.3 + # - name: Cache Go modules & build + # uses: actions/cache@v4 + # with: + # path: | + # ~/.cache/go-build + # ~/go/pkg/mod + # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # restore-keys: | + # ${{ runner.os }}-go- + # - name: Sync workspace + # run: go work sync + # - name: Run tests for ${{ matrix.app }} + # working-directory: ${{ matrix.app }} + # run: go test ./... -v -coverprofile=coverage.out + # - name: Upload coverage + # uses: actions/upload-artifact@v4 + # with: + # name: coverage-${{ matrix.app }} + # path: coverage.out + + # build-and-push: + # name: Build & Push ${{ matrix.app }} + # needs: test + # runs-on: ubuntu-latest + # permissions: + # contents: read + # packages: write + # strategy: + # matrix: + # include: + # - app: shuttle + # docker_name: cf-shuttle + # - app: weaver + # docker_name: cf-weaver + + # steps: + # - uses: actions/checkout@v4 + # - uses: docker/setup-qemu-action@v2 + # - uses: docker/setup-buildx-action@v2 + # - uses: docker/login-action@v3 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Get short SHA + # id: vars + # run: echo "short_sha=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT + + # - name: Build & Push ${{ matrix.app }} + # uses: docker/build-push-action@v4 + # with: + # context: . + # file: build/${{ matrix.app }}/Dockerfile + # push: true + # tags: | + # ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_name }}:${{ steps.vars.outputs.short_sha }} + # ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_name }}:latest + # cache-from: type=gha + # cache-to: type=gha,mode=max + + commit-lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Check out code + uses: actions/checkout@v3 with: - node-version: "lts/*" - - run: npm install -g @commitlint/cli @commitlint/config-conventional commitlint-plugin-regex-match - - name: Lint PR title + fetch-depth: 0 # needed to compare against history + - name: Install dependencies + run: npm ci + - name: Run commitlint run: | - PR_TITLE="${{ github.event.pull_request.title }}" - echo "$PR_TITLE" | npx commitlint + git fetch origin main --depth=1 + npx commitlint --from=origin/main --to=HEAD - lint_code: - name: Lint Go Code + calculate-next-release: + needs: commit-lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.3 - - name: Cache Go modules & build - uses: actions/cache@v4 + - name: Check out code + uses: actions/checkout@v3 with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('go.work.sum','**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Sync workspace - run: go work sync - - name: go fmt - run: | - ( cd shuttle && go fmt ./... ) - ( cd weaver && go fmt ./... ) - - name: go vet + fetch-depth: 0 + - name: Install dependencies + run: npm ci + - name: Dry-run semantic-release + id: dryrun env: - GOFLAGS: -mod=readonly - run: go vet ./shuttle/... ./weaver/... - - name: go mod tidy check + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - ( cd shuttle && go mod tidy ) - ( cd weaver && go mod tidy ) - - name: golangci-lint - uses: golangci/golangci-lint-action@v8 - with: - version: v2.1 - args: ./shuttle/... ./weaver/... --timeout 5m - - test_unit: - name: Test ${{ matrix.app }} - needs: lint_code - runs-on: ubuntu-latest - strategy: - matrix: - app: [shuttle, weaver] - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.3 - - name: Cache Go modules & build - uses: actions/cache@v4 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Sync workspace - run: go work sync - - name: Run tests for ${{ matrix.app }} - working-directory: ${{ matrix.app }} - run: go test ./... -v -coverprofile=coverage.out - - name: Upload coverage - uses: actions/upload-artifact@v4 - with: - name: coverage-${{ matrix.app }} - path: coverage.out - - build_and_push: - name: Build & Push ${{ matrix.app }} - needs: test_unit - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - strategy: - matrix: - include: - - app: shuttle - docker_name: cf-shuttle - - app: weaver - docker_name: cf-weaver - - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v2 - - uses: docker/setup-buildx-action@v2 - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get short SHA - id: vars - run: echo "short_sha=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT - - - name: Build & Push ${{ matrix.app }} - uses: docker/build-push-action@v4 - with: - context: . - file: build/${{ matrix.app }}/Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: | - ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_name }}:${{ steps.vars.outputs.short_sha }} - ${{ github.event_name == 'push' && format('ghcr.io/{0}/{1}:latest', github.repository_owner, matrix.docker_name) || '' }} - cache-from: type=gha - cache-to: type=gha,mode=max + npx semantic-release --dry-run --no-ci \ + > dry-run.log 2>&1 + - name: Show next version + run: | + grep "The next release version is" -m1 dry-run.log release: - name: Release - needs: - - test_unit - - build_and_push + needs: [commit-lint, calculate-next-release] if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 + - name: Check out code + uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: "lts/*" - - name: Install semantic-release & plugins - run: npm install -g semantic-release@20.1.0 @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github + - name: Install dependencies + run: npm ci - name: Run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release diff --git a/commitlint.config.js b/commitlint.config.js index 2f328b6..415287c 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -25,9 +25,5 @@ module.exports = { 'scope-empty': [2, 'never'], // allow any subject-case 'subject-case': [0] - }, - ignores: [ - (message) => message.includes('Draft:') - ] - + } }; From a0d96e1fcb0532be0eb1375bf7f445ae34c09aab Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:08:55 +0100 Subject: [PATCH 02/14] --- .github/workflows/ci.yaml | 77 ++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 447c220..7f543b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -124,52 +124,71 @@ jobs: # cache-from: type=gha # cache-to: type=gha,mode=max - commit-lint: + lint-commit: + name: Lint commits & MR title runs-on: ubuntu-latest + container: node:lts-alpine steps: - - name: Check out code - uses: actions/checkout@v3 - with: - fetch-depth: 0 # needed to compare against history - - name: Install dependencies - run: npm ci + - uses: actions/checkout@v3 + - run: | + apk add --no-cache git openssh npm + npm install -g @commitlint/cli \ + @commitlint/config-conventional \ + commitlint-plugin-regex-match - name: Run commitlint run: | - git fetch origin main --depth=1 - npx commitlint --from=origin/main --to=HEAD + if [ "${{ github.event_name }}" = "pull_request" ]; then + title="${{ github.event.pull_request.title#Draft: }}" + echo "$title" | npx commitlint + else + git log -1 --pretty=format:"%s" | npx commitlint + fi - calculate-next-release: - needs: commit-lint + calculate0tag: + name: Calculate next tag runs-on: ubuntu-latest + container: node:lts-alpine + needs: lint-commit steps: - - name: Check out code - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Install dependencies - run: npm ci - - name: Dry-run semantic-release - id: dryrun + - run: | + apk add --no-cache git openssh npm + npm install -g semantic-release@20.1.0 \ + @semantic-release/exec \ + @semantic-release/github + - id: dryrun + name: Dry-run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npx semantic-release --dry-run --no-ci \ - > dry-run.log 2>&1 - - name: Show next version - run: | - grep "The next release version is" -m1 dry-run.log + run: npx semantic-release --dry-run --no-ci > dry-run.log 2>&1 + - name: Export version to env + run: grep "The next release version is" -m1 dry-run.log > release.env + - uses: actions/upload-artifact@v3 + with: + name: release-env + path: release.env - release: - needs: [commit-lint, calculate-next-release] + release_build: + name: Release to GitHub if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest + container: node:lts-alpine + needs: calculate_tag steps: - - name: Check out code - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Install dependencies - run: npm ci + - uses: actions/download-artifact@v3 + with: + name: release-env + path: . + - run: | + apk add --no-cache git openssh npm + npm install -g semantic-release@20.1.0 \ + @semantic-release/exec \ + @semantic-release/github - name: Run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5fb0c1b2c4b66dacbbc1ceb310777e635e52ee95 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:16:25 +0100 Subject: [PATCH 03/14] feat(ci): update linting and semantic release steps in CI pipeline --- .github/workflows/ci.yaml | 52 ++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7f543b8..fb4ab70 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -124,47 +124,46 @@ jobs: # cache-from: type=gha # cache-to: type=gha,mode=max - lint-commit: + lint_commit: name: Lint commits & MR title runs-on: ubuntu-latest - container: node:lts-alpine steps: - uses: actions/checkout@v3 - - run: | - apk add --no-cache git openssh npm - npm install -g @commitlint/cli \ - @commitlint/config-conventional \ - commitlint-plugin-regex-match + - uses: actions/setup-node@v3 + with: + node-version: "18" + - run: npm install -g @commitlint/cli @commitlint/config-conventional commitlint-plugin-regex-match - name: Run commitlint run: | if [ "${{ github.event_name }}" = "pull_request" ]; then - title="${{ github.event.pull_request.title#Draft: }}" - echo "$title" | npx commitlint + TITLE="${{ github.event.pull_request.title }}" + # strip leading "Draft: " if present + TITLE="${TITLE#Draft: }" + echo "$TITLE" | npx commitlint else git log -1 --pretty=format:"%s" | npx commitlint fi - calculate0tag: + calculate_tag: name: Calculate next tag + needs: lint_commit runs-on: ubuntu-latest - container: node:lts-alpine - needs: lint-commit steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - run: | - apk add --no-cache git openssh npm - npm install -g semantic-release@20.1.0 \ - @semantic-release/exec \ - @semantic-release/github - - id: dryrun - name: Dry-run semantic-release + - uses: actions/setup-node@v3 + with: + node-version: "18" + - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github + - name: Dry-run semantic-release + id: dryrun env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release --dry-run --no-ci > dry-run.log 2>&1 - name: Export version to env - run: grep "The next release version is" -m1 dry-run.log > release.env + run: | + grep "The next release version is" -m1 dry-run.log > release.env - uses: actions/upload-artifact@v3 with: name: release-env @@ -172,10 +171,9 @@ jobs: release_build: name: Release to GitHub + needs: calculate_tag if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest - container: node:lts-alpine - needs: calculate_tag steps: - uses: actions/checkout@v3 with: @@ -183,12 +181,10 @@ jobs: - uses: actions/download-artifact@v3 with: name: release-env - path: . - - run: | - apk add --no-cache git openssh npm - npm install -g semantic-release@20.1.0 \ - @semantic-release/exec \ - @semantic-release/github + - uses: actions/setup-node@v3 + with: + node-version: "18" + - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github - name: Run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b4940d67e614c03436d3b91e888e44a2a8362440 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:21:20 +0100 Subject: [PATCH 04/14] feat(CF-4): add semantic release and commit lint configuration --- .github/workflows/ci.yaml | 13 ++++++------- commitlint.config.js | 6 +++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fb4ab70..41b80f6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -145,7 +145,6 @@ jobs: fi calculate_tag: - name: Calculate next tag needs: lint_commit runs-on: ubuntu-latest steps: @@ -161,16 +160,15 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release --dry-run --no-ci > dry-run.log 2>&1 - - name: Export version to env - run: | - grep "The next release version is" -m1 dry-run.log > release.env - - uses: actions/upload-artifact@v3 + - name: Export next version + run: grep "The next release version is" -m1 dry-run.log > release.env + - name: Upload version artifact + uses: actions/upload-artifact@v4 with: name: release-env path: release.env release_build: - name: Release to GitHub needs: calculate_tag if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest @@ -178,7 +176,8 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/download-artifact@v3 + - name: Download version artifact + uses: actions/download-artifact@v4 with: name: release-env - uses: actions/setup-node@v3 diff --git a/commitlint.config.js b/commitlint.config.js index 415287c..2f328b6 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -25,5 +25,9 @@ module.exports = { 'scope-empty': [2, 'never'], // allow any subject-case 'subject-case': [0] - } + }, + ignores: [ + (message) => message.includes('Draft:') + ] + }; From fcaa3cf58b59d59955837d4582d1ec8812c80653 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:33:50 +0100 Subject: [PATCH 05/14] feat(CF-4): add semantic release and commit lint configuration --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 41b80f6..ffdd71f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -145,8 +145,11 @@ jobs: fi calculate_tag: + name: Calculate next version tag needs: lint_commit runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 with: @@ -157,8 +160,6 @@ jobs: - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github - name: Dry-run semantic-release id: dryrun - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release --dry-run --no-ci > dry-run.log 2>&1 - name: Export next version run: grep "The next release version is" -m1 dry-run.log > release.env @@ -169,9 +170,12 @@ jobs: path: release.env release_build: + name: Build and release needs: calculate_tag if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 with: @@ -185,6 +189,4 @@ jobs: node-version: "18" - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github - name: Run semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release From dfdcb14eb62fe817378beed7de0674970b5889ba Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:37:27 +0100 Subject: [PATCH 06/14] feat(ci): update linting steps and improve semantic release logging --- .github/workflows/ci.yaml | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ffdd71f..209e9bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -125,27 +125,17 @@ jobs: # cache-to: type=gha,mode=max lint_commit: - name: Lint commits & MR title runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: "18" + node-version: "lts/*" - run: npm install -g @commitlint/cli @commitlint/config-conventional commitlint-plugin-regex-match - - name: Run commitlint - run: | - if [ "${{ github.event_name }}" = "pull_request" ]; then - TITLE="${{ github.event.pull_request.title }}" - # strip leading "Draft: " if present - TITLE="${TITLE#Draft: }" - echo "$TITLE" | npx commitlint - else - git log -1 --pretty=format:"%s" | npx commitlint - fi + - name: Lint commit message + run: git log -1 --pretty=format:"%s" | npx commitlint calculate_tag: - name: Calculate next version tag needs: lint_commit runs-on: ubuntu-latest env: @@ -154,23 +144,38 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - uses: actions/setup-node@v3 with: - node-version: "18" + node-version: "lts/*" + - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github + - name: Dry-run semantic-release id: dryrun - run: npx semantic-release --dry-run --no-ci > dry-run.log 2>&1 + run: | + set -o pipefail + npx semantic-release --dry-run --no-ci 2>&1 | tee dry-run.log + continue-on-error: true + + - name: Dump dry-run.log + if: always() + run: | + echo "=== semantic-release dry-run output ===" + cat dry-run.log + - name: Export next version + if: success() run: grep "The next release version is" -m1 dry-run.log > release.env + - name: Upload version artifact + if: success() uses: actions/upload-artifact@v4 with: name: release-env path: release.env release_build: - name: Build and release needs: calculate_tag if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest @@ -180,13 +185,16 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Download version artifact - uses: actions/download-artifact@v4 + + - uses: actions/download-artifact@v4 with: name: release-env + - uses: actions/setup-node@v3 with: - node-version: "18" + node-version: "lts/*" + - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github + - name: Run semantic-release run: npx semantic-release From f40f0c6f3b6aaa73557d4c78dc1102eeea448c0b Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:40:49 +0100 Subject: [PATCH 07/14] feat(ci): enhance CI pipeline with linting for commit messages and improved semantic release steps --- .github/workflows/ci.yaml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 209e9bd..3872d74 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -125,6 +125,7 @@ jobs: # cache-to: type=gha,mode=max lint_commit: + name: Lint Commit Message runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -136,6 +137,7 @@ jobs: run: git log -1 --pretty=format:"%s" | npx commitlint calculate_tag: + name: Calculate Release Tag needs: lint_commit runs-on: ubuntu-latest env: @@ -149,7 +151,13 @@ jobs: with: node-version: "lts/*" - - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github + - run: npm install -g semantic-release@20.1.0 \ + @semantic-release/commit-analyzer \ + @semantic-release/release-notes-generator \ + @semantic-release/changelog \ + @semantic-release/exec \ + @semantic-release/git \ + @semantic-release/github - name: Dry-run semantic-release id: dryrun @@ -176,6 +184,7 @@ jobs: path: release.env release_build: + name: Release Build needs: calculate_tag if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest @@ -194,7 +203,13 @@ jobs: with: node-version: "lts/*" - - run: npm install -g semantic-release@20.1.0 @semantic-release/exec @semantic-release/github + - run: npm install -g semantic-release@20.1.0 \ + @semantic-release/commit-analyzer \ + @semantic-release/release-notes-generator \ + @semantic-release/changelog \ + @semantic-release/exec \ + @semantic-release/git \ + @semantic-release/github - name: Run semantic-release run: npx semantic-release From 8f57adb5793aa9637a9b8dbb5d094aadc3fdebb8 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:42:38 +0100 Subject: [PATCH 08/14] fix(ci): improve readability of semantic-release installation step --- .github/workflows/ci.yaml | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3872d74..a7f096a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -151,13 +151,15 @@ jobs: with: node-version: "lts/*" - - run: npm install -g semantic-release@20.1.0 \ - @semantic-release/commit-analyzer \ - @semantic-release/release-notes-generator \ - @semantic-release/changelog \ - @semantic-release/exec \ - @semantic-release/git \ - @semantic-release/github + - name: Install semantic-release & plugins + run: > + npm install -g semantic-release@20.1.0 + @semantic-release/commit-analyzer + @semantic-release/release-notes-generator + @semantic-release/changelog + @semantic-release/exec + @semantic-release/git + @semantic-release/github - name: Dry-run semantic-release id: dryrun @@ -203,13 +205,15 @@ jobs: with: node-version: "lts/*" - - run: npm install -g semantic-release@20.1.0 \ - @semantic-release/commit-analyzer \ - @semantic-release/release-notes-generator \ - @semantic-release/changelog \ - @semantic-release/exec \ - @semantic-release/git \ - @semantic-release/github + - name: Install semantic-release & plugins + run: > + npm install -g semantic-release@20.1.0 + @semantic-release/commit-analyzer + @semantic-release/release-notes-generator + @semantic-release/changelog + @semantic-release/exec + @semantic-release/git + @semantic-release/github - name: Run semantic-release run: npx semantic-release From bb30ac92e1a155df473aa10adad76b4f3010dc22 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 22:53:54 +0100 Subject: [PATCH 09/14] fix(ci): update actions to latest versions and improve commit message linting step --- .github/workflows/ci.yaml | 44 +++++++++++---------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a7f096a..08b9b43 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -128,13 +128,14 @@ jobs: name: Lint Commit Message runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "lts/*" - run: npm install -g @commitlint/cli @commitlint/config-conventional commitlint-plugin-regex-match - name: Lint commit message - run: git log -1 --pretty=format:"%s" | npx commitlint + run: | + git log -1 --pretty=format:"%s" | npx commitlint calculate_tag: name: Calculate Release Tag @@ -143,23 +144,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: "lts/*" - - name: Install semantic-release & plugins - run: > - npm install -g semantic-release@20.1.0 - @semantic-release/commit-analyzer - @semantic-release/release-notes-generator - @semantic-release/changelog - @semantic-release/exec - @semantic-release/git - @semantic-release/github + run: npm install -g semantic-release@20.1.0 @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github - name: Dry-run semantic-release id: dryrun @@ -167,17 +159,15 @@ jobs: set -o pipefail npx semantic-release --dry-run --no-ci 2>&1 | tee dry-run.log continue-on-error: true - - name: Dump dry-run.log if: always() run: | echo "=== semantic-release dry-run output ===" cat dry-run.log - - name: Export next version if: success() - run: grep "The next release version is" -m1 dry-run.log > release.env - + run: | + grep "The next release version is" -m1 dry-run.log | cut -d' ' -f6 > release.env - name: Upload version artifact if: success() uses: actions/upload-artifact@v4 @@ -193,27 +183,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/download-artifact@v4 with: name: release-env - - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: "lts/*" - - name: Install semantic-release & plugins - run: > - npm install -g semantic-release@20.1.0 - @semantic-release/commit-analyzer - @semantic-release/release-notes-generator - @semantic-release/changelog - @semantic-release/exec - @semantic-release/git - @semantic-release/github + run: npm install -g semantic-release@20.1.0 @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github - name: Run semantic-release run: npx semantic-release From 43424e3411c6cacff47c1a0015d6cffc0b60ec41 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 23:02:54 +0100 Subject: [PATCH 10/14] fix(ci): add additional semantic-release plugins for enhanced functionality --- .github/workflows/ci.yaml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 08b9b43..b3b15e5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -143,6 +143,8 @@ jobs: runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + outputs: + next_version: ${{ steps.set_version.outputs.version }} steps: - uses: actions/checkout@v4 with: @@ -155,6 +157,9 @@ jobs: - name: Dry-run semantic-release id: dryrun + env: + # Override branch detection to simulate main branch + GITHUB_REF: refs/heads/main run: | set -o pipefail npx semantic-release --dry-run --no-ci 2>&1 | tee dry-run.log @@ -164,12 +169,19 @@ jobs: run: | echo "=== semantic-release dry-run output ===" cat dry-run.log - - name: Export next version - if: success() + - name: Extract next version + id: set_version run: | - grep "The next release version is" -m1 dry-run.log | cut -d' ' -f6 > release.env + # Simple and reliable version extraction + VERSION=$(grep -E "The next release version is [0-9]+\.[0-9]+\.[0-9]+" dry-run.log | awk '{print $NF}') + VERSION=${VERSION:-$(grep -E "next release version is [0-9]+\.[0-9]+\.[0-9]+" dry-run.log | awk '{print $NF}')} + VERSION=${VERSION:-$(grep -E "would publish version [0-9]+\.[0-9]+\.[0-9]+" dry-run.log | awk '{print $NF}')} + VERSION=${VERSION:-unknown} + + echo "Next release version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "$VERSION" > release.env - name: Upload version artifact - if: success() uses: actions/upload-artifact@v4 with: name: release-env @@ -189,11 +201,13 @@ jobs: - uses: actions/download-artifact@v4 with: name: release-env + - name: Display next version + run: | + echo "Next release version: $(cat release.env)" - uses: actions/setup-node@v4 with: node-version: "lts/*" - name: Install semantic-release & plugins run: npm install -g semantic-release@20.1.0 @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github - - name: Run semantic-release run: npx semantic-release From 41625189189341fdea78389e45f27b452456e390 Mon Sep 17 00:00:00 2001 From: dockninja Date: Fri, 11 Jul 2025 23:53:11 +0100 Subject: [PATCH 11/14] fix(ci): update lint_commit job to run on all events and rename lint_code job for clarity --- .github/workflows/ci.yaml | 271 +++++++++++++++----------------------- 1 file changed, 109 insertions(+), 162 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b3b15e5..360207a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,118 +12,6 @@ permissions: pull-requests: write jobs: - # lint: - # name: Lint (all modules) - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Go - # uses: actions/setup-go@v5 - # with: - # go-version: 1.24.3 - # - name: Cache Go modules & build - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('go.work.sum','**/go.sum') }} - # restore-keys: | - # ${{ runner.os }}-go- - # - name: Sync workspace - # run: go work sync - # - name: go fmt - # run: | - # ( cd shuttle && go fmt ./... ) - # ( cd weaver && go fmt ./... ) - # - name: go vet - # env: - # GOFLAGS: -mod=readonly - # run: go vet ./shuttle/... ./weaver/... - # - name: go mod tidy check - # run: | - # ( cd shuttle && go mod tidy ) - # ( cd weaver && go mod tidy ) - # - name: golangci-lint - # uses: golangci/golangci-lint-action@v8 - # with: - # version: v2.1 - # args: ./shuttle/... ./weaver/... --timeout 5m - - # test: - # name: Test ${{ matrix.app }} - # needs: lint - # runs-on: ubuntu-latest - # strategy: - # matrix: - # app: [shuttle, weaver] - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Go - # uses: actions/setup-go@v5 - # with: - # go-version: 1.24.3 - # - name: Cache Go modules & build - # uses: actions/cache@v4 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - # restore-keys: | - # ${{ runner.os }}-go- - # - name: Sync workspace - # run: go work sync - # - name: Run tests for ${{ matrix.app }} - # working-directory: ${{ matrix.app }} - # run: go test ./... -v -coverprofile=coverage.out - # - name: Upload coverage - # uses: actions/upload-artifact@v4 - # with: - # name: coverage-${{ matrix.app }} - # path: coverage.out - - # build-and-push: - # name: Build & Push ${{ matrix.app }} - # needs: test - # runs-on: ubuntu-latest - # permissions: - # contents: read - # packages: write - # strategy: - # matrix: - # include: - # - app: shuttle - # docker_name: cf-shuttle - # - app: weaver - # docker_name: cf-weaver - - # steps: - # - uses: actions/checkout@v4 - # - uses: docker/setup-qemu-action@v2 - # - uses: docker/setup-buildx-action@v2 - # - uses: docker/login-action@v3 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Get short SHA - # id: vars - # run: echo "short_sha=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT - - # - name: Build & Push ${{ matrix.app }} - # uses: docker/build-push-action@v4 - # with: - # context: . - # file: build/${{ matrix.app }}/Dockerfile - # push: true - # tags: | - # ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_name }}:${{ steps.vars.outputs.short_sha }} - # ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_name }}:latest - # cache-from: type=gha - # cache-to: type=gha,mode=max - lint_commit: name: Lint Commit Message runs-on: ubuntu-latest @@ -133,63 +21,128 @@ jobs: with: node-version: "lts/*" - run: npm install -g @commitlint/cli @commitlint/config-conventional commitlint-plugin-regex-match - - name: Lint commit message + - name: Lint PR title run: | - git log -1 --pretty=format:"%s" | npx commitlint + PR_TITLE="${{ github.event.pull_request.title }}" + echo "$PR_TITLE" | npx commitlint - calculate_tag: - name: Calculate Release Tag - needs: lint_commit + lint_code: + name: Lint Go Code runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - outputs: - next_version: ${{ steps.set_version.outputs.version }} steps: - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 with: - fetch-depth: 0 - - uses: actions/setup-node@v4 + go-version: 1.24.3 + - name: Cache Go modules & build + uses: actions/cache@v4 with: - node-version: "lts/*" - - name: Install semantic-release & plugins - run: npm install -g semantic-release@20.1.0 @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/changelog @semantic-release/exec @semantic-release/git @semantic-release/github - - - name: Dry-run semantic-release - id: dryrun - env: - # Override branch detection to simulate main branch - GITHUB_REF: refs/heads/main + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('go.work.sum','**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Sync workspace + run: go work sync + - name: go fmt run: | - set -o pipefail - npx semantic-release --dry-run --no-ci 2>&1 | tee dry-run.log - continue-on-error: true - - name: Dump dry-run.log - if: always() - run: | - echo "=== semantic-release dry-run output ===" - cat dry-run.log - - name: Extract next version - id: set_version + ( cd shuttle && go fmt ./... ) + ( cd weaver && go fmt ./... ) + - name: go vet + env: + GOFLAGS: -mod=readonly + run: go vet ./shuttle/... ./weaver/... + - name: go mod tidy check run: | - # Simple and reliable version extraction - VERSION=$(grep -E "The next release version is [0-9]+\.[0-9]+\.[0-9]+" dry-run.log | awk '{print $NF}') - VERSION=${VERSION:-$(grep -E "next release version is [0-9]+\.[0-9]+\.[0-9]+" dry-run.log | awk '{print $NF}')} - VERSION=${VERSION:-$(grep -E "would publish version [0-9]+\.[0-9]+\.[0-9]+" dry-run.log | awk '{print $NF}')} - VERSION=${VERSION:-unknown} + ( cd shuttle && go mod tidy ) + ( cd weaver && go mod tidy ) + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: v2.1 + args: ./shuttle/... ./weaver/... --timeout 5m - echo "Next release version: $VERSION" - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "$VERSION" > release.env - - name: Upload version artifact + test_unit: + name: Test ${{ matrix.app }} + needs: lint_code + runs-on: ubuntu-latest + strategy: + matrix: + app: [shuttle, weaver] + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24.3 + - name: Cache Go modules & build + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Sync workspace + run: go work sync + - name: Run tests for ${{ matrix.app }} + working-directory: ${{ matrix.app }} + run: go test ./... -v -coverprofile=coverage.out + - name: Upload coverage uses: actions/upload-artifact@v4 with: - name: release-env - path: release.env + name: coverage-${{ matrix.app }} + path: coverage.out + + build-and-push: + name: Build & Push ${{ matrix.app }} + needs: test_unit + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + matrix: + include: + - app: shuttle + docker_name: cf-shuttle + - app: weaver + docker_name: cf-weaver - release_build: - name: Release Build - needs: calculate_tag + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get short SHA + id: vars + run: echo "short_sha=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT + + - name: Build & Push ${{ matrix.app }} + uses: docker/build-push-action@v4 + with: + context: . + file: build/${{ matrix.app }}/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: | + ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_name }}:${{ steps.vars.outputs.short_sha }} + ${{ github.event_name == 'push' && format('ghcr.io/{0}/{1}:latest', github.repository_owner, matrix.docker_name) || '' }} + cache-from: type=gha + cache-to: type=gha,mode=max + + release: + name: Release + needs: + - test_unit + - build-and-push if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest env: @@ -198,12 +151,6 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/download-artifact@v4 - with: - name: release-env - - name: Display next version - run: | - echo "Next release version: $(cat release.env)" - uses: actions/setup-node@v4 with: node-version: "lts/*" From 55a900c22c67ae2eff54e9d91f98afa7e5f96f8f Mon Sep 17 00:00:00 2001 From: dockninja Date: Sat, 12 Jul 2025 00:18:40 +0100 Subject: [PATCH 12/14] fix(ci): correct job name reference in release step --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 360207a..c5b3e7e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -97,7 +97,7 @@ jobs: name: coverage-${{ matrix.app }} path: coverage.out - build-and-push: + build_and_push: name: Build & Push ${{ matrix.app }} needs: test_unit runs-on: ubuntu-latest @@ -142,7 +142,7 @@ jobs: name: Release needs: - test_unit - - build-and-push + - build_and_push if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest env: From 9220823be48a124a7261ef32c06ed5df8f1c1987 Mon Sep 17 00:00:00 2001 From: dockninja Date: Sat, 12 Jul 2025 00:29:01 +0100 Subject: [PATCH 13/14] fix(ci): enhance lint_commit job to correctly lint PR titles with escaped quotes --- .github/workflows/ci.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c5b3e7e..37cc352 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,6 +14,7 @@ permissions: jobs: lint_commit: name: Lint Commit Message + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -21,10 +22,21 @@ jobs: with: node-version: "lts/*" - run: npm install -g @commitlint/cli @commitlint/config-conventional commitlint-plugin-regex-match - - name: Lint PR title + + - name: Get PR title + id: get_pr_title run: | PR_TITLE="${{ github.event.pull_request.title }}" - echo "$PR_TITLE" | npx commitlint + # Escape quotes for JSON + PR_TITLE_ESCAPED=$(echo "$PR_TITLE" | sed 's/"/\\"/g') + echo "pr_title=$PR_TITLE_ESCAPED" >> $GITHUB_OUTPUT + + - name: Lint PR title + run: | + # Write title to temp file + echo "${{ steps.get_pr_title.outputs.pr_title }}" > pr_title.txt + # Lint from file + npx commitlint --edit pr_title.txt lint_code: name: Lint Go Code From f74b89e545e64f1ebdaa625b0f0b7381bac7cf5e Mon Sep 17 00:00:00 2001 From: dockninja Date: Sat, 12 Jul 2025 00:33:18 +0100 Subject: [PATCH 14/14] fix(ci): remove conditional execution for lint_commit job on pull requests --- .github/workflows/ci.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 37cc352..526540c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,6 @@ permissions: jobs: lint_commit: name: Lint Commit Message - if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -152,6 +151,11 @@ jobs: release: name: Release + permissions: + contents: write + issues: write + pull-requests: write + deployments: write needs: - test_unit - build_and_push