Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

fix(build): Don't filter paths and enforce //check-for-changes on new cq-gen config files #1401

Merged
merged 5 commits into from
Aug 9, 2022
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
8 changes: 4 additions & 4 deletions .github/workflows/check_generated_code_drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ on:
push:
branches:
- main
paths:
- 'resources/services/**/*'
pull_request:
branches:
- main
paths:
- 'resources/services/**/*'
jobs:
check_generated_code_drift:
name: Check Generated Code for Drift
Expand Down Expand Up @@ -49,6 +45,10 @@ jobs:
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go }}-
- name: Fail if new cq-gen config file is missing //check-for-changes
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request'
run: |
./scripts/check-new-files-have-check-for-changes.sh
- name: Run go generate on changed service directories
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request'
run: |
Expand Down
17 changes: 17 additions & 0 deletions scripts/check-new-files-have-check-for-changes-flag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set -x
set -e

for d in ./resources/services/*/ ; do
# check if there is a new cq-gen .hcl config file
if git diff --name-status origin/main HEAD -- $d | grep -q '^A.*\.hcl$'; then
# .hcl file was newly added
if grep -q '//check-for-changes' "$d"*.hcl; then
echo "cq-gen config files in $d are OK";
else
echo "//check-for-changes must be present in all new cq-gen config files";
exit 1;
fi;
else
echo "No new cq-gen config files found in $d"
fi;
done