Skip to content

ROX-27073: github action for multicluster test #31

ROX-27073: github action for multicluster test

ROX-27073: github action for multicluster test #31

name: Multicluster E2E tests
on:
push:
branches:
- main
paths-ignore:
- 'fleetshard/pkg/runtime/**'
- 'fleetshard/pkg/reconciler/**'
- '.github/workflows/multicluster-e2e.yaml'
- 'scripts/ci/**'
- 'scripts/lib/**'
- 'internal/pkg/handlers/admin_dinosaur.go'
- 'internal/dinosaur/pkg/services/dinosaur.go'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'fleetshard/pkg/runtime/**'
- 'fleetshard/pkg/reconciler/**'
- '.github/workflows/multicluster-e2e.yaml'
- 'scripts/ci/**'
- 'scripts/lib/**'
- 'internal/pkg/handlers/admin_dinosaur.go'
- 'internal/dinosaur/pkg/services/dinosaur.go'
jobs:
# create-cluster:
# name: "Create Test Infra Clusters"
# runs-on: ubuntu-latest
# if: ${{ !github.event.pull_request.head.repo.fork && !github.event.pull_request.draft }} # do not run for PRs from forks and drafts
# environment: development
# strategy:
# matrix:
# name: [acscs1, acscs2]
# steps:
# - name: Create cluster
# uses: stackrox/actions/infra/create-cluster@v1
# with:
# token: ${{ secrets.INFRA_TOKEN }}
# flavor: osd-on-aws
# name: ${{ matrix.name }}-${{ github.run_id }}${{ github.run_attempt }}
# lifespan: 3h
# args: nodes=3,machine-type=m5.2xlarge
# wait: true
e2e-test:
name: "Multicluster e2e tests"
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && !github.event.pull_request.draft }} # do not run for PRs from forks and drafts
# needs: [create-cluster]
environment: development
env:
INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }}
AWS_AUTH_HELPER: "none"
permissions:
id-token: write
contents: read
steps:
- name: Install infractl
uses: stackrox/actions/infra/install-infractl@v1
- name: Install oc
uses: redhat-actions/oc-installer@v1
- name: Check out code
uses: actions/checkout@v4
- name: Set cluster credentials
run: |
set -eo pipefail
mkdir kube
cluster1Conf="$(pwd)/kube/cluster1"
# url=$(infractl artifacts "acscs1-${{ github.run_id }}${{ github.run_attempt }}" --json | jq '.Artifacts[] | select(.Name=="kubeconfig") | .URL' -r)
url=$(infractl artifacts "acscs1-130285277621" --json | jq '.Artifacts[] | select(.Name=="kubeconfig") | .URL' -r)
wget -O "$cluster1Conf" "$url"
cluster2Conf="$(pwd)/kube/cluster2"
# url=$(infractl artifacts "acscs2-${{ github.run_id }}${{ github.run_attempt }}" --json | jq '.Artifacts[] | select(.Name=="kubeconfig") | .URL' -r)
url=$(infractl artifacts "acscs2-130285277621" --json | jq '.Artifacts[] | select(.Name=="kubeconfig") | .URL' -r)
wget -O "$cluster2Conf" "$url"
echo "CLUSTER_1_KUBECONFIG=$cluster1Conf" >> "$GITHUB_ENV"
echo "CLUSTER_2_KUBECONFIG=$cluster2Conf" >> "$GITHUB_ENV"
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github
- name: Docker login to registry.redhat.io
run: |
set -eo pipefail
export DOCKER_CONFIG=$HOME/.docker
KUBECONFIG=$CLUSTER_1_KUBECONFIG oc get secret/pull-secret -n openshift-config --template='{{index .data ".dockerconfigjson" | base64decode}}' > dockercfg
creds=$(jq '.auths."registry.redhat.io".auth' -r < dockercfg | base64 -d)
user=$(echo "$creds" | cut -d':' -f1)
pw=$(echo "$creds" | cut -d':' -f2)
docker login registry.redhat.io -u "$user" --password-stdin <<< "$pw"
- name: "Run"
run: "scripts/ci/multicluster_tests/entrypoint.sh"
# cleanup-clusters:
# name: "Cleanup Test Infra Clusters"
# runs-on: ubuntu-latest
# needs: [create-cluster]
# if: ${{ !github.event.pull_request.head.repo.fork && !github.event.pull_request.draft && always() }} # do not run for PRs from forks
# environment: development
# env:
# INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }}
# steps:
# - name: Install infractl
# uses: stackrox/actions/infra/install-infractl@v1
# - name: Delete test clusters
# run: |
# set -o pipefail
# infractl delete "acscs1-${{ github.run_id }}${{ github.run_attempt }}"
# infractl delete "acscs2-${{ github.run_id }}${{ github.run_attempt }}"
#  exit 0