|
| 1 | +# Produce a build of element-web with this version of react-sdk |
| 2 | +# and any matching branches of element-web and js-sdk, output it |
| 3 | +# as an artifact and run integration tests. |
| 4 | +name: Element Web - Build and Test |
| 5 | +on: |
| 6 | + pull_request: { } |
| 7 | + push: |
| 8 | + branches: [ develop, master ] |
| 9 | + repository_dispatch: |
| 10 | + types: [ upstream-sdk-notify ] |
| 11 | +env: |
| 12 | + # These must be set for fetchdep.sh to get the right branch |
| 13 | + REPOSITORY: ${{ github.repository }} |
| 14 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: "Build Element-Web" |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + |
| 22 | + - uses: actions/setup-node@v3 |
| 23 | + with: |
| 24 | + cache: 'yarn' |
| 25 | + |
| 26 | + - name: Fetch layered build |
| 27 | + id: layered_build |
| 28 | + run: | |
| 29 | + scripts/ci/layered.sh |
| 30 | + JSSDK_SHA=$(git -C matrix-js-sdk rev-parse --short=12 HEAD) |
| 31 | + REACT_SHA=$(git rev-parse --short=12 HEAD) |
| 32 | + VECTOR_SHA=$(git -C element-web rev-parse --short=12 HEAD) |
| 33 | + echo "::set-output name=VERSION::$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA" |
| 34 | +
|
| 35 | + - name: Copy config |
| 36 | + run: cp element.io/develop/config.json config.json |
| 37 | + working-directory: ./element-web |
| 38 | + |
| 39 | + - name: Build |
| 40 | + env: |
| 41 | + CI_PACKAGE: true |
| 42 | + VERSION: "${{ steps.layered_build.outputs.VERSION }}" |
| 43 | + run: yarn build |
| 44 | + working-directory: ./element-web |
| 45 | + |
| 46 | + - name: Upload Artifact |
| 47 | + uses: actions/upload-artifact@v2 |
| 48 | + with: |
| 49 | + name: previewbuild |
| 50 | + path: element-web/webapp |
| 51 | + # We'll only use this in a triggered job, then we're done with it |
| 52 | + retention-days: 1 |
| 53 | + |
| 54 | + cypress: |
| 55 | + name: "Cypress End to End Tests" |
| 56 | + needs: build |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v2 |
| 60 | + |
| 61 | + - name: Download build |
| 62 | + uses: actions/download-artifact@v3 |
| 63 | + with: |
| 64 | + name: previewbuild |
| 65 | + path: webapp |
| 66 | + |
| 67 | + - name: Run Cypress tests |
| 68 | + uses: cypress-io/github-action@v2 |
| 69 | + with: |
| 70 | + # The built-in Electron runner seems to grind to a halt trying |
| 71 | + # to run the tests, so use chrome. |
| 72 | + browser: chrome |
| 73 | + start: npx serve -p 8080 webapp |
| 74 | + record: true |
| 75 | + command-prefix: 'yarn percy exec --' |
| 76 | + env: |
| 77 | + # pass the Dashboard record key as an environment variable |
| 78 | + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} |
| 79 | + # pass the Percy token as an environment variable |
| 80 | + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} |
| 81 | + # Use existing chromium rather than downloading another |
| 82 | + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true |
| 83 | + PERCY_BROWSER_EXECUTABLE: /usr/bin/chromium-browser |
| 84 | + # pass GitHub token to allow accurately detecting a build vs a re-run build |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + |
| 87 | + - name: Upload Artifact |
| 88 | + if: failure() |
| 89 | + uses: actions/upload-artifact@v2 |
| 90 | + with: |
| 91 | + name: cypress-results |
| 92 | + path: | |
| 93 | + cypress/screenshots |
| 94 | + cypress/videos |
| 95 | + cypress/synapselogs |
| 96 | +
|
| 97 | + - name: Store benchmark result |
| 98 | + if: github.ref == 'refs/heads/develop' |
| 99 | + uses: matrix-org/github-action-benchmark@jsperfentry-1 |
| 100 | + with: |
| 101 | + name: Cypress measurements |
| 102 | + tool: 'jsperformanceentry' |
| 103 | + output-file-path: cypress/performance/measurements.json |
| 104 | + # The dashboard is available at https://matrix-org.github.io/matrix-react-sdk/cypress/bench/ |
| 105 | + benchmark-data-dir-path: cypress/bench |
| 106 | + fail-on-alert: false |
| 107 | + comment-on-alert: false |
| 108 | + github-token: ${{ secrets.DEPLOY_GH_PAGES }} |
| 109 | + auto-push: ${{ github.ref == 'refs/heads/develop' }} |
| 110 | + |
| 111 | + app-tests: |
| 112 | + name: Element Web Integration Tests |
| 113 | + runs-on: ubuntu-latest |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v2 |
| 116 | + |
| 117 | + - uses: actions/setup-node@v3 |
| 118 | + with: |
| 119 | + cache: 'yarn' |
| 120 | + |
| 121 | + - name: Run tests |
| 122 | + run: "./scripts/ci/app-tests.sh" |
0 commit comments