Update dependency hashicorp/terraform-provider-aws to v5.17.0 #531
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
name: lint-test-and-generate | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: | |
contents: read | |
jobs: | |
golangci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.19 | |
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0 | |
with: | |
version: v1.53.3 | |
args: "--timeout=10m" | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0 | |
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 | |
with: | |
terraform_version: 1.3.6 | |
terraform_wrapper: false | |
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.19 | |
cache: true | |
cache-dependency-path: go.sum | |
- name: install jsonnet-bundler | |
run: | | |
go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest | |
- name: run tests | |
run: | | |
go test -v ./... | |
generate: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
needs: | |
- golangci | |
- test | |
outputs: | |
entries: ${{ steps.load-managed-cfg.outputs.entries }} | |
steps: | |
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | |
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v3.3.1 | |
with: | |
go-version: 1.19 | |
- name: setup jb packages for docsonnet steps | |
run: | | |
go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest | |
jb install | |
mkdir generator-out | |
mv vendor generator-out/vendor | |
- name: run libgenerator with stored config | |
run: | | |
go run ./cmd/libgenerator \ | |
gen --out "$(pwd)/generator-out" --config "$(pwd)/cfg/managed.json" --loglevel debug | |
- name: tar artifact | |
run: | | |
tar -czf generator-out.tar.gz ./generator-out | |
- name: create artifact | |
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: generator-out | |
path: generator-out.tar.gz | |
# Set the contents of cfg/managed.json as a github output so that we can run a matrix job where a GitHub Action | |
# job runs for each entry in the config. | |
- id: load-managed-cfg | |
run: echo entries="$(cat "$(pwd)/cfg/managed.json" | jq -Mc .)" >> "$GITHUB_OUTPUT" | |
copy: | |
if: github.event_name == 'pull_request' | |
needs: generate | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
entry: ${{ fromJSON(needs.generate.outputs.entries) }} | |
steps: | |
- name: download generated code | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: generator-out | |
- name: untar generated code | |
run: | | |
tar -xvf ./generator-out.tar.gz | |
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |
with: | |
go-version: 1.19 | |
- name: generator docs with docsonnet | |
run: | | |
# TODO: Replace with jsonnet-libs when relevant PRs are merged | |
go install github.com/yorinasub17/docsonnet@installable | |
docsonnet \ | |
-J "$(pwd)/generator-out/vendor" \ | |
-o "$(pwd)/generator-out/${{ matrix.entry.repo }}/docs/${{ matrix.entry.subdir }}" \ | |
"$(pwd)/generator-out/${{ matrix.entry.repo }}/${{ matrix.entry.subdir }}/main.libsonnet" | |
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | |
with: | |
token: ${{ secrets.TFLIBSONNET_CI_GITHUB_TOKEN }} | |
repository: tf-libsonnet/${{ matrix.entry.repo }} | |
path: ${{ matrix.entry.repo }} | |
fetch-depth: 0 | |
- name: switch to pr branch or create | |
run: | | |
cd ${{ matrix.entry.repo }} | |
git switch "$PR_BRANCH" || git switch -c "$PR_BRANCH" | |
env: | |
PR_BRANCH: pr-${{ github.event.pull_request.number }} | |
- name: clear tracked files before generating (to support deletes) | |
run: | | |
rm -vr ${{ matrix.entry.repo }}/docs/${{ matrix.entry.subdir }} || true | |
rm -vr ${{ matrix.entry.repo }}/${{ matrix.entry.subdir }} || true | |
- name: copy generated code and update permissions | |
run: | | |
rsync -va ./generator-out/${{ matrix.entry.repo }}/ ${{ matrix.entry.repo }} | |
tree ${{ matrix.entry.repo }} | |
cd ${{ matrix.entry.repo }} | |
git status | |
- name: import gpg signing key | |
uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 | |
with: | |
gpg_private_key: ${{ secrets.TFLIBSONNET_CI_GPG_KEY }} | |
passphrase: ${{ secrets.TFLIBSONNET_CI_GPG_PASSPHRASE }} | |
git_config_global: true | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_committer_name: "tflibsonnet-ci" | |
git_committer_email: "[email protected]" | |
- name: commit generated code to new branch if files changed | |
id: auto-commit-action | |
uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a # v4.16.0 | |
with: | |
repository: ${{ matrix.entry.repo }} | |
branch: pr-${{ github.event.pull_request.number }} | |
commit_message: "Generate libsonnet source from libgenerator PR ${{ github.event.pull_request.html_url }}" | |
commit_options: "-S -s" | |
commit_user_name: "tflibsonnet-ci" | |
commit_user_email: "[email protected]" | |
- name: open PR if changes were made | |
if: steps.auto-commit-action.outputs.changes_detected == 'true' | |
run: | | |
cd ${{ matrix.entry.repo }} | |
if [[ -z "$(gh pr view "$PR_BRANCH" --json state -q 'select(.state == "OPEN")')" ]]; then | |
gh pr create \ | |
-t "$PR_TITLE" \ | |
-b "$(echo -e "_(original: $PR_HTML_URL)_\n\n$PR_BODY")" \ | |
-B main -H "$PR_BRANCH" | |
fi | |
env: | |
PR_BRANCH: pr-${{ github.event.pull_request.number }} | |
PR_TITLE: ${{ github.event.pull_request.title }} | |
PR_HTML_URL: ${{ github.event.pull_request.html_url }} | |
PR_BODY: ${{ github.event.pull_request.body }} | |
GITHUB_TOKEN: ${{ secrets.TFLIBSONNET_CI_GITHUB_TOKEN }} |