Skip to content

Add External Events #4312

Add External Events

Add External Events #4312

Workflow file for this run

name: Test
on:
pull_request:
branches:
- develop
- dev-[0-9]+.[0-9]+.[0-9]+
types:
# defaults + 'edited', to handle changes to flags like ___REQUIRES_AERIE_PR___ in the PR body
[opened, synchronize, reopened, edited]
push:
branches:
- develop
tags:
- v*
workflow_dispatch:
workflow_call:
inputs:
env:
description: 'Github Actions environment that the test workflow should run under'
type: string
required: false
env:
AERIE_PASSWORD: '${{secrets.AERIE_PASSWORD}}'
AERIE_USERNAME: '${{secrets.AERIE_USERNAME}}'
HASURA_GRAPHQL_ADMIN_SECRET: '${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}}'
HASURA_GRAPHQL_JWT_SECRET: '${{secrets.HASURA_GRAPHQL_JWT_SECRET}}'
POSTGRES_USER: '${{secrets.POSTGRES_USER}}'
POSTGRES_PASSWORD: '${{secrets.POSTGRES_PASSWORD}}'
GATEWAY_USERNAME: '${{secrets.GATEWAY_USERNAME}}'
GATEWAY_PASSWORD: '${{secrets.GATEWAY_PASSWORD}}'
MERLIN_USERNAME: '${{secrets.MERLIN_USERNAME}}'
MERLIN_PASSWORD: '${{secrets.MERLIN_PASSWORD}}'
SCHEDULER_USERNAME: '${{secrets.SCHEDULER_USERNAME}}'
SCHEDULER_PASSWORD: '${{secrets.SCHEDULER_PASSWORD}}'
SEQUENCING_USERNAME: '${{secrets.SEQUENCING_USERNAME}}'
SEQUENCING_PASSWORD: '${{secrets.SEQUENCING_PASSWORD}}'
PR_BODY: '${{github.event.pull_request.body}}'
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo (UI)
uses: actions/checkout@v4
- name: Setup Node (UI)
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm
- name: Install Dependencies (UI)
run: npm ci
- name: Build (UI)
run: npm run build
- name: Test (unit)
run: npm run test:unit:coverage
- name: Upload Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
**/unit-test-results
e2e-test:
runs-on: ubuntu-latest
environment: ${{ inputs.env || 'test-workflow' }}
steps:
- name: Checkout Repo (UI)
uses: actions/checkout@v4
- name: Setup Node (UI)
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm
- name: Extract Aerie backend docker tag from PR body
# look in the PR body for eg. the string ___REQUIRES_AERIE_PR___=9999, extract the number & save to env var
# if backend PR is labeled correctly, it will publish a docker tag called 'pr-9999' to use in tests
if: ${{ contains(env.PR_BODY, '___REQUIRES_AERIE_PR___=') }}
run: |
echo "AERIE_IMAGE_TAG=pr-$(echo $PR_BODY | sed -n 's/.*___REQUIRES_AERIE_PR___=\"\([0-9]\+\)\".*/\1/p')" >> $GITHUB_ENV
- name: Extract Aerie gateway docker tag from PR body
# look in the PR body for eg. the string ___REQUIRES_AERIE_PR___=9999, extract the number & save to env var
# if backend PR is labeled correctly, it will publish a docker tag called 'pr-9999' to use in tests
if: ${{ contains(env.PR_BODY, '___REQUIRES_GATEWAY_PR___=') }}
run: |
echo "GATEWAY_IMAGE_TAG=pr-$(echo $PR_BODY | sed -n 's/.*___REQUIRES_GATEWAY_PR___=\"\([0-9]\+\)\".*/\1/p')" >> $GITHUB_ENV
- name: Start Services (Aerie)
run: |
echo "AERIE_IMAGE_TAG: $AERIE_IMAGE_TAG"
echo "GATEWAY_IMAGE_TAG: $GATEWAY_IMAGE_TAG"
docker compose -f docker-compose-test.yml up -d --quiet-pull
docker images
docker ps -a --no-trunc
- name: Cache E2E Test Modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: aerie-ui-node-cache
with:
path: ~/.npm
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
${{ env.cache-name }}-
- name: Install Dependencies (UI)
run: npm ci
- name: Build (UI)
run: npm run build
- name: Install Playwright Dependencies (Test - e2e)
run: npx playwright install chromium --with-deps
- name: Test (e2e)
run: npm run test:e2e
- name: Upload Results
if: always()
uses: actions/upload-artifact@v4
with:
name: E2E Test Results
path: |
**/e2e-test-results
- name: Print Logs for Services (Aerie)
if: always()
run: docker compose -f docker-compose-test.yml logs -t
- name: Stop Services (Aerie)
if: always()
run: |
docker ps -a
docker compose -f docker-compose-test.yml down
docker ps -a
- name: Prune Volumes (Aerie)
if: always()
run: docker volume prune --force