CI #5560
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
merge_group: | |
push: | |
branches: | |
- main | |
- release-* | |
jobs: | |
test-unit: | |
runs-on: ubuntu-latest | |
container: | |
image: golang:1.22.4-bookworm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: /go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Run unit tests | |
run: make test-unit | |
- name: Remove generated code from report | |
run: | | |
grep -v .pb.go coverage.txt | grep -v zz_generated | grep -v service.connect.go > coverage.tmp | |
mv coverage.tmp coverage.txt | |
- name: Upload coverage reports | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
lint-ui: | |
runs-on: ubuntu-latest | |
container: | |
image: node:20.12.2 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm- | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
package_json_file: ui/package.json | |
- name: Install nodejs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "22.2.0" | |
cache: "pnpm" | |
cache-dependency-path: "**/pnpm-lock.yaml" | |
- name: Run linter | |
run: make lint-ui | |
lint-go: | |
runs-on: ubuntu-latest | |
container: | |
image: golang:1.22.4-bookworm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install linter | |
env: | |
GOLANGCI_LINT_VERSION: 1.57.2 | |
working-directory: /usr/local/bin | |
run: | | |
curl -sSfL https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz \ | |
| tar xvz golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint --strip-components=1 | |
- name: Configure Git | |
run: git config --global --add safe.directory '*' | |
- name: Run linter | |
env: | |
GO_LINT_ERROR_FORMAT: github-actions | |
run: make lint-go | |
lint-charts: | |
runs-on: ubuntu-latest | |
container: | |
image: golang:1.22.4-bookworm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install linter | |
run: | | |
cd /usr/local/bin | |
curl -sSfL https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz \ | |
| tar xvz linux-amd64/helm --strip-components=1 | |
- name: Run linter | |
run: make lint-charts | |
lint-proto: | |
runs-on: ubuntu-latest | |
container: | |
image: golang:1.22.4-bookworm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install linter | |
uses: bufbuild/buf-setup-action@v1 | |
with: | |
version: "1.20.0" | |
- name: Run linter | |
env: | |
BUF_LINT_ERROR_FORMAT: github-actions | |
run: make lint-proto | |
check-codegen: | |
runs-on: ubuntu-latest | |
container: | |
image: golang:1.22.4-bookworm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install tools | |
run: apt update && apt install unzip | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
package_json_file: ui/package.json | |
- name: Install nodejs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "22.2.0" | |
cache: "pnpm" | |
cache-dependency-path: "**/pnpm-lock.yaml" | |
- name: Install nodejs dependencies | |
run: pnpm install --dev | |
working-directory: ./ui | |
- uses: actions/cache@v4 | |
with: | |
path: /go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install buf | |
uses: bufbuild/buf-setup-action@v1.29.0-1 | |
with: | |
version: 1.26.1 | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v3 | |
with: | |
version: "25.3" | |
- name: Install codegen tools | |
run: | | |
go install k8s.io/code-generator/cmd/go-to-protobuf@v0.29.3 | |
go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo@v0.29.3 | |
go install golang.org/x/tools/cmd/goimports@v0.21.0 | |
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 | |
- name: Git stuff | |
# As of go 1.20, this seems to be necessary for invoking git commands | |
# within the container | |
run: git config --global --add safe.directory /__w/kargo/kargo | |
- name: Run Codegen | |
run: make codegen | |
- name: Check nothing has changed | |
run: git diff --exit-code -- . | |
build-image: | |
needs: [test-unit, lint-go, lint-charts, lint-proto, lint-ui, check-codegen] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-cli: | |
needs: [test-unit, lint-go, lint-charts, lint-proto, lint-ui, check-codegen] | |
runs-on: ubuntu-latest | |
container: | |
image: golang:1.22.4-bookworm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: /go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Build CLI | |
env: | |
GOFLAGS: -buildvcs=false | |
run: make build-cli |