Skip to content

Commit

Permalink
merge(#1049): add file integrity checks to CI workflow
Browse files Browse the repository at this point in the history
* feat: add file integrity checks to CI workflow

Signed-off-by: Zsolt Rappi <[email protected]>

* feat: pin actions to commit SHA

Signed-off-by: Zsolt Rappi <[email protected]>

* fix: switch back to go 1.19

Signed-off-by: Zsolt Rappi <[email protected]>

* fix: code review findings

Signed-off-by: Zsolt Rappi <[email protected]>

---------

Signed-off-by: Zsolt Rappi <[email protected]>
Co-authored-by: Patrik Egyed <[email protected]>
  • Loading branch information
rappizs and pregnor authored Aug 31, 2023
1 parent a6f7678 commit 158c5bb
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,57 @@ on:
pull_request:

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

steps:
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #v4.1.0
with:
go-version: 1.19

- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3

- name: Check Go modules dependency file integrity
run: |
find . -type f -name go.mod | while read module_file; do
module=$(dirname "$module_file")
pushd "$module" > /dev/null
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
popd > /dev/null
done
- name: Check generated file integrity
run: |
make generate manifests
if [ "$(git status --porcelain)" != "" ]; then
printf >&2 '\ngenerating code files 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
name: Build
runs-on: ubuntu-22.04

steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #v4.1.0
with:
go-version: 1.19

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3

- name: License cache
uses: actions/cache@v3
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
path: .licensei.cache
key: license-v1-${{ hashFiles('**/go.sum') }}
Expand Down

0 comments on commit 158c5bb

Please sign in to comment.