constellation/.github/workflows/test-go-generate.yml

73 lines
2.3 KiB
YAML
Raw Normal View History

2022-11-14 08:38:07 -05:00
name: Go generate check
on:
workflow_dispatch:
push:
branches:
- main
- "release/**"
pull_request:
jobs:
go-generate:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
2022-11-14 08:38:07 -05:00
with:
path: constellation
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
token: ${{ !github.event.pull_request.head.repo.fork && secrets.TIDY_RENOVATE_PUSH || '' }}
2022-11-14 08:38:07 -05:00
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
2022-11-14 08:38:07 -05:00
with:
go-version: "1.19.4"
2022-11-14 08:38:07 -05:00
cache: true
cache-dependency-path: constellation/go.mod
- name: Install docgen
uses: ./constellation/.github/actions/install_docgen
- name: Install stringer
shell: bash
run: go install golang.org/x/tools/cmd/stringer@latest
- name: Get Go submodules
id: submods
shell: bash
working-directory: constellation
run: |
mods=$(go list -f '{{.Dir}}' -m | xargs)
echo "Found mods: $mods"
echo "submods=${mods}" >> "$GITHUB_OUTPUT"
- name: Go generate check
id: generatecheck
2022-11-14 08:38:07 -05:00
shell: bash
working-directory: constellation
run: |
mods="${{ steps.submods.outputs.submods }}"
for mod in $mods; do
go generate $mod/...
done
git diff --exit-code
- name: Push changes on renovate branch
if: |
failure() &&
(steps.generatecheck.conclusion == 'failure')
&& startsWith(github.head_ref, 'renovate/') &&
!github.event.pull_request.head.repo.fork
shell: bash
working-directory: constellation
run: |
diff_dirs=$(git diff --name-only)
if [[ "${diff_dirs}" == "internal/versions/versions.go" ]]; then
echo "internal/versions/versions.go is the only changed file, so we can push the changes."
git config --global user.name "renovate[bot]"
git config --global user.email "29139614+renovate[bot]@users.noreply.github.com"
git commit -am "[bot] Update versions.go"
git push
fi