chore: Generates and checks PURLS on the CI #3698
This file contains hidden or 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: 'Code Health' | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| merge_group: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: Set up Go | |
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 | |
| with: | |
| go-version-file: 'cfn-resources/go.mod' | |
| - name: Build | |
| run: | | |
| cd cfn-resources | |
| go build -v ./... | |
| - name: Generate purls for all resources | |
| run: make gen-purls | |
| - name: Check purls for all resources | |
| run: make check-purls | |
| mock-generation: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: Set up Go | |
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 | |
| with: | |
| go-version-file: 'cfn-resources/go.mod' | |
| - name: Generate mocks | |
| run: | | |
| make tools generate-mocks | |
| - name: Check for uncommited files | |
| run: | | |
| FILES=$(git ls-files -o -m --directory --exclude-standard --no-empty-directory) | |
| LINES=$(echo "$FILES" | awk 'NF' | wc -l) | |
| if [ "$LINES" -ne 0 ]; then | |
| echo "Detected files that need to be committed:" | |
| echo "$FILES" | while IFS= read -r line; do echo " $line"; done | |
| echo "" | |
| echo "Mock skeletons are not up-to-date, you may have forgotten to run mockery before committing your changes." | |
| exit 1 | |
| fi | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 | |
| with: | |
| go-version-file: 'cfn-resources/go.mod' | |
| cache: false # see https://github.com/golangci/golangci-lint-action/issues/807 | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 | |
| with: | |
| version: v2.1.6 # Also update GOLANGCI_VERSION variable in Makefile when updating this version | |
| working-directory: cfn-resources | |
| - name: actionlint | |
| run: | | |
| make tools | |
| actionlint -verbose -color | |
| shell: bash | |
| check-copyright: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 | |
| with: | |
| go-version-file: 'cfn-resources/go.mod' | |
| - name: install tools | |
| run: make tools | |
| - name: check copyright | |
| run: ./.github/scripts/check-licenses.sh | |
| shell: bash | |
| dependency-review: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'pull_request' }} | |
| steps: | |
| - name: 'Checkout Repository' | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: 'Dependency Review' | |
| uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 | |
| shellcheck: | |
| name: shellcheck | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: Run ShellCheck | |
| uses: bewuethr/shellcheck-action@d01912909579c4b1a335828b8fca197fbb8e0aa4 | |
| cfn-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 'Checkout Repository' | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: 'Setup cfn-lint' | |
| uses: scottbrenner/cfn-lint-action@3ad6d2d941976dbf8764f8919a274a7ebed486da | |
| - name: 'Run cfn-lint' | |
| run: | | |
| shopt -s globstar # enable globbing | |
| cfn-lint --version | |
| - run: cfn-lint ./cfn-resources/**/*.yml | |
| - run: cfn-lint ./cfn-resources/**/*.yaml | |
| if: always() # run even if previous step fails to lint all files | |
| unit-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 | |
| with: | |
| go-version-file: 'cfn-resources/go.mod' | |
| - name: run-unit-test | |
| run: make unit-test |