2021-02-18 10:27:10 +00:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2023-05-15 07:06:15 +00:00
|
|
|
- release-*
|
2021-02-18 10:27:10 +00:00
|
|
|
pull_request: {}
|
|
|
|
|
|
|
|
env:
|
|
|
|
# Common versions
|
2023-10-24 20:18:13 +00:00
|
|
|
GOLANGCI_VERSION: 'v1.54.2'
|
2023-08-28 22:17:10 +00:00
|
|
|
KUBERNETES_VERSION: '1.28.x'
|
2021-12-17 11:23:57 +00:00
|
|
|
|
2021-09-28 16:55:16 +00:00
|
|
|
# Sonar
|
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
detect-noop:
|
2022-10-06 17:14:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-02-18 10:27:10 +00:00
|
|
|
outputs:
|
|
|
|
noop: ${{ steps.noop.outputs.should_skip }}
|
|
|
|
steps:
|
|
|
|
- name: Detect No-op Changes
|
|
|
|
id: noop
|
2023-10-23 20:22:57 +00:00
|
|
|
uses: fkirc/skip-duplicate-actions@v5.3.1
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
paths_ignore: '["**.md", "**.png", "**.jpg"]'
|
|
|
|
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
|
|
|
|
concurrent_skipping: false
|
|
|
|
|
|
|
|
lint:
|
2022-10-06 17:14:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-02-18 10:27:10 +00:00
|
|
|
needs: detect-noop
|
2023-09-21 21:29:11 +00:00
|
|
|
if: needs.detect-noop.outputs.noop != 'true' && github.ref != 'refs/heads/main'
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-11 10:23:07 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-02-18 10:27:10 +00:00
|
|
|
|
2021-06-25 23:56:42 +00:00
|
|
|
- name: Setup Go
|
2023-03-20 22:00:25 +00:00
|
|
|
uses: actions/setup-go@v4
|
2021-06-25 23:56:42 +00:00
|
|
|
with:
|
2022-09-15 15:17:52 +00:00
|
|
|
go-version-file: "go.mod"
|
2021-06-25 23:56:42 +00:00
|
|
|
|
2021-02-18 10:27:10 +00:00
|
|
|
- name: Find the Go Cache
|
|
|
|
id: go
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=build-cache::$(go env GOCACHE)"
|
|
|
|
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
|
|
|
|
|
|
|
- name: Cache the Go Build Cache
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.build-cache }}
|
2022-10-06 17:14:13 +00:00
|
|
|
key: ${{ runner.os }}-build-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Cache Go Dependencies
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.mod-cache }}
|
2022-10-06 17:14:13 +00:00
|
|
|
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Lint
|
2022-10-06 17:14:13 +00:00
|
|
|
uses: golangci/golangci-lint-action@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
version: ${{ env.GOLANGCI_VERSION }}
|
2021-03-06 22:57:02 +00:00
|
|
|
skip-pkg-cache: true
|
|
|
|
skip-build-cache: true
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
check-diff:
|
2022-10-06 17:14:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-02-18 10:27:10 +00:00
|
|
|
needs: detect-noop
|
2023-09-21 21:29:11 +00:00
|
|
|
if: needs.detect-noop.outputs.noop != 'true' && github.ref != 'refs/heads/main'
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-11 10:23:07 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-02-18 10:27:10 +00:00
|
|
|
|
2022-11-30 19:06:59 +00:00
|
|
|
- name: Configure Git
|
|
|
|
run: |
|
|
|
|
git config user.name "$GITHUB_ACTOR"
|
|
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
|
|
|
2021-02-18 10:27:10 +00:00
|
|
|
- name: Setup Go
|
2023-03-20 22:00:25 +00:00
|
|
|
uses: actions/setup-go@v4
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
2022-09-15 15:17:52 +00:00
|
|
|
go-version-file: "go.mod"
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Find the Go Cache
|
|
|
|
id: go
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=build-cache::$(go env GOCACHE)"
|
|
|
|
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
|
|
|
|
|
|
|
- name: Cache the Go Build Cache
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.build-cache }}
|
2022-10-06 17:14:13 +00:00
|
|
|
key: ${{ runner.os }}-build-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Cache Go Dependencies
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.mod-cache }}
|
2022-10-06 17:14:13 +00:00
|
|
|
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Check Diff
|
2021-10-23 13:33:01 +00:00
|
|
|
run: |
|
|
|
|
make check-diff
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
unit-tests:
|
2022-10-06 17:14:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-02-18 10:27:10 +00:00
|
|
|
needs: detect-noop
|
2023-09-21 21:29:11 +00:00
|
|
|
if: needs.detect-noop.outputs.noop != 'true' && github.ref != 'refs/heads/main'
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-11 10:23:07 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Fetch History
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Setup Go
|
2023-03-20 22:00:25 +00:00
|
|
|
uses: actions/setup-go@v4
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
2022-09-15 15:17:52 +00:00
|
|
|
go-version-file: "go.mod"
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Find the Go Cache
|
|
|
|
id: go
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=build-cache::$(go env GOCACHE)"
|
|
|
|
echo "::set-output name=mod-cache::$(go env GOMODCACHE)"
|
|
|
|
|
|
|
|
- name: Cache the Go Build Cache
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.build-cache }}
|
2022-10-06 17:14:13 +00:00
|
|
|
key: ${{ runner.os }}-build-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Cache Go Dependencies
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.go.outputs.mod-cache }}
|
2022-10-06 17:14:13 +00:00
|
|
|
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
2021-06-25 23:56:42 +00:00
|
|
|
- name: Cache envtest binaries
|
2022-03-28 08:07:03 +00:00
|
|
|
uses: actions/cache@v3
|
2021-02-18 10:27:10 +00:00
|
|
|
with:
|
2023-07-24 06:31:56 +00:00
|
|
|
path: bin/k8s
|
|
|
|
key: ${{ runner.os }}-envtest-${{env.KUBERNETES_VERSION}}
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Run Unit Tests
|
2021-06-25 23:56:42 +00:00
|
|
|
run: |
|
|
|
|
make test
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
publish-artifacts:
|
|
|
|
needs: detect-noop
|
|
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
2022-10-06 17:14:13 +00:00
|
|
|
uses: ./.github/workflows/publish.yml
|
2022-03-19 20:07:50 +00:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
2022-03-20 08:43:25 +00:00
|
|
|
contents: read
|
2022-10-06 17:14:13 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- dockerfile: "Dockerfile"
|
2022-11-23 20:25:19 +00:00
|
|
|
build-args: "CGO_ENABLED=0"
|
2023-08-24 10:26:25 +00:00
|
|
|
build-arch: "amd64 arm64 s390x"
|
|
|
|
build-platform: "linux/amd64,linux/arm64,linux/s390x"
|
2022-10-06 17:14:13 +00:00
|
|
|
tag-suffix: "" # distroless
|
|
|
|
- dockerfile: "Dockerfile.ubi"
|
2022-11-23 20:25:19 +00:00
|
|
|
build-args: "CGO_ENABLED=0"
|
|
|
|
build-arch: "amd64 arm64"
|
|
|
|
build-platform: "linux/amd64,linux/arm64"
|
2022-10-06 17:14:13 +00:00
|
|
|
tag-suffix: "-ubi"
|
2022-11-23 20:25:19 +00:00
|
|
|
- dockerfile: "Dockerfile.ubi"
|
2023-01-24 17:00:17 +00:00
|
|
|
build-args: "CGO_ENABLED=0 GOEXPERIMENT=boringcrypto"
|
2022-11-23 20:25:19 +00:00
|
|
|
build-arch: "amd64"
|
|
|
|
build-platform: "linux/amd64"
|
|
|
|
tag-suffix: "-ubi-boringssl"
|
2022-10-06 17:14:13 +00:00
|
|
|
with:
|
|
|
|
dockerfile: ${{ matrix.dockerfile }}
|
|
|
|
tag-suffix: ${{ matrix.tag-suffix }}
|
|
|
|
image-name: ghcr.io/${{ github.repository }}
|
2022-11-23 20:25:19 +00:00
|
|
|
build-platform: ${{ matrix.build-platform }}
|
|
|
|
build-args: ${{ matrix.build-args }}
|
|
|
|
build-arch: ${{ matrix.build-arch }}
|
|
|
|
ref: ${{ github.ref }}
|
2022-10-06 17:14:13 +00:00
|
|
|
secrets:
|
|
|
|
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
|
|
|
|
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
|
2022-03-19 20:07:50 +00:00
|
|
|
|