228 lines
6.9 KiB
YAML
228 lines
6.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- release-*
|
|
pull_request: {}
|
|
workflow_dispatch: {}
|
|
|
|
env:
|
|
# Common versions
|
|
GO_VERSION: '1.23.1'
|
|
GOLANGCI_VERSION: 'v1.61.0'
|
|
|
|
jobs:
|
|
check-diff:
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Find the Go Build Cache
|
|
id: go
|
|
run: echo "::set-output name=cache::$(make go.cachedir)"
|
|
|
|
- name: Cache the Go Build Cache
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: ${{ steps.go.outputs.cache }}
|
|
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-build-check-diff-
|
|
|
|
- name: Cache Go Dependencies
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: .work/pkg
|
|
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-pkg-
|
|
|
|
- name: Download Go Modules
|
|
run: make modules.download modules.check
|
|
|
|
- name: Check Diff
|
|
run: make check-diff
|
|
|
|
detect-noop:
|
|
runs-on: ubuntu-22.04
|
|
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-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Find the Go Build Cache
|
|
id: go
|
|
run: echo "::set-output name=cache::$(make go.cachedir)"
|
|
|
|
- name: Cache the Go Build Cache
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: .work/pkg
|
|
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-pkg-
|
|
|
|
- name: Download Go Modules
|
|
run: make modules.download modules.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@aaa42aa0628b4ae2578232a66b541047968fac86 # v6
|
|
with:
|
|
version: ${{ env.GOLANGCI_VERSION }}
|
|
skip-cache: true # We do our own caching.
|
|
|
|
codeql:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Find the Go Build Cache
|
|
id: go
|
|
run: echo "::set-output name=cache::$(make go.cachedir)"
|
|
|
|
- name: Cache the Go Build Cache
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: ${{ steps.go.outputs.cache }}
|
|
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-build-check-diff-
|
|
|
|
- name: Cache Go Dependencies
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: .work/pkg
|
|
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-pkg-
|
|
|
|
- name: Download Go Modules
|
|
run: make modules.download modules.check
|
|
|
|
- name: Initialize CodeQL
|
|
uses: github/codeql-action/init@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3
|
|
with:
|
|
languages: go
|
|
|
|
- name: Perform CodeQL Analysis
|
|
uses: github/codeql-action/analyze@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3
|
|
|
|
trivy-scan-fs:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Run Trivy vulnerability scanner in fs mode
|
|
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
|
|
with:
|
|
scan-type: 'fs'
|
|
ignore-unfixed: true
|
|
skip-dirs: design
|
|
scan-ref: '.'
|
|
exit-code: '1'
|
|
severity: 'CRITICAL,HIGH'
|
|
|
|
unit-tests:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Fetch History
|
|
run: git fetch --prune --unshallow
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Find the Go Build Cache
|
|
id: go
|
|
run: echo "::set-output name=cache::$(make go.cachedir)"
|
|
|
|
- name: Cache the Go Build Cache
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: ${{ steps.go.outputs.cache }}
|
|
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-build-unit-tests-
|
|
|
|
- name: Cache Go Dependencies
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
|
|
with:
|
|
path: .work/pkg
|
|
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-pkg-
|
|
|
|
- name: Download Go Modules
|
|
run: make modules.download modules.check
|
|
|
|
- name: Run Unit Tests
|
|
run: make -j2 test
|
|
|
|
- name: Publish Unit Test Coverage
|
|
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
|
|
with:
|
|
flags: unittests
|
|
file: _output/tests/linux_amd64/coverage.txt
|