GHA: make element-web and cypress workflows reusable (#10969)
* GHA: make `element-web` workflow reusable ... so that we can call it from the js-sdk repo * GHA: make `cypress.yaml` a reusable workflow ... so that we can call it from js-sdk * GHA: give cypress.yaml a `rust-crypto` parameter * Update .github/workflows/cypress.yaml Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * remove workflow_dispatch --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
67313743fc
commit
3bba816b10
2 changed files with 56 additions and 4 deletions
31
.github/workflows/cypress.yaml
vendored
31
.github/workflows/cypress.yaml
vendored
|
@ -1,13 +1,33 @@
|
|||
# Triggers after the layered build has finished, taking the artifact and running cypress on it
|
||||
#
|
||||
# Also called by a workflow in matrix-js-sdk.
|
||||
#
|
||||
name: Cypress End to End Tests
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Element Web - Build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
# support calls from other workflows
|
||||
workflow_call:
|
||||
inputs:
|
||||
react-sdk-repository:
|
||||
type: string
|
||||
required: true
|
||||
description: "The name of the github repository to check out and build."
|
||||
rust-crypto:
|
||||
type: boolean
|
||||
required: false
|
||||
description: "Enable Rust cryptography for the cypress run."
|
||||
secrets:
|
||||
CYPRESS_RECORD_KEY:
|
||||
required: true
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event.workflow_run.event == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare
|
||||
|
@ -129,11 +149,20 @@ jobs:
|
|||
# XXX: We're checking out untrusted code in a secure context
|
||||
# We need to be careful to not trust anything this code outputs/may do
|
||||
#
|
||||
# Note that we check out from the default repository, which is (for this workflow) the
|
||||
# Note that (in the absence of a `react-sdk-repository` input),
|
||||
# we check out from the default repository, which is (for this workflow) the
|
||||
# *target* repository for the pull request.
|
||||
#
|
||||
ref: ${{ steps.sha.outputs.sha }}
|
||||
persist-credentials: false
|
||||
path: matrix-react-sdk
|
||||
repository: ${{ inputs.react-sdk-repository || github.repository }}
|
||||
|
||||
# Enable rust crypto if the calling workflow requests it
|
||||
- name: Enable rust crypto
|
||||
if: inputs.rust-crypto
|
||||
run: |
|
||||
echo "CYPRESS_RUST_CRYPTO=1" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Run Cypress tests
|
||||
uses: cypress-io/github-action@40a1a26c08d0e549e8516612ecebbd1ab5eeec8f
|
||||
|
|
29
.github/workflows/element-web.yaml
vendored
29
.github/workflows/element-web.yaml
vendored
|
@ -12,6 +12,20 @@ on:
|
|||
branches: [develop, master]
|
||||
repository_dispatch:
|
||||
types: [upstream-sdk-notify]
|
||||
|
||||
# support triggering from other workflows
|
||||
workflow_call:
|
||||
inputs:
|
||||
react-sdk-repository:
|
||||
type: string
|
||||
required: true
|
||||
description: "The name of the github repository to check out and build."
|
||||
|
||||
matrix-js-sdk-sha:
|
||||
type: string
|
||||
required: false
|
||||
description: "The Git SHA of matrix-js-sdk to build against. By default, will use a matching branch name if it exists, or develop."
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
|
||||
cancel-in-progress: true
|
||||
|
@ -25,7 +39,10 @@ jobs:
|
|||
name: "Build Element-Web"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ inputs.react-sdk-repository || github.repository }}
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
|
@ -33,6 +50,9 @@ jobs:
|
|||
|
||||
- name: Fetch layered build
|
||||
id: layered_build
|
||||
env:
|
||||
# tell layered.sh to check out the right sha of the JS-SDK, if we were given one
|
||||
JS_SDK_GITHUB_BASE_REF: ${{ inputs.matrix-js-sdk-sha }}
|
||||
run: |
|
||||
scripts/ci/layered.sh
|
||||
JSSDK_SHA=$(git -C matrix-js-sdk rev-parse --short=12 HEAD)
|
||||
|
@ -44,7 +64,6 @@ jobs:
|
|||
run: cp element.io/develop/config.json config.json
|
||||
working-directory: ./element-web
|
||||
|
||||
# After building we write the version file and the react-sdk sha so our cypress tests are from the same sha
|
||||
- name: Build
|
||||
env:
|
||||
CI_PACKAGE: true
|
||||
|
@ -52,9 +71,13 @@ jobs:
|
|||
run: |
|
||||
yarn build
|
||||
echo $VERSION > webapp/version
|
||||
echo $GITHUB_SHA > webapp/sha
|
||||
working-directory: ./element-web
|
||||
|
||||
# Record the react-sdk sha so our cypress tests are from the same sha
|
||||
- name: Record react-sdk SHA
|
||||
run: |
|
||||
git rev-parse HEAD > element-web/webapp/sha
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
|
Loading…
Reference in a new issue