Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/tasks: ensure go.mod/sum and generated pb code are up-to-date #223

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v2
with:
version: '3.x'
version: '23.4'
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Taskfile
Expand All @@ -33,8 +33,8 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
cache: true
go-version: '1.21'
check-latest: true

- name: Install dependencies
env:
Expand All @@ -45,13 +45,17 @@ jobs:
task install:deps
go mod download

- name: Compile Protobuf
- name: Check tidiness of go.mod and go.sum
run: |
task pb:compile:v1
./scripts/mods/check_tidy

- name: Ensure generated protobuf Go source is up-to-date
run: |
./scripts/proto/check_up

- name: Compile packages, apps, and specs
run: |
go build ./pkg/... ./cmd/... ./test/specifications/...
go build -mod=readonly ./pkg/... ./cmd/... ./test/specifications/...

- name: Lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -76,9 +80,9 @@ jobs:
token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v2
with:
version: '3.x'
version: '23.4'
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Taskfile
Expand All @@ -87,10 +91,10 @@ jobs:
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
go-version: '1.21'
check-latest: true

- name: Install dependencies
env:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/on-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v2
with:
version: '3.x'
version: '23.4'
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Taskfile
Expand All @@ -30,10 +30,10 @@ jobs:
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
go-version: '1.21'
check-latest: true

- name: Install dependencies
env:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v2
with:
version: '3.x'
version: '23.4'
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Install Taskfile
Expand All @@ -29,10 +29,10 @@ jobs:
repo-token: ${{ secrets.KWIL_MACH_SECRET }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.19.0'
cache: true
go-version: '1.21'
check-latest: true

- name: Install dependencies
env:
Expand Down
7 changes: 6 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ tasks:
- git submodule update --init

git:sync:
desc: Sync git submodules
desc: Sync git submodules to required revisions
cmds:
- git submodule update

git:advance:
desc: Advance git submodules to latest main revision
cmds:
- git submodule update --remote

Expand Down
13 changes: 13 additions & 0 deletions scripts/mods/check_tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

go mod tidy

STATUS=$(git status go.mod go.sum --porcelain)

if [[ -n "$STATUS" ]]; then
echo "Changes detected in 'go.mod' or 'go.sum' after running 'go mod tidy'!"
exit 1
else
echo "No changes detected in 'go.mod' or 'go.sum'."
exit 0
fi
22 changes: 22 additions & 0 deletions scripts/proto/check_up
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# This script ensures that the generated protobuf .go files are up-to-date.

pushd $(git rev-parse --show-toplevel) > /dev/null

# Force regenerate of pb Go code.
task -f pb:compile:v1

STATUS=$(git status api/protobuf/tx/v1 --porcelain)

popd > /dev/null

if [[ -n "$STATUS" ]]; then
echo "Changes detected in api/protobuf/tx/v1 !"
exit 1
else
echo "No changes detected in the directory."
exit 0
fi

popd