Skip to content

Deploy & E2E, triggered by rikukissa to #2

Deploy & E2E, triggered by rikukissa to

Deploy & E2E, triggered by rikukissa to #2

name: Deploy & run E2E
run-name: Deploy & E2E, triggered by ${{ github.event.client_payload.actor || github.actor }} to ${{ github.event.inputs.environment }}
on:
repository_dispatch:
types: [run_e2e]
push:
branches:
- develop
workflow_dispatch:
inputs:
environment:
type: choice
description: Environment to deploy to
required: true
default: 'development'
options:
- development
core-image-tag:
description: Core DockerHub image tag
required: true
default: 'v1.4.1'
countryconfig-image-tag:
description: Your Country Config DockerHub image tag
required: true
default: 'v1.4.1'
concurrency:
group: ci-build
cancel-in-progress: false
jobs:
get-core-commit:
name: Resolve latest core tag
runs-on: ubuntu-latest
outputs:
latest_commit_sha: ${{ steps.get_latest_commit.outputs.commit_sha }}
steps:
- name: Checkout opencrvs-core repository
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
uses: actions/checkout@v3
with:
repository: 'opencrvs/opencrvs-core'
ref: 'develop'
- name: Get latest commit SHA
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
id: get_latest_commit
run: echo "::set-output name=commit_sha::$(git rev-parse HEAD | cut -c 1-7)"
get-country-config-commit:
name: Resolve latest Farajaland tag
runs-on: ubuntu-latest
needs: get-core-commit
outputs:
short_sha: ${{ steps.set_short_sha.outputs.short_sha }}
steps:
- name: Checkout code
uses: actions/checkout@v3
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
- name: Get short commit hash
id: set_short_sha
run: echo "::set-output name=short_sha::${GITHUB_SHA:0:7}"
if: github.event_name == 'push' || github.event_name == 'repository_dispatch'
deploy:
needs: [get-country-config-commit, get-core-commit]
uses: ./.github/workflows/deploy.yml
with:
environment: ${{ github.event.inputs.environment || 'development' }}
core-image-tag: ${{ github.event.inputs.core-image-tag || needs.get-core-commit.outputs.latest_commit_sha }}
countryconfig-image-tag: ${{ github.event.inputs.countryconfig-image-tag || needs.get-country-config-commit.outputs.short_sha }}
reset: 'true'
secrets: inherit
discover-tests:
name: Discover test directories
runs-on: ubuntu-22.04
outputs:
test_matrix: ${{ steps.list-tests.outputs.test_matrix }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: List Test Directories
id: list-tests
run: |
test_dirs=$(find ./e2e/testcases -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')
echo "Test directories: $test_dirs"
echo "test_matrix=$test_dirs" >> $GITHUB_OUTPUT
echo "test_matrix=$test_dirs"
test:
needs: [deploy, discover-tests]
runs-on: ubuntu-22.04
environment: ${{ github.event.inputs.environment || 'development' }}
strategy:
fail-fast: false
matrix:
test_dir: ${{ fromJson(needs.discover-tests.outputs.test_matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Check for Spec Files
id: check-specs
run: |
if ls ./e2e/testcases/${{ matrix.test_dir }}/*.spec.ts > /dev/null 2>&1; then
echo "::set-output name=has_spec_files::true"
else
echo "::set-output name=has_spec_files::false"
fi
- name: Install Dependencies
if: steps.check-specs.outputs.has_spec_files == 'true'
run: yarn
- name: Install Playwright Browsers
if: steps.check-specs.outputs.has_spec_files == 'true'
run: npx playwright install --with-deps
- name: Run Playwright Tests
if: steps.check-specs.outputs.has_spec_files == 'true'
run: npx playwright test ./e2e/testcases/${{ matrix.test_dir }}
env:
DOMAIN: '${{ vars.DOMAIN }}'
- uses: actions/upload-artifact@v4
if: steps.check-specs.outputs.has_spec_files == 'true'
with:
name: playwright-report-${{ matrix.test_dir }}
path: playwright-report/
retention-days: 30