-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update CI to use Github Environments #326
Open
muddyfish
wants to merge
9
commits into
main
Choose a base branch
from
feature/ci-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a0b3956
Initial commit to use environments for e2e tests
muddyfish e64d01a
Skip build if already uploaded
muddyfish 8746234
Make benchmark + kops state bucket configurable
muddyfish 2518677
Move secrets to variables as they're not secret
muddyfish 5a2d921
Add trusted/untrusted files for e2e
muddyfish 46a3a4d
Migrate release.yaml to use release environment
muddyfish 1b80958
Use registry from ECR login
muddyfish 22290ae
Don't run release on forks
muddyfish a77b225
Address PR feedback
muddyfish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "E2E Tests (Trusted)" | ||
|
||
on: | ||
push: | ||
branches: [ "main", "feature/**", "release-**", "workflow/**" ] | ||
merge_group: | ||
types: [ "checks_requested" ] | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
e2e: | ||
name: E2E Tests | ||
uses: ./.github/workflows/e2e-tests.yaml | ||
with: | ||
environment: "trusted" | ||
ref: ${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }} | ||
secrets: inherit |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "E2E Tests (Untrusted)" | ||
|
||
on: | ||
pull_request_target: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
e2e: | ||
name: E2E Tests | ||
uses: ./.github/workflows/e2e-tests.yaml | ||
with: | ||
environment: "untrusted" | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
secrets: inherit | ||
unexge marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,58 @@ | ||
name: E2E Tests | ||
|
||
on: | ||
push: | ||
branches: ["main", "release-**", "feature/*"] | ||
pull_request: | ||
branches: ["main", "feature/*"] | ||
paths: | ||
- "tests/**" | ||
- "pkg/**" | ||
- "cmd/**" | ||
- "charts/**" | ||
- ".github/workflows/**" | ||
- "Dockerfile" | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
ref: | ||
required: true | ||
type: string | ||
|
||
# This workflow runs e2e tests and relies on existence 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. | ||
# | ||
# Successful 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" | ||
BENCHMARK_RESULTS_BUCKET: "s3://mountpoint-s3-csi-driver-benchmark" | ||
BENCHMARK_RESULTS_REGION: "us-east-1" | ||
IMAGE_NAME: "s3-csi-driver" | ||
BENCHMARK_ARTIFACTS_FOLDER: ".github/artifacts" | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
KOPS_STATE_FILE: "s3://${{ vars.KOPS_STATE_FILE }}" | ||
BENCHMARK_BUCKET: "s3://${{ vars.BENCHMARK_BUCKET }}" | ||
TAG_UNTESTED: "untested_${{ inputs.ref }}" | ||
TAG_PASSED: "test_passed_${{ inputs.ref }}" | ||
jobs: | ||
build: | ||
# this is to prevent the job to run at forked projects | ||
if: github.repository == 'awslabs/mountpoint-s3-csi-driver' | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
persist-credentials: false | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "go.mod" | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@master | ||
with: | ||
role-to-assume: ${{ secrets.TEST_IAM_ROLE }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-to-assume: ${{ vars.IAM_ROLE }} | ||
aws-region: ${{ vars.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 }} | ||
PLATFORM: "linux/amd64,linux/arm64" | ||
TAG: "${{ env.TAG_UNTESTED }}" | ||
run: | | ||
export PLATFORM=linux/amd64,linux/arm64 | ||
export TAG=${{ env.COMMIT_ID }} | ||
make -j `nproc` all-push | ||
make -j `nproc` all-push-skip-if-present | ||
test: | ||
needs: build | ||
strategy: | ||
|
@@ -113,12 +99,23 @@ jobs: | |
- cluster-type: "kops" | ||
kubernetes-version: "1.31.0" | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
env: | ||
unexge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AWS_REGION: "${{ vars.AWS_REGION }}" | ||
CLUSTER_TYPE: "${{ matrix.cluster-type }}" | ||
ARCH: "${{ matrix.arch }}" | ||
AMI_FAMILY: "${{ matrix.family }}" | ||
K8S_VERSION: "${{ matrix.kubernetes-version }}" | ||
TAG: "untested_${{ inputs.ref }}" | ||
unexge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
persist-credentials: false | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
|
@@ -127,10 +124,10 @@ jobs: | |
with: | ||
python-version: "3.10" | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@master | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.TEST_IAM_ROLE }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-to-assume: ${{ vars.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
- name: Install tools | ||
run: | | ||
export ACTION=install_tools | ||
|
@@ -143,60 +140,36 @@ jobs: | |
export ENVTEST_K8S_VERSION="${K8S_VERSION%.*}" | ||
make e2e-controller | ||
- name: Create cluster | ||
env: | ||
ACTION: "create_cluster" | ||
run: | | ||
export ACTION=create_cluster | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Update kubeconfig | ||
env: | ||
ACTION: "update_kubeconfig" | ||
run: | | ||
export ACTION=update_kubeconfig | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Install the driver | ||
env: | ||
ACTION: "install_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 }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Run E2E Tests | ||
env: | ||
ACTION: "run_tests" | ||
run: | | ||
export ACTION=run_tests | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export TAG=${{ env.COMMIT_ID }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Run Performance Tests | ||
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86' | ||
env: | ||
ACTION: "run_perf" | ||
run: | | ||
export ACTION=run_perf | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export TAG=${{ env.COMMIT_ID }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Download previous benchmark results | ||
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86' | ||
run: | | ||
mkdir -p ${{ env.BENCHMARK_ARTIFACTS_FOLDER }} | ||
aws s3 cp --region ${{ env.BENCHMARK_RESULTS_REGION }} ${{ env.BENCHMARK_RESULTS_BUCKET }}/benchmark-data.json ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/benchmark-data.json || true | ||
aws s3 cp --region ${{ vars.BENCHMARK_RESULTS_REGION }} ${{ vars.BENCHMARK_BUCKET }}/benchmark-data.json ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/benchmark-data.json || true | ||
- name: Update benchmark result file | ||
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86' | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
|
@@ -211,59 +184,45 @@ jobs: | |
if: (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'bench') && matrix.cluster-type == 'kops' && matrix.arch == 'x86' | ||
run: | | ||
tests/e2e-kubernetes/scripts/format_benchmark_data.py ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/benchmark-data.json ${{ env.BENCHMARK_ARTIFACTS_FOLDER }}/quicksight-data.json | ||
aws s3 cp ${{ env.BENCHMARK_ARTIFACTS_FOLDER }} s3://mountpoint-s3-csi-driver-benchmark --recursive | ||
aws s3 cp ${{ env.BENCHMARK_ARTIFACTS_FOLDER }} ${{ env.BENCHMARK_BUCKET }} --recursive | ||
- name: Post e2e cleanup | ||
if: always() | ||
env: | ||
ACTION: "e2e_cleanup" | ||
run: | | ||
export ACTION=e2e_cleanup | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Uninstall the driver | ||
if: always() | ||
env: | ||
ACTION: "uninstall_driver" | ||
run: | | ||
export ACTION=uninstall_driver | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
- name: Delete cluster | ||
if: always() | ||
env: | ||
ACTION: "delete_cluster" | ||
run: | | ||
export ACTION=delete_cluster | ||
export AWS_REGION=${{ env.AWS_REGION }} | ||
export CLUSTER_TYPE=${{ matrix.cluster-type }} | ||
export ARCH=${{ matrix.arch }} | ||
export AMI_FAMILY=${{ matrix.family }} | ||
export K8S_VERSION=${{ matrix.kubernetes-version }} | ||
tests/e2e-kubernetes/scripts/run.sh | ||
promote: | ||
if: startsWith(github.ref_name, 'release') | ||
post_test: | ||
unexge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
needs: test | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: Set up crane | ||
uses: imjasonh/setup-[email protected] | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@master | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.TEST_IAM_ROLE }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-to-assume: ${{ vars.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
- name: Promote image for release branch | ||
- name: Mark tests as passed | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
REPOSITORY: "${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}" | ||
run: | | ||
export TMP_IMAGE_NAME=${REGISTRY}/${{ env.TMP_IMAGE_NAME }}:${{ env.COMMIT_ID }} | ||
export NEW_IMAGE_NAME=${REGISTRY}/${{ env.PROMOTED_IMAGE_NAME }}:${{ env.COMMIT_ID }} | ||
crane copy ${TMP_IMAGE_NAME} ${NEW_IMAGE_NAME} | ||
docker buildx imagetools create --tag ${REPOSITORY}:${TAG_PASSED} ${REPOSITORY}:${TAG_UNTESTED} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that was possible before but seems like we can also use merge queues now. That's great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely certain if this works, it was actually in the previous thing as well. I think merge queues are a thing we need to enable in the repository settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but this definition in the workflow ensures that the checks will run and then when we switch it on in repo settings, it will then allow the merge queue to run and read those workflows.