Skip to content

Commit

Permalink
chore : simplify workflow cypress build (#723)
Browse files Browse the repository at this point in the history
* Simple cypress build

* Try removing env vars to see if it breaks

* Try removing GITHIB_TOKEN to see if it breaks

* Remove both and see what happens

* Run on macos, the machine is beefier

* Only run on non-draft PRs

* Remove env, not needed

* Remove accidental change
  • Loading branch information
estellecomment authored Sep 26, 2023
1 parent 8062a72 commit d016b55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Build the application
name: Build
name: Build without E2E tests
on:
pull_request: {}
push:
Expand Down
39 changes: 15 additions & 24 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
# This is a tchap-specific file, inspired from the one in matrix-react-sdk
name: Cypress End to End Tests
name: Build + E2E Tests

# Run this job when the "Build" job completes
on:
workflow_run:
workflows: ["Build"]
types:
- completed
workflow_dispatch: # for running action manually

env:
# Removing this makes the job break.
REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
pull_request:
types: [ready_for_review]

jobs:
cypress:
name: Cypress
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -26,29 +18,29 @@ jobs:
id: node_version
run: echo ::set-output name=node_version::$(node -e 'console.log(require("./package.json").engines.node)')

- name: Yarn cache
- name: Setup node with yarn cache
uses: actions/setup-node@v3
with:
cache: "yarn"
node-version: ${{ steps.node_version.outputs.node_version }}

- name: Download build from artifact
# use this action instead of actions/download-artifact because we need the "workflow" param
uses: dawidd6/action-download-artifact@v2
with:
name: devbuild
path: webapp
run_id: ${{ github.event.workflow_run.id }} # I think this is the run_id of the workflow that triggered this workflow

- name: Install Dependencies
run: "yarn install" # this is needed otherwise "cypress: not found". Can we do just yarn install cypress to go faster ?
run: "yarn install"

- name: "Copy the dev config file at the right place"
run: "cp config.dev.json config.json"
# todo we could make the choice of backend configurable.
# But then the test user, password, server, should be changed too, see cypress env vars below.

- name: Build
run: "yarn build"

- name: Run Cypress tests
uses: cypress-io/[email protected]
with:
install: false # disable the default install, we already installed and built.

# Serve with 'npx serve', a simple static webserver, so that it starts quickly. The dev server is slow and messy to start.
# Serve with 'npx serve', a simple static webserver, so that it starts quickly. The webpack dev server is slow and messy to start.
start: "npx serve -p 8080 -L webapp"
# Note : 'wait-on' caused issues where localhost was not found by cypress. Be careful if you want to use it.

Expand All @@ -65,4 +57,3 @@ jobs:
E2E_TEST_USER_SECURITY_KEY: ${{ secrets.E2E_TEST_USER_SECURITY_KEY }}
E2E_TEST_USER_HOMESERVER_URL: "https://matrix.agent1.tchap.incubateur.net"
E2E_TEST_USER_HOMESERVER_SHORT: "agent1.tchap.incubateur.net"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # don't remember what this is for, can't hurt

0 comments on commit d016b55

Please sign in to comment.