Skip to content
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

chore(e2e): Package and publish e2e docker image #6384

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .evergreen/buildvariants-and-tasks.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ buildvariants:
- name: e2e-coverage-<%= group.number %>
<% } %>

- name: publish-e2e-tests
display_name: Publish E2E Tests Docker Image
run_on: ubuntu2004-large
tasks:
- name: publish-e2e-tests

- name: csfle-tests
display_name: CSFLE Tests
run_on: ubuntu2004-large
Expand Down Expand Up @@ -528,3 +534,9 @@ for (const compassDistribution of COMPASS_DISTRIBUTIONS) {
- func: create_static_analysis_report
vars:
first_party_dependency_filenames: <%= firstPartyDepsFilenames.map(f => '.sbom/' + f).join(',') %>

- name: publish-e2e-tests
tags: ['run-on-pr']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove this before merging, turned it on for now just to test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do a "dry run" to confirm that it's working on PRs?

commands:
- func: clone
- func: package-and-publish-e2e-docker-image
11 changes: 11 additions & 0 deletions .evergreen/buildvariants-and-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ buildvariants:
- name: e2e-coverage-1
- name: e2e-coverage-2
- name: e2e-coverage-3
- name: publish-e2e-tests
display_name: Publish E2E Tests Docker Image
run_on: ubuntu2004-large
tasks:
- name: publish-e2e-tests
- name: csfle-tests
display_name: CSFLE Tests
run_on: ubuntu2004-large
Expand Down Expand Up @@ -1774,3 +1779,9 @@ tasks:
vars:
first_party_dependency_filenames: >-
.sbom/first-party-deps-compass-package-ubuntu.json,.sbom/first-party-deps-compass-package-windows.json,.sbom/first-party-deps-compass-package-rhel.json,.sbom/first-party-deps-compass-package-macos-x64.json,.sbom/first-party-deps-compass-package-macos-arm.json,.sbom/first-party-deps-compass-isolated-package-ubuntu.json,.sbom/first-party-deps-compass-isolated-package-windows.json,.sbom/first-party-deps-compass-isolated-package-rhel.json,.sbom/first-party-deps-compass-isolated-package-macos-x64.json,.sbom/first-party-deps-compass-isolated-package-macos-arm.json,.sbom/first-party-deps-compass-readonly-package-ubuntu.json,.sbom/first-party-deps-compass-readonly-package-windows.json,.sbom/first-party-deps-compass-readonly-package-rhel.json,.sbom/first-party-deps-compass-readonly-package-macos-x64.json,.sbom/first-party-deps-compass-readonly-package-macos-arm.json
- name: publish-e2e-tests
tags:
- run-on-pr
commands:
- func: clone
- func: package-and-publish-e2e-docker-image
11 changes: 11 additions & 0 deletions .evergreen/e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# "bullseye" is the debian distribution that ubuntu:20.04 is based on
ARG NODE_JS_VERSION=20
FROM node:${NODE_JS_VERSION}-bullseye

COPY . /compass-monorepo-root
WORKDIR /compass-monorepo-root

RUN npm i -g [email protected]
RUN npm run bootstrap-ci

CMD ["npm run test-web"]
35 changes: 35 additions & 0 deletions .evergreen/e2e-tests/package-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

post_evergreen_status() {
status="$1"
type="$2"
desc="$3"
should_continue="$4"
curl --silent --show-error --header "Content-Type: application/json" --data \
'{"status": "'"$status"'", "type": "'"$type"'", "desc": "'"$desc"'", "should_continue": '"$should_continue"'}' \
"http://localhost:2285/task_status" || true
}

# NOTE: do not -x here there are "env" vars in the commands
set -e

MONOREPO_ROOT_DIR="$(cd $(dirname "$0")/../..; pwd)"
cd $MONOREPO_ROOT_DIR

echo "building e2e tests image from ${PWD}"
docker build -t compass-e2e-tests:$github_commit --build-arg "NODE_JS_VERSION=$NODE_JS_VERSION" -f "./.evergreen/package-and-publish-e2e-docker-image/Dockerfile" .
echo "e2e tests image built"

# skip if the image already exists
if aws ecr describe-images --region $ECR_REGION --repository-name=compass/e2e-tests --image-ids=imageTag=$github_commit; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked in the slack, but why are we using ecr and not artifactory?

echo "Image with tag '${github_commit}' found in the 'compass/e2e-tests' repository. Setting task status to 'success'..."
post_evergreen_status success test "image tag '${github_commit}' already exists in the 'compass/e2e-tests' repository" false
else
echo "Image with tag '${github_commit}' not found in the 'compass/e2e-tests' repository. Continuing with remainder of task..."
fi

echo "pushing e2e tests image to ECR"
aws ecr get-login-password --region $ECR_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
docker tag compass-e2e-tests:$github_commit $ECR_REGISTRY/compass/e2e-tests:$github_commit
docker push $ECR_REGISTRY/compass/e2e-tests:$github_commit
echo "image pushed"
14 changes: 14 additions & 0 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@ post:
params:
file: src/.logs/*.xml
functions:
package-and-publish-e2e-docker-image:
command: shell.exec
params:
shell: bash
env:
<<: *compass-env
AWS_ACCESS_KEY_ID: ${aws_key}
AWS_SECRET_ACCESS_KEY: ${aws_secret}
ECR_REGISTRY: ${ecr_registry}
include_expansions_in_env: [github_commit, ECR_REGION]
script: |
set -e
bash .evergreen/e2e-tests/package-and-publish-docker-image.sh

clone:
- command: git.get_project
type: system
Expand Down
Loading