Skip to content

Commit

Permalink
feat: add file integrity checks to CI workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Zsolt Rappi <[email protected]>
  • Loading branch information
rappizs committed Aug 23, 2023
1 parent 9c2ac52 commit 20e8ad8
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,52 @@ on:
pull_request:

jobs:
check-integrity:
name: Check integrity
runs-on: ubuntu-latest

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.7

- name: Checkout code
uses: actions/checkout@v3

- name: Check Go modules dependency file integrity
run: |
for module_file in $(find . -type f -name go.mod); do
module=$(dirname $module_file)
cd "$module"
go mod tidy
if [ "$(git status --porcelain)" != "" ]; then
printf >&2 '\n`go mod tidy` in module `%s` results in a dirty state, Go mod files are not in sync with the source code files, differences:\n\n%s\n\n' "$module" "$(git diff)"
git reset --hard
exit 1
fi
cd - > /dev/null
done
- name: Check generated file integrity
run: |
make generate manifests
git status --porcelain
git version
if [ "$(git status --porcelain)" != "" ]; then
printf >&2 '\n`make generate and manifests` results in a dirty state, generated files are not in sync with the source code files, differences:\n\n%s\n\n' "$(git diff)"
git reset --hard
exit 1
fi
build:
runs-on: ubuntu-latest

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.20.7

- name: Checkout code
uses: actions/checkout@v3
Expand Down

0 comments on commit 20e8ad8

Please sign in to comment.