Update dependency hashicorp/terraform-provider-azurerm to v3.117.0 #788
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@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version: 1.19 | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 | |
with: | |
version: v1.53.3 | |
args: "--timeout=10m" | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0 | |
with: | |
terraform_version: 1.3.6 | |
terraform_wrapper: false | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # 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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | |
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@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.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@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.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@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5.0.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 }} |