KUBE-440: add e2e test for cluster-controller upgrade #808
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: Build | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go 1.22 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22.7' | |
- uses: azure/setup-kubectl@v4 | |
- uses: azure/[email protected] | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
version: '>= 363.0.0' | |
install_components: 'gke-gcloud-auth-plugin' | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-build- | |
- name: Get release tag | |
if: github.event_name == 'release' | |
run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Get version | |
run: echo "VERSION_TAG=$(git describe --tags)" >> $GITHUB_ENV | |
- name: Build Go binary amd64 | |
run: go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-$VERSION_TAG}" -o bin/castai-cluster-controller-amd64 . | |
env: | |
GOOS: linux | |
GOARCH: amd64 | |
CGO_ENABLED: 0 | |
- name: Build Go binary arm64 | |
run: go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-$VERSION_TAG}" -o bin/castai-cluster-controller-arm64 . | |
env: | |
GOOS: linux | |
GOARCH: arm64 | |
CGO_ENABLED: 0 | |
- name: Test | |
run: go test -short -race ./... | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Google Artifact Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: us-docker.pkg.dev | |
username: _json_key | |
password: ${{ secrets.ARTIFACT_BUILDER_JSON_KEY }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push pr | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: linux/arm64,linux/amd64 | |
push: ${{ github.event_name == 'pull_request' }} | |
tags: ghcr.io/castai/cluster-controller:${{ env.VERSION_TAG }} | |
- name: Build and push main | |
if: github.ref_name == 'main' && github.event_name == 'push' | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/arm64,linux/amd64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: us-docker.pkg.dev/castai-hub/library/cluster-controller:${{ env.VERSION_TAG }} | |
- name: Run e2e tests | |
if: ${{ github.event_name == 'pull_request' }} | |
#if: github.ref_name == 'main' && github.event_name == 'push' | |
env: | |
#CLUSTER_CONTROLLER_IMAGE_REPOSITORY: us-docker.pkg.dev/castai-hub/library/cluster-controller | |
CLUSTER_CONTROLLER_IMAGE_REPOSITORY: ghcr.io/castai/cluster-controller | |
CLUSTER_CONTROLLER_IMAGE_TAG: ${{ env.VERSION_TAG }} | |
CLUSTER_NAME: e2e-cluster-controller | |
CLUSTER_REGION: us-central1 | |
CASTAI_API_TOKEN: ${{ secrets.CASTAI_API_TOKEN }} | |
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }} | |
run: | | |
go test -v -p 1 ./e2e | |
- name: Build and push release | |
if: github.event_name == 'release' | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
platforms: linux/arm64,linux/amd64 | |
tags: | | |
us-docker.pkg.dev/castai-hub/library/cluster-controller:${{ env.RELEASE_TAG }} | |
us-docker.pkg.dev/castai-hub/library/cluster-controller:latest | |
- name: Docker pull for fossa main | |
if: github.event_name == 'release' | |
run: docker pull us-docker.pkg.dev/castai-hub/library/cluster-controller:${{ env.RELEASE_TAG }} | |
- name: FOSSA scan docker image | |
if: github.event_name == 'release' | |
continue-on-error: true | |
uses: fossas/fossa-action@v1 | |
with: | |
api-key: ${{ secrets.FOSSA_API_KEY }} | |
container: us-docker.pkg.dev/castai-hub/library/cluster-controller:${{ env.RELEASE_TAG }} |