Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
GHA: make element-web and cypress workflows reusable (#10969)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
richvdh and t3chguy committed May 26, 2023
1 parent 6731374 commit 3bba816
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 26 additions & 3 deletions .github/workflows/element-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,14 +39,20 @@ 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:
cache: "yarn"

- 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)
Expand All @@ -44,17 +64,20 @@ 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
VERSION: "${{ steps.layered_build.outputs.VERSION }}"
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:
Expand Down

0 comments on commit 3bba816

Please sign in to comment.