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
|
2024-08-26 09:10:58 +00:00
|
|
|
GOLANGCI_VERSION: 'v1.60.1'
|
|
|
|
KUBERNETES_VERSION: '1.31.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
|
|
|
|
2024-01-18 20:03:07 +00:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2021-02-18 10:27:10 +00:00
|
|
|
jobs:
|
|
|
|
detect-noop:
|
2024-01-18 20:03:07 +00:00
|
|
|
permissions:
|
|
|
|
actions: write # for fkirc/skip-duplicate-actions to skip or stop workflow runs
|
|
|
|
contents: read # for fkirc/skip-duplicate-actions to read and compare commits
|
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
|
2024-01-18 20:03:07 +00:00
|
|
|
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # 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:
|
2024-01-18 20:03:07 +00:00
|
|
|
permissions:
|
|
|
|
contents: read # for actions/checkout to fetch code
|
|
|
|
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
|
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
|
2024-10-15 07:37:11 +00:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2021-02-18 10:27:10 +00:00
|
|
|
|
2021-06-25 23:56:42 +00:00
|
|
|
- name: Setup Go
|
2024-07-15 10:43:35 +00:00
|
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
|
2023-11-01 15:54:27 +00:00
|
|
|
id: setup-go
|
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
|
|
|
|
2023-11-01 15:54:27 +00:00
|
|
|
- name: Download Go modules
|
|
|
|
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
|
|
|
|
run: go mod download
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Lint
|
2024-10-08 08:07:16 +00:00
|
|
|
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
|
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
|
2024-10-15 07:37:11 +00:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Setup Go
|
2024-07-15 10:43:35 +00:00
|
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
|
2023-11-01 15:54:27 +00:00
|
|
|
id: setup-go
|
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
|
|
|
|
2023-11-01 15:54:27 +00:00
|
|
|
- name: Download Go modules
|
|
|
|
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
|
|
|
|
run: go mod download
|
2021-02-18 10:27:10 +00:00
|
|
|
|
2023-11-01 15:54:27 +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: 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
|
2024-02-17 09:49:56 +00:00
|
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-10-15 07:37:11 +00:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2021-02-18 10:27:10 +00:00
|
|
|
|
|
|
|
- name: Fetch History
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Setup Go
|
2024-07-15 10:43:35 +00:00
|
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
|
2023-11-01 15:54:27 +00:00
|
|
|
id: setup-go
|
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
|
|
|
|
2023-11-01 15:54:27 +00:00
|
|
|
- name: Download Go modules
|
|
|
|
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
|
|
|
|
run: go mod download
|
2021-02-18 10:27:10 +00:00
|
|
|
|
2021-06-25 23:56:42 +00:00
|
|
|
- name: Cache envtest binaries
|
2024-10-15 07:48:18 +00:00
|
|
|
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
|
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
|
|
|
|
2024-01-05 22:26:39 +00:00
|
|
|
- name: Publish Unit Test Coverage
|
2024-10-08 14:12:19 +00:00
|
|
|
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
|
2024-02-19 23:04:46 +00:00
|
|
|
env:
|
|
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
2024-01-05 22:26:39 +00:00
|
|
|
with:
|
|
|
|
flags: unittests
|
|
|
|
file: ./cover.out
|
|
|
|
|
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"
|
2024-05-21 11:41:39 +00:00
|
|
|
build-arch: "amd64 arm64 s390x ppc64le"
|
|
|
|
build-platform: "linux/amd64,linux/arm64,linux/s390x,linux/ppc64le"
|
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"
|
2024-05-21 11:41:39 +00:00
|
|
|
build-arch: "amd64 arm64 ppc64le"
|
|
|
|
build-platform: "linux/amd64,linux/arm64,linux/ppc64le"
|
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"
|
2024-05-21 11:41:39 +00:00
|
|
|
build-arch: "amd64 ppc64le"
|
|
|
|
build-platform: "linux/amd64,linux/ppc64le"
|
2022-11-23 20:25:19 +00:00
|
|
|
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
|
|
|
|