Skip to content

Run Hermetic tests #1881

Run Hermetic tests

Run Hermetic tests #1881

Workflow file for this run

name: Run Hermetic tests
on:
pull_request:
branches: [ "main" ]
merge_group:
branches: [ "main" ]
schedule:
- cron: "0 0/8 * * *" # Every 8 hours
workflow_dispatch: # manually triggered
inputs:
test_selector:
type: string
description: Path regex passed to Jest to select which tests to run
required: true
default: correctness/fast
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
jobs:
generate-matrix:
name: Generate Matrix
runs-on: ubuntu-latest
outputs:
networks: ${{ steps.generate-matrix.outputs.networks }}
build_tag: ${{ steps.generate-matrix.outputs.build_tag }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Generate network matrix
id: generate-matrix
run: |
NETWORKS=$(ls networks | jq -R -s -c '. | gsub(".yaml"; "") | split("\n")[:-1]')
echo "Networks:"
echo ${NETWORKS}
echo "networks=${NETWORKS}" >> $GITHUB_OUTPUT
# Choose unique name for this build
BUILD_TAG="$(echo ${{ github.sha }} | head -c 8)-${{ github.run_id }}"
echo "Build tag:"
echo ${BUILD_TAG}
echo "build_tag=${BUILD_TAG}" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
publish-suite:
name: Publish Suite
runs-on: ubuntu-latest
needs: generate-matrix
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
- name: Build and Publish
run: make BUILD_TAG=${{ needs.generate-matrix.outputs.build_tag }} publish-suite
build-driver:
name: Build 'hermetic-driver' binary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
# The prefix cache key, this can be changed to start a new cache manually.
# default: "v0-rust"
prefix-key: v0
# Cache only the cargo registry
cache-targets: false
- uses: mozilla-actions/[email protected]
- name: Build Tester
run: make BUILD_PROFILE=release driver
- uses: actions/upload-artifact@master
with:
name: hermetic-driver
path: ./target/release/hermetic-driver
retention-days: 1
run-tests:
name: Test
runs-on: ubuntu-latest
environment: dev
needs:
- generate-matrix
- build-driver
- publish-suite
strategy:
fail-fast: false
matrix:
networks: ${{ fromJSON(needs.generate-matrix.outputs.networks) }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup GKE auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
-
name: Get GKE credentials
uses: 'google-github-actions/get-gke-credentials@v1'
with:
cluster_name: ${{ vars.GKE_CLUSTER }}
location: ${{ vars.GKE_ZONE }}
- uses: actions/download-artifact@master
with:
name: hermetic-driver
path: ./bin
-
name: Test ${{ matrix.networks }}
run: |
set -euxo pipefail
export BUILD_TAG=${{ needs.generate-matrix.outputs.build_tag }}
export TEST_NETWORK=./networks/${{ matrix.networks }}.yaml
chmod +x ./bin/hermetic-driver
# For scheduled events, "test_selector" will be null, so default to running all tests.
test_selector=${{ github.event.inputs.test_selector || 'correctness' }}
# For PR and merge group events, run only "fast" tests.
# Note it is not possible to override "test_selector" for these types of events.
if [[ ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }} == 'true' ]]; then
test_selector="correctness/fast"
fi
make TEST_SELECTOR="$test_selector" HERMETIC_CMD=./bin/hermetic-driver hermetic-tests
run-migration-tests:
name: Test Migrations
runs-on: ubuntu-latest
environment: dev
needs:
- build-driver
- publish-suite
- generate-matrix #Needed to know the BUILD_TAG
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup GKE auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
-
name: Get GKE credentials
uses: 'google-github-actions/get-gke-credentials@v1'
with:
cluster_name: ${{ vars.GKE_CLUSTER }}
location: ${{ vars.GKE_ZONE }}
- uses: actions/download-artifact@master
with:
name: hermetic-driver
path: ./bin
-
name: Test ${{ matrix.networks }}
run: |
set -euxo pipefail
export BUILD_TAG=${{ needs.generate-matrix.outputs.build_tag }}
chmod +x ./bin/hermetic-driver
make HERMETIC_CMD=./bin/hermetic-driver migration-tests
collect-results:
name: Hermetic Test Results
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [run-tests, run-migration-tests]
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}