This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Synced file(s) with cloudquery/.github (#1391)
* chore: Synced file(s) with cloudquery/.github * Add missing workflow file Co-authored-by: cq-bot <null> Co-authored-by: Herman Schaaf <[email protected]>
- Loading branch information
1 parent
cc33980
commit 32b53c3
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: check_generated_code_drift | ||
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 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: dorny/paths-filter@v2 | ||
id: changes | ||
with: | ||
filters: | | ||
src: | ||
- 'resources/services/**/*' | ||
- name: Set up Go 1.x | ||
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request' | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ^1.18 | ||
- name: Install tools | ||
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request' | ||
run: | | ||
make install-tools | ||
- uses: actions/cache@v3 | ||
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request' | ||
with: | ||
# In order: | ||
# * Module download cache | ||
# * Build cache (Linux) | ||
# * Build cache (Mac) | ||
# * Build cache (Windows) | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
~/Library/Caches/go-build | ||
~\AppData\Local\go-build | ||
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-${{ matrix.go }}- | ||
- name: Run go generate on changed service directories | ||
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request' | ||
run: | | ||
./scripts/regenerate-changed-directories.sh | ||
- name: Fail if any files are changed | ||
if: steps.changes.outputs.src == 'true' || github.event_name != 'pull_request' | ||
run: | | ||
echo "List of files changed after running go generate:" | ||
git status -s ./resources/services | ||
test "$(git status -s ./resources/services | wc -l)" -eq 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
set -x | ||
set -e | ||
|
||
for d in ./resources/services/*/ ; do | ||
# check whether directory changed in this branch | ||
if git diff --quiet origin/main HEAD -- $d; then | ||
echo "no changes in $d"; | ||
continue; | ||
fi | ||
|
||
# regenerate if //check-for-changes is present in an .hcl file | ||
if grep -s -q '//check-for-changes' "$d"*.hcl; then | ||
(cd $d && go generate); | ||
fi | ||
done |