Skip to content

Commit

Permalink
chore: configure continuous delivery workflows (#2254)
Browse files Browse the repository at this point in the history
There are 4 workflows:

verify PR (dhis2-verify-app.yml)
-- build, lint, test, e2e-prod

verify commit to dev (dhis2-verify-app.yml)
-- build, lint, test, e2e-prod, report-failure-to-slack

verify commit to master (dhis2-verify-app.yml)
-- build, lint, test, e2e-prod, release, report-failure-to-slack

nightly (nightly.yml)
-- e2e-dev, report-failure

In addition:

* e2e-prod and e2e-dev are reusable workflows and are called from dhis2-verify-app and nightly.
* removed uses: c-hive/gha-yarn-cache@v1 since it is deprecated and setup-node handles that work.
* updated action versions and node versions
* cypress test version tagging for features and bugs has been added (copied from line-list)
  • Loading branch information
jenniferarnesen authored and edoardo committed Oct 23, 2023
1 parent e01815f commit 24d6692
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 10 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/e2e-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: 'e2e-prod'

# Requirements:
#
# - Customize environment variables:
# BASE_URL_INSTANCES: Set the base url for the instances, e.g. https://test.e2e.dhis2.org
# NAME_PATTERN_PROD_INSTANCES: Set the name pattern for your instances. {version} will be replaced by "[majorVersion].[minorVersion]"
# NAME_PATTERN_DEV_INSTANCE: Set the name pattern for your dev instance. {version} will be replaced by "dev"
#
# - Other optional customizations:
# containers: Set the matrix containers array for the e2e-prod job. The number of parallel Cypress instances running for each backend version will equal the array length.
#
# - Set status check as required:
# We recommend setting "e2e-tests-success" as a required step in your workflow.

on:
workflow_call:
secrets:
baseurl:
required: true
username:
required: true
password:
required: true
recordkey:
required: true

env:
BASE_URL_INSTANCES: https://test.e2e.dhis2.org
NAME_PATTERN_PROD_INSTANCES: 'analytics-{version}'
NAME_PATTERN_DEV_INSTANCE: analytics-dev

concurrency:
group: e2e-prod-${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
compute-prod-versions:
if: "!github.event.push.repository.fork && (github.event.pull_request.draft == false || github.action == 'workflow_dispatch')"
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.prod-versions.outputs.versions }}
steps:
- name: Compute dev instance url
id: instance-url
run: |
url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_DEV_INSTANCE/"{version}"/dev}
echo "url=$url" >> $GITHUB_OUTPUT
echo "url: $url"
- uses: actions/checkout@v3

- name: Output prod version urls
id: prod-versions
uses: dhis2/action-supported-legacy-versions@v1
with:
instance-url-latest: ${{ steps.instance-url.outputs.url }} # can be removed if maxDHIS2Version has been specified
username: ${{ secrets.username }}
password: ${{ secrets.password }}

e2e-prod:
needs: compute-prod-versions
runs-on: ubuntu-latest
container:
image: cypress/browsers:node16.17.0-chrome106
options: --user 1001
strategy:
fail-fast: false
matrix:
versions: ${{ fromJSON(needs.compute-prod-versions.outputs.versions) }}
containers: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Compute prod instance url
id: instance-url
run: |
url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_PROD_INSTANCES/"{version}"/$version}
echo "url=$url" >> $GITHUB_OUTPUT
echo "url: $url"
env:
version: ${{ matrix.versions }}

- name: Run e2e tests
uses: cypress-io/github-action@v5
with:
start: yarn d2-app-scripts start
wait-on: 'http://localhost:3000'
wait-on-timeout: 300
record: true
parallel: true
browser: chrome
group: e2e-chrome-parallel-${{ matrix.versions }}
env:
CI: true
BROWSER: none
CYPRESS_RECORD_KEY: ${{ secrets.recordkey }}
CYPRESS_dhis2BaseUrl: ${{ steps.instance-url.outputs.url }}
CYPRESS_dhis2InstanceVersion: ${{matrix.versions}}
CYPRESS_dhis2Username: ${{ secrets.username }}
CYPRESS_dhis2Password: ${{ secrets.password }}
CYPRESS_networkMode: live
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

e2e-tests-success:
needs: e2e-prod
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- run: if [ $result != 'success' ]; then exit 1; fi;
env:
result: ${{ needs.e2e-prod.result }}
24 changes: 14 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,9 @@
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.0", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.9", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.5.tgz#8564dd588182ce0047d55d7a75e93921107b57ec"
integrity sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==
version "7.21.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673"
integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==
dependencies:
regenerator-runtime "^0.13.11"

Expand Down Expand Up @@ -8164,7 +8164,16 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5:
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==

get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0:
get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f"
integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==
dependencies:
function-bind "^1.1.1"
has "^1.0.3"
has-symbols "^1.0.3"

get-intrinsic@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82"
integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==
Expand Down Expand Up @@ -11284,16 +11293,11 @@ minimist-options@^3.0.1:
arrify "^1.0.1"
is-plain-obj "^1.1.0"

minimist@^1.1.0, minimist@^1.2.7, minimist@^1.2.8:
minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.7, minimist@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==

minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
version "1.2.7"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==

minipass@^2.6.0, minipass@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6"
Expand Down

0 comments on commit 24d6692

Please sign in to comment.