Skip to content

tekton: automate releases with Pipelines-as-Code #324

tekton: automate releases with Pipelines-as-Code

tekton: automate releases with Pipelines-as-Code #324

Workflow file for this run

name: ci
'on':
pull_request: {}
merge_group: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
permissions:
contents: read
checks: write # Used to annotate code in the PR
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Build binaries
run: |
go build -v ./...
unit-tests:
name: Unit Tests
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Run unit tests
run: |
go test -v -race ./pkg/... ./cmd/...
linting:
name: Linting
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Check Go formatting
run: |
gofmt_out=$(gofmt -d $(find * -name '*.go' ! -path 'vendor/*' ! -path 'third_party/*'))
if [[ -n "$gofmt_out" ]]; then
echo "$gofmt_out"
echo "ERROR: Go files are not formatted. Run 'go fmt ./...' to fix."
exit 1
fi
echo "All Go files are properly formatted."
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
only-new-issues: true
args: --timeout=10m
- name: YAML Lint
run: |
sudo apt-get update && sudo apt-get install -y yamllint
yamllint -c .yamllint config/ .github/workflows/
continue-on-error: false
check-licenses:
name: License Check
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Check licenses
run: |
go install github.com/google/go-licenses@v1.6.0
go-licenses check ./...
ko-resolve:
name: Ko Resolve (Multi-arch)
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
- name: Validate ko resolve for multi-arch
run: |
cat <<EOF > .ko.yaml
defaultBaseImage: cgr.dev/chainguard/static
EOF
# Test that ko can resolve the config for multiple architectures
KO_DOCKER_REPO=example.com ko resolve --platform=linux/amd64,linux/arm64 --push=false -R -f config 1>/dev/null
echo "Ko resolve succeeded for multi-arch build."
e2e-tests:
needs: [build]
uses: ./.github/workflows/kind-e2e.yaml
ci-summary:
name: CI summary
needs: [build, unit-tests, linting, check-licenses, ko-resolve, e2e-tests]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check CI results
run: |
results=(
"build=${{ needs.build.result }}"
"unit-tests=${{ needs.unit-tests.result }}"
"linting=${{ needs.linting.result }}"
"check-licenses=${{ needs.check-licenses.result }}"
"ko-resolve=${{ needs.ko-resolve.result }}"
"e2e-tests=${{ needs.e2e-tests.result }}"
)
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"