Update GH action dependencies and linter config #1211
Workflow file for this run
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
# SPDX-FileCopyrightText: 2023 The Crossplane Authors <https://crossplane.io> | |
# | |
# SPDX-License-Identifier: CC0-1.0 | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
pull_request: {} | |
workflow_dispatch: {} | |
env: | |
# Common versions | |
GO_VERSION: "1.22" | |
GOLANGCI_VERSION: "v1.61.0" | |
DOCKER_BUILDX_VERSION: "v0.18.0" | |
# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run | |
# a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether | |
# credentials have been provided before trying to run steps that need them. | |
DOCKER_USR: ${{ secrets.DOCKER_USR }} | |
AWS_USR: ${{ secrets.AWS_USR }} | |
jobs: | |
detect-noop: | |
runs-on: ubuntu-latest | |
outputs: | |
noop: ${{ steps.noop.outputs.should_skip }} | |
steps: | |
- name: Detect No-op Changes | |
id: noop | |
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
paths_ignore: '["**.md", "**.png", "**.jpg"]' | |
do_not_skip: '["workflow_dispatch", "schedule", "push"]' | |
concurrent_skipping: false | |
lint: | |
runs-on: ubuntu-latest | |
needs: detect-noop | |
if: needs.detect-noop.outputs.noop != 'true' | |
steps: | |
- name: Cleanup Disk | |
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 | |
with: | |
large-packages: false | |
swap-storage: false | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
- name: Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Find the Go Build Cache | |
id: go | |
run: echo "cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT | |
- name: Find the Go Build Cache | |
id: gomod | |
run: echo "cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT | |
- name: Cache the Go Build Cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: ${{ steps.go.outputs.cache }} | |
key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-build-lint- | |
- name: Cache Go Dependencies | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: .work/pkg | |
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-pkg- | |
- name: Vendor Dependencies | |
run: make vendor vendor.check | |
# We could run 'make lint' to ensure our desired Go version, but we prefer | |
# this action because it leaves 'annotations' (i.e. it comments on PRs to | |
# point out linter violations). | |
- name: Lint | |
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3 | |
with: | |
version: ${{ env.GOLANGCI_VERSION }} | |
check-diff: | |
runs-on: ubuntu-latest | |
needs: detect-noop | |
if: needs.detect-noop.outputs.noop != 'true' | |
steps: | |
- name: Cleanup Disk | |
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 | |
with: | |
large-packages: false | |
swap-storage: false | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
- name: Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Find the Go Build Cache | |
id: go-cache-paths | |
run: | | |
echo "go-build=$(make go.cachedir)" >> $GITHUB_OUTPUT | |
echo "go-mod=$(make go.mod.cachedir)" >> $GITHUB_OUTPUT | |
- name: Cache the Go Build Cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-build }} | |
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-build-check-diff- | |
- name: Cache Go Dependencies | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-mod }} | |
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-pkg- | |
- name: Vendor Dependencies | |
run: make vendor vendor.check | |
- name: Check Diff | |
run: make check-diff | |
unit-tests: | |
runs-on: ubuntu-latest | |
needs: detect-noop | |
if: needs.detect-noop.outputs.noop != 'true' | |
steps: | |
- name: Cleanup Disk | |
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 | |
with: | |
large-packages: false | |
swap-storage: false | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
- name: Fetch History | |
run: git fetch --prune --unshallow | |
- name: Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Find the Go Build Cache | |
id: go-cache-paths | |
run: | | |
echo "go-build=$(make go.cachedir)" >> $GITHUB_OUTPUT | |
echo "go-mod=$(make go.mod.cachedir)" >> $GITHUB_OUTPUT | |
- name: Cache the Go Build Cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-build }} | |
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-build-unit-tests- | |
- name: Cache Go Dependencies | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.go-mod }} | |
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-pkg- | |
- name: Vendor Dependencies | |
run: make vendor vendor.check | |
- name: Run Unit Tests | |
run: make -j2 test | |
- name: Publish Unit Test Coverage | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3 | |
with: | |
flags: unittests | |
file: _output/tests/linux_amd64/coverage.txt |