Quick test for helm chart release (#35) #67
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: E2E Tests | |
on: | |
push: | |
branches: [ "main", "release-**" ] | |
pull_request: | |
branches: [ "main" ] | |
# This workflow runs e2e tests and relies on existance of EKS cluster with a `s3-csi-driver-sa` service account | |
# already deployed to it, which provides the driver with access to s3. | |
# | |
# Since we have a single cluster for e2e tests, we ensure that no more than one instance of this workflow is | |
# running by `concurrency: e2e-cluster` option. | |
# | |
# Succesfull workflows triggered by push to main will upload tested image to the private repository "PROMOTED_IMAGE_NAME": | |
# - uploaded images will be tagged with main branch commit number | |
# - uploaded images will be later promoted to public repository by "release" workflow | |
concurrency: e2e-cluster | |
env: | |
AWS_REGION : "us-east-1" | |
COMMIT_ID: ${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }} | |
TMP_IMAGE_NAME: "s3-csi-driver-tmp" | |
PROMOTED_IMAGE_NAME: "s3-csi-driver" | |
jobs: | |
build: | |
# this is to prevent the job to run at forked projects | |
if: github.repository == 'awslabs/mountpoint-s3-csi-driver' | |
strategy: | |
matrix: | |
cluster-type: ["kops", "eksctl"] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@master | |
with: | |
role-to-assume: arn:aws:iam::239424963615:role/S3CSIDriverE2ETestsRole | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push docker image to Amazon ECR Private Repository | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_NAME: ${{ env.TMP_IMAGE_NAME }} | |
run: | | |
BRANCH_OR_TAG=$(echo $GITHUB_REF | cut -d'/' -f3) | |
export PLATFORM=linux/amd64 | |
export TAG=${{ env.COMMIT_ID }} | |
make build_image | |
make push_image | |
- name: Install tools | |
run: | | |
export ACTION=install_tools | |
tests/e2e-kubernetes/run.sh | |
- name: Create cluster | |
run: | | |
export ACTION=create_cluster | |
export AWS_REGION=${{ env.AWS_REGION }} | |
export CLUSTER_TYPE=${{ matrix.cluster-type }} | |
tests/e2e-kubernetes/run.sh | |
- name: Install the driver | |
run: | | |
export ACTION=install_driver | |
export AWS_REGION=${{ env.AWS_REGION }} | |
export CLUSTER_TYPE=${{ matrix.cluster-type }} | |
export IMAGE_NAME=${{ env.TMP_IMAGE_NAME }} | |
export TAG=${{ env.COMMIT_ID }} | |
tests/e2e-kubernetes/run.sh | |
- name: Run E2E Tests | |
run: | | |
cd tests/e2e-kubernetes | |
export ACTION=run_tests | |
export AWS_REGION=${{ env.AWS_REGION }} | |
export CLUSTER_TYPE=${{ matrix.cluster-type }} | |
export TAG=${{ env.COMMIT_ID }} | |
./run.sh | |
- name: Uinstall the driver | |
if: always() | |
run: | | |
export ACTION=uninstall_driver | |
export AWS_REGION=${{ env.AWS_REGION }} | |
export CLUSTER_TYPE=${{ matrix.cluster-type }} | |
tests/e2e-kubernetes/run.sh | |
- name: Delete cluster | |
if: always() | |
run: | | |
export ACTION=delete_cluster | |
export AWS_REGION=${{ env.AWS_REGION }} | |
export CLUSTER_TYPE=${{ matrix.cluster-type }} | |
tests/e2e-kubernetes/run.sh | |
- name: Promote image for release branch | |
if: ${{ startsWith(github.ref_name, 'release') }} | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
run: | | |
export NEW_IMAGE_NAME=${REGISTRY}/${{ env.PROMOTED_IMAGE_NAME }}:${{ env.COMMIT_ID }} | |
docker tag ${REGISTRY}/${{ env.TMP_IMAGE_NAME }}:${{ env.COMMIT_ID }} ${NEW_IMAGE_NAME} | |
docker push ${NEW_IMAGE_NAME} |