Automatic Testing #188
Workflow file for this run
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
name: Automatic Testing | |
on: | |
workflow_dispatch: | |
jobs: | |
set_vars: | |
name: Set Auxiliary Variables | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
should_run: ${{ steps.set_should_run.outputs.should_run }} | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v3 | |
- name: Checking whether relevant files were changed | |
uses: dorny/[email protected] | |
id: changes | |
with: | |
filters: | | |
infra: | |
- '.github/workflows/test.yml' | |
- 'env.zip.gpg' | |
- 'Makefile' | |
- 'docker-compose.dev.yml' | |
- 'docker-compose.test.yml' | |
- 'Dockerfile-dev' | |
- 'bin/**' | |
app: | |
- 'frontend/**' | |
- 'middleware/**' | |
- 'reverse-proxy/**' | |
tests: | |
- 'frontend-e2e/**' | |
- name: Set `should_run` | |
id: set_should_run | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const refName = context.ref.split('/').slice(2).join('/') | |
core.info(`Detected ref: ${refName}`) | |
const event = context.eventName | |
core.info(`Detected event: ${event}`) | |
if (event === 'pull_request') { | |
const relevantFilesChanged = ${{ steps.changes.outputs.infra == 'true' || steps.changes.outputs.app == 'true' || steps.changes.outputs.tests == 'true' }} | |
core.info(`Relevant files changed: ${relevantFilesChanged}`) | |
if (relevantFilesChanged) { | |
core.info('PR event with relevant changes ➡️ running E2E tests 🧪') | |
core.setOutput('should_run', true) | |
} else { | |
core.info('PR event with irrelevant changes ➡️ no need for E2E tests 😴') | |
core.setOutput('should_run', false) | |
} | |
} else { | |
core.info('Not a PR event ➡️ running E2E tests 🧪') | |
core.setOutput('should_run', true) | |
} | |
e2e: | |
if: ${{ needs.set_vars.outputs.should_run == 'true' }} | |
needs: set_vars | |
name: End-to-end Tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v3 | |
- name: Create `env_passphrase` file for decryption of environment variables | |
run: echo -n ${{ secrets.ENV_PASSPHRASE }} > env_passphrase | |
- name: Build `docker-compose.dev.yml` with empty environment variables | |
run: | | |
touch .env.dev stemweb/.env.dev && \ | |
make build-dev | |
- name: Decrypt environment variables stored in `env.zip.gpg` | |
run: make decrypt-env | |
- name: Run the end-to-end tests | |
run: pwd && ls && make tests | |
- name: Upload test run videos | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cypress_videos | |
path: frontend-e2e/cypress/videos |