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

(test) O3-2525: Add new GH workflow to run E2E on release PRs #754

Merged
merged 9 commits into from
Oct 27, 2023
Merged
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
349 changes: 349 additions & 0 deletions .github/workflows/e2e-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
name: Run E2E Tests on Release PRs

on:
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.pull_request.title, '(release)') }}
outputs:
patient_management_version: ${{steps.versions.outputs.patient_management}}
patient_chart_version: ${{steps.versions.outputs.patient_chart}}
esm_core_version: ${{steps.versions.outputs.esm_core}}
form_builder_version: ${{steps.versions.outputs.form_builder}}
cohort_builder_version: ${{steps.versions.outputs.cohort_builder}}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
jayasanka-sack marked this conversation as resolved.
Show resolved Hide resolved

- name: Checkout to the release commit
run: git checkout 'HEAD^{/\(release\)}'

- name: Extract version numbers from the spa-build-config.json file
id: versions
run: sh e2e_test_support_files/extract_tag_numbers.sh

- name: Build and Run Containers
run: docker-compose -f e2e_test_support_files/docker-compose-build.yml up -d

- name: Wait for the backend to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost/openmrs/login.htm)" != "200" ]]; do sleep 10; done

- name: Commit and export Containers
run: sh e2e_test_support_files/commit_and_export_images.sh

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: e2e_release_env_images
path: e2e_release_env_images.tar.gz
retention-days: 1
Comment on lines +39 to +44
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably add a "finally" job that just removes the artifact. That's better hygiene, I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Deleting artifact seems tricky. While there are marketplace options available for the same, they are used by only a few users.


run-patient-management-e2e-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Create Temporary Directory to Download Docker Images
id: tempdir
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"

- name: Download Docker Images
uses: actions/download-artifact@v3
with:
name: e2e_release_env_images
path: ${{ steps.tempdir.outputs.tmpdir }}

- name: Load Docker Images
run: |
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
docker image ls -a

- name: Spin up an OpenMRS Instance
run: docker-compose up -d
working-directory: e2e_test_support_files

- name: Checkout to the Repo's Tag
uses: actions/checkout@v4
with:
repository: openmrs/openmrs-esm-patient-management
ref: refs/tags/v${{ needs.build.outputs.patient_management_version }}
path: e2e_repo

- name: Copy test environment variables
run: cp example.env .env
working-directory: e2e_repo

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo

- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
working-directory: e2e_repo

- name: Wait for the OpenMRS instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done

- name: Run E2E tests
run: yarn playwright test
working-directory: e2e_repo

- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: report-patient-management
path: e2e_repo/playwright-report/
retention-days: 30

run-patient-chart-e2e-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Create Temporary Directory to Download Docker Images
id: tempdir
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"

- name: Download Docker Images
uses: actions/download-artifact@v3
with:
name: e2e_release_env_images
path: ${{ steps.tempdir.outputs.tmpdir }}

- name: Load Docker Images
run: |
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
docker image ls -a

- name: Spin up an OpenMRS Instance
run: docker-compose up -d
working-directory: e2e_test_support_files

- name: Checkout to the Repo's Tag
uses: actions/checkout@v4
with:
repository: openmrs/openmrs-esm-patient-chart
ref: refs/tags/v${{ needs.build.outputs.patient_chart_version }}
path: e2e_repo

- name: Copy test environment variables
run: cp example.env .env
working-directory: e2e_repo

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo

- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
working-directory: e2e_repo

- name: Wait for the OpenMRS instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done

- name: Run E2E tests
run: yarn playwright test
working-directory: e2e_repo

- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: report-patient-chart
path: e2e_repo/playwright-report/
retention-days: 30

run-form-builder-e2e-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Create Temporary Directory to Download Docker Images
id: tempdir
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"

- name: Download Docker Images
uses: actions/download-artifact@v3
with:
name: e2e_release_env_images
path: ${{ steps.tempdir.outputs.tmpdir }}

- name: Load Docker Images
run: |
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
docker image ls -a

- name: Spin up an OpenMRS Instance
run: docker-compose up -d
working-directory: e2e_test_support_files

- name: Checkout to the Repo's Tag
uses: actions/checkout@v4
with:
repository: openmrs/openmrs-esm-form-builder
ref: refs/tags/v${{ needs.build.outputs.form_builder_version }}
path: e2e_repo

- name: Copy test environment variables
run: cp example.env .env
working-directory: e2e_repo

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo

- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
working-directory: e2e_repo

- name: Wait for the OpenMRS instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done

- name: Run E2E tests
run: yarn playwright test
working-directory: e2e_repo

- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: report-form-builder
path: e2e_repo/playwright-report/
retention-days: 30

run-esm-core-e2e-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Create Temporary Directory to Download Docker Images
id: tempdir
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"

- name: Download Docker Images
uses: actions/download-artifact@v3
with:
name: e2e_release_env_images
path: ${{ steps.tempdir.outputs.tmpdir }}

- name: Load Docker Images
run: |
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
docker image ls -a

- name: Spin up an OpenMRS Instance
run: docker-compose up -d
working-directory: e2e_test_support_files

- name: Checkout to the Repo's Tag
uses: actions/checkout@v4
with:
repository: openmrs/openmrs-esm-core
ref: refs/tags/v${{ needs.build.outputs.esm_core_version }}
path: e2e_repo

- name: Copy test environment variables
run: cp example.env .env
working-directory: e2e_repo

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo

- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
working-directory: e2e_repo

- name: Wait for the OpenMRS instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done

- name: Run E2E tests
run: yarn playwright test
working-directory: e2e_repo

- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: report-esm-core
path: e2e_repo/playwright-report/
retention-days: 30

run-cohort-builder-e2e-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Create Temporary Directory to Download Docker Images
id: tempdir
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"

- name: Download Docker Images
uses: actions/download-artifact@v3
with:
name: e2e_release_env_images
path: ${{ steps.tempdir.outputs.tmpdir }}

- name: Load Docker Images
run: |
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
docker image ls -a

- name: Spin up an OpenMRS Instance
run: docker-compose up -d
working-directory: e2e_test_support_files

- name: Checkout to the Repo's Tag
uses: actions/checkout@v4
with:
repository: openmrs/openmrs-esm-cohortbuilder
ref: refs/tags/v${{ needs.build.outputs.cohort_builder_version }}
path: e2e_repo

- name: Copy test environment variables
run: cp example.env .env
working-directory: e2e_repo

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo

- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
working-directory: e2e_repo

- name: Wait for the OpenMRS instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done

- name: Run E2E tests
run: yarn playwright test
working-directory: e2e_repo

- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: report-cohort-builder
path: e2e_repo/playwright-report/
retention-days: 30
Loading
Loading