Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
217 changes: 217 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
name: ci

on: [pull_request] # yamllint disable-line rule:truthy

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull-request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
contents: read

jobs:
changes:
name: categorize changes
runs-on: ubuntu-latest
outputs:
non-docs: ${{ steps.detect.outputs.non-docs }}
yaml: ${{ steps.detect.outputs.yaml }}
steps:
- name: Get base depth
id: base-depth
env:
PR_COMMITS: ${{ github.event.pull_request.commits }}
run: echo "base-depth=$(expr "${PR_COMMITS}" + 1)" >> $GITHUB_OUTPUT
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ steps.base-depth.outputs.base-depth }}
persist-credentials: false
- name: detect
id: detect
env:
GITHUB_BASE_REF_NAME: ${{ github.base_ref }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
git fetch origin "${GITHUB_BASE_REF_NAME}"
CHANGED_FILES=$(git diff --name-only "${BASE_SHA}...${HEAD_SHA}" | tr ' ' '\n')

echo -e "Changed files:\n${CHANGED_FILES}"

if [[ -n "${CHANGED_FILES}" ]]; then
NON_DOCS='false'
YAML='false'

while read -r file; do
if [[ "$file" != *.md ]]; then
NON_DOCS='true'
break
fi
done <<< "${CHANGED_FILES}"

while read -r file; do
if [[ "$file" == *.yaml || "$file" == *.yml ]]; then
YAML='true'
break
fi
done <<< "${CHANGED_FILES}"

echo "non-docs=${NON_DOCS}" | tee -a $GITHUB_OUTPUT
echo "yaml=${YAML}" | tee -a $GITHUB_OUTPUT
fi

build:
name: build
runs-on: ubuntu-latest
needs: [changes]
if: ${{ needs.changes.outputs.non-docs == 'true' }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: build
run: |
go build -v ./...
linting:
name: lint
runs-on: ubuntu-latest
needs: [changes]
permissions:
contents: read
checks: write # Used by golangci-lint-action to annotate code in the PR
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: gofmt
if: ${{ needs.changes.outputs.non-docs == 'true' }}
run: |
gofmt_out=$(gofmt -d $(find * -name '*.go' ! -path 'vendor/*' ! -path 'third_party/*'))
if [[ -n "$gofmt_out" ]]; then
failed=1
fi
echo "$gofmt_out"
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
if: ${{ needs.changes.outputs.non-docs == 'true' }}
with:
version: v2.8.0
args: --new-from-merge-base=origin/${{ github.base_ref }} --timeout=10m
- name: yamllint
if: ${{ needs.changes.outputs.yaml == 'true' }}
run: |
sudo apt-get update && sudo apt-get install -y yamllint
make yamllint
- name: check-license
if: ${{ needs.changes.outputs.non-docs == 'true' }}
run: |
go install github.com/google/go-licenses@v1.0.0
go-licenses check ./...
tests:
needs: [build]
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: unit-test
run: |
make test-unit-verbose-and-race
generated:
needs: [build]
name: Check generated code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: generated
run: |
./hack/verify-codegen.sh
multi-arch-build:
needs: [build]
name: Multi-arch build
runs-on: ubuntu-latest
env:
KOCACHE: /tmp/ko-cache
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Cache ko build cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /tmp/ko-cache
key: ${{ runner.os }}-${{ runner.arch }}-ko-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-ko-
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
- name: ko-resolve
run: |
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -R -f config 1>/dev/null
KO_DOCKER_REPO=example.com ko resolve --platform=all --push=false -f config/interceptors 1>/dev/null
e2e-tests:
needs: [build]
uses: ./.github/workflows/e2e-matrix.yml

ci-summary:
name: CI summary
needs: [build, linting, tests, generated, multi-arch-build, e2e-tests]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check CI results
env:
BUILD: ${{ needs.build.result }}
LINTING: ${{ needs.linting.result }}
TESTS: ${{ needs.tests.result }}
GENERATED: ${{ needs.generated.result }}
MULTI_ARCH_BUILD: ${{ needs.multi-arch-build.result }}
E2E_TESTS: ${{ needs.e2e-tests.result }}
run: |
results=(
"build=${BUILD}"
"linting=${LINTING}"
"tests=${TESTS}"
"generated=${GENERATED}"
"multi-arch-build=${MULTI_ARCH_BUILD}"
"e2e-tests=${E2E_TESTS}"
)
failed=0
for r in "${results[@]}"; do
name="${r%%=*}"
result="${r#*=}"
echo "${name}: ${result}"
if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
failed=1
fi
done
if [ "$failed" -eq 1 ]; then
echo ""
echo "Some CI jobs failed or were cancelled"
exit 1
fi
echo ""
echo "All CI checks passed"
70 changes: 70 additions & 0 deletions .github/workflows/e2e-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Triggers Integration

on: [workflow_call]

defaults:
run:
shell: bash

permissions:
contents: read

jobs:
e2e-tests:
concurrency:
group: ${{ github.workflow }}-e2e-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: e2e tests
runs-on: ubuntu-latest
env:
KO_DOCKER_REPO: registry.local:5000/tekton
CLUSTER_DOMAIN: c${{ github.run_id }}.local
ARTIFACTS: ${{ github.workspace }}/artifacts
KOCACHE: /tmp/ko-cache

steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Cache ko build cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /tmp/ko-cache
key: ${{ runner.os }}-${{ runner.arch }}-ko-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-ko-
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9

- name: Install Dependencies
working-directory: ./
run: |
echo '::group:: install go-junit-report'
go install github.com/jstemmer/go-junit-report@v0.9.1
echo '::endgroup::'

echo '::group::create required folders'
mkdir -p "${ARTIFACTS}"
echo '::endgroup::'

echo "${GOPATH}/bin" >> "$GITHUB_PATH"

- name: Run Integration tests
env:
GOTOOLCHAIN: auto
run: |
./test/setup-kind.sh \
--registry-url $(echo ${KO_DOCKER_REPO} | cut -d'/' -f 1) \
--cluster-suffix "${CLUSTER_DOMAIN}" \
--nodes 3 \
--k8s-version v1.29.x \
--e2e-script ./test/gh-e2e-tests.sh \
--e2e-env ./test/e2e-tests-kind-prow.env

- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ failure() }}
with:
path: ${{ env.ARTIFACTS }}
23 changes: 13 additions & 10 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: "1.24"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.1.6
only-new-issues: true
args: --timeout=10m
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.7.2
only-new-issues: true
args: --timeout=10m
Loading
Loading