GKE-CI #934
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
# Copyright © 2021 - 2023 SUSE LLC | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: GKE-CI | |
on: | |
pull_request: | |
branches: [ main ] | |
types: [ ready_for_review ] | |
paths: | |
- 'acceptance/install/scenario1_test.go' | |
- '.github/workflows/gke.yml' | |
schedule: | |
- cron: '0 1 * * *' | |
workflow_dispatch: | |
inputs: | |
keep_cluster: | |
type: choice | |
description: "Keep the cluster afterwards?" | |
required: true | |
default: 'Delete' | |
options: | |
- Delete | |
- Keep | |
env: | |
SETUP_GO_VERSION: '1.20.4' | |
GOLANGCI_LINT_VERSION: v1.52 | |
GINKGO_NODES: 1 | |
FLAKE_ATTEMPTS: 1 | |
PUBLIC_CLOUD: 1 | |
KUBECONFIG: ${{ github.workspace }}/kubeconfig-epinio-ci | |
GKE_ZONE: ${{ secrets.GKE_ZONE }} | |
GKE_MACHINE_TYPE: 'n2-standard-4' | |
GKE_NETWORK: 'epinio-ci' | |
jobs: | |
linter: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
timeout-minutes: 5 | |
with: | |
cache: false | |
go-version: ${{ env.SETUP_GO_VERSION }} | |
- name: Cache Tools | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/tools | |
key: ${{ runner.os }}-tools | |
- name: Install Tools | |
run: make tools-install | |
- name: Add Tools to PATH | |
run: | | |
echo "`pwd`/output/bin" >> $GITHUB_PATH | |
- name: Lint Epinio | |
uses: golangci/golangci-lint-action@v3.7.0 | |
timeout-minutes: 10 | |
with: | |
version: ${{ env.GOLANGCI_LINT_VERSION }} | |
args: --timeout=10m --skip-files docs.go | |
skip-cache: true | |
acceptance-scenario1: | |
needs: | |
- linter | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
timeout-minutes: 5 | |
with: | |
cache: false | |
go-version: ${{ env.SETUP_GO_VERSION }} | |
# The system domain is managed by route53, we need credentials to update | |
# it to the loadbalancer's IP | |
- name: Configure AWS credentials for Route53 | |
uses: aws-actions/configure-aws-credentials@v4.0.0 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.EKS_REGION }} | |
- name: Setup Ginkgo Test Framework | |
run: go install github.com/onsi/ginkgo/v2/ginkgo@v2.11.0 | |
- name: Authenticate to GCP | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.EPCI_GCP_CREDENTIALS }}' | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Install gcloud kubectl version | |
run: gcloud components install kubectl | |
- name: Create GKE cluster | |
id: create-cluster | |
run: | | |
id=$RANDOM | |
echo "ID=$id" >> $GITHUB_OUTPUT | |
echo "RUN_ID: $id" | |
gcloud container clusters create epinioci$id \ | |
--disk-size 100 \ | |
--num-nodes=1 \ | |
--machine-type ${{ env.GKE_MACHINE_TYPE }} \ | |
--no-enable-cloud-logging \ | |
--no-enable-cloud-monitoring \ | |
--network ${{ env.GKE_NETWORK }} \ | |
--zone ${{ env.GKE_ZONE }} | |
- name: Get kubeconfig file from GKE | |
env: | |
# Prevents using deprecated auth method in generated kubeconfig | |
USE_GKE_GCLOUD_AUTH_PLUGIN: True | |
run: | | |
id=${{ steps.create-cluster.outputs.ID }} | |
gcloud container clusters get-credentials epinioci$id --zone ${{ env.GKE_ZONE }} --project ${{ secrets.EPCI_GKE_PROJECT }} | |
- name: Installation Acceptance Tests | |
env: | |
REGEX: Scenario1 | |
REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} | |
AWS_ZONE_ID: ${{ secrets.AWS_ZONE_ID }} | |
# Use a random host name, so we don't collide with our workflows on GKE | |
GKE_DOMAIN: id${{ steps.create-cluster.outputs.ID }}-${{ secrets.GKE_DOMAIN }} | |
EPINIO_SYSTEM_DOMAIN: id${{ steps.create-cluster.outputs.ID }}-${{ secrets.GKE_DOMAIN }} | |
EPINIO_TIMEOUT_MULTIPLIER: 3 | |
INGRESS_CONTROLLER: traefik | |
# EXTRAENV_NAME: SESSION_KEY | |
# EXTRAENV_VALUE: 12345 | |
run: | | |
echo "System Domain: $GKE_DOMAIN" | |
make test-acceptance-install | |
- name: Delete GKE cluster | |
# We always tear down the cluster, to avoid costs. Except when running | |
# manually and keep_cluster was set to "Keep" | |
if: ${{ always() && github.event.inputs.keep_cluster != 'Keep' }} | |
run: | | |
export RUN_ID=${{ steps.create-cluster.outputs.ID }} | |
export RUN_PCP="GKE" | |
export AWS_ZONE_ID=${{ secrets.AWS_ZONE_ID }} | |
export GKE_DOMAIN=${{ secrets.GKE_DOMAIN }} | |
export GKE_ZONE=${{ secrets.GKE_ZONE }} | |
export EPCI_GKE_PROJECT=${{ secrets.EPCI_GKE_PROJECT }} | |
export KUBECONFIG=${{ env.KUBECONFIG }} | |
go run acceptance/helpers/delete_clusters/delete_clusters.go |