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

Commit

Permalink
chore: Synced file(s) with cloudquery/.github (#1391)
Browse files Browse the repository at this point in the history
* 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
cq-bot and hermanschaaf authored Aug 5, 2022
1 parent cc33980 commit 32b53c3
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ Use the following steps to ensure your PR is ready to be reviewed
- [ ] Lint your changes via `golangci-lint run` 🚨 (install golangci-lint [here](https://golangci-lint.run/usage/install/#local-installation))
- [ ] Update or add tests. Learn more about testing [here](https://docs.cloudquery.io/docs/developers/sdk/testing) 🧪
- [ ] Update the docs by running `go run ./docs/docs.go` and committing the changes 📃
- [ ] If adding a new resource, add [relevant Terraform files](../terraform) in a separate PR 📂
- [ ] Ensure the status checks below are successful ✅
61 changes: 61 additions & 0 deletions .github/workflows/check_generated_code_drift.yml
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
2 changes: 1 addition & 1 deletion .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# GoReleaser will upload the binaries to GitHub and mark the release as ready
- name: Mark as pre-release
if: steps.release.outputs.release_created
uses: tubone24/update_release@2146f1550a23d883b8ea0c036298ed74cd65eac6
uses: tubone24/update_release@ef1052963da78ecdc430f10503a39f46507d639d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.release.outputs.tag_name }}
Expand Down
15 changes: 15 additions & 0 deletions scripts/regenerate-changed-directories.sh
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

0 comments on commit 32b53c3

Please sign in to comment.