Skip to content

Commit

Permalink
feat: add github action to ensure consistency
Browse files Browse the repository at this point in the history
If the snapcraft yaml is out of sync with the go.mod file, fail
the build
  • Loading branch information
SimonRichardson committed Jun 25, 2024
1 parent d3ac273 commit d5d083c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,39 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v6

go-version:
name: Go Version
runs-on: [self-hosted, linux, arm64, aws, large]
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
binary: ["jujud", "juju"]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache: true

- name: Get go.mod version
id: go_mod_version
shell: bash
run: echo "GO_MOD_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV

- name: Get binary snapcraft.yaml
id: get_binary_snapcraft
uses: mikefarah/yq@master
with:
cmd: yq -r '.parts | .["${{ matrix.binary }}"] | .["go-channel"]' snap/snapcraft.yaml

- name: Ensure go version
echo ${{ steps.get_binary_snapcraft.outputs.result }} | grep -q "$GO_MOD_VERSION"
if [ $? -ne 0 ]; then
echo "Go version in go.mod ($mod_version) does not match snapcraft.yaml ($snap_version)"
exit 1
fi
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ parts:
after:
- libdqlite
plugin: juju-go
go-channel: 1.20/stable
go-channel: 1.21/stable
source: .
go-packages:
- github.com/juju/juju/cmd/jujud
Expand Down

0 comments on commit d5d083c

Please sign in to comment.