Move more stuff from BK to GHA (#8372)

This commit is contained in:
Michael Telatynski 2022-04-21 12:55:32 +01:00 committed by GitHub
parent dd880df6ae
commit 146bcdd6a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 336 additions and 210 deletions

View file

@ -21,3 +21,6 @@ insert_final_newline = true
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.{yml,yaml}]
indent_size = 2

View file

@ -3,47 +3,87 @@
# as an artifact and run integration tests. # as an artifact and run integration tests.
name: Element Web - Build and Test name: Element Web - Build and Test
on: on:
pull_request: pull_request: { }
push:
branches: [ develop, master ]
repository_dispatch:
types: [ upstream-sdk-notify ]
jobs: jobs:
build: build:
runs-on: ubuntu-latest name: "Build Element-Web"
env: runs-on: ubuntu-latest
# This must be set for fetchdep.sh to get the right branch env:
PR_NUMBER: ${{github.event.number}} # This must be set for fetchdep.sh to get the right branch
steps: PR_NUMBER: ${{github.event.number}}
- uses: actions/checkout@v2 steps:
- name: Build - uses: actions/checkout@v2
run: scripts/ci/layered.sh && cd element-web && cp element.io/develop/config.json config.json && CI_PACKAGE=true yarn build
- name: Upload Artifact - uses: actions/setup-node@v3
uses: actions/upload-artifact@v2 with:
with: cache: 'yarn'
name: previewbuild
path: element-web/webapp - name: Fetch layered build
# We'll only use this in a triggered job, then we're done with it run: scripts/ci/layered.sh
retention-days: 1
cypress: - name: Copy config
needs: build run: cp element.io/develop/config.json config.json
runs-on: ubuntu-latest working-directory: ./element-web
steps:
- uses: actions/checkout@v2 - name: Build
- name: Download build run: CI_PACKAGE=true yarn build
uses: actions/download-artifact@v3 working-directory: ./element-web
with:
name: previewbuild - name: Upload Artifact
path: webapp uses: actions/upload-artifact@v2
- name: Run Cypress tests with:
uses: cypress-io/github-action@v2 name: previewbuild
with: path: element-web/webapp
# The built in Electron runner seems to grind to a halt trying # We'll only use this in a triggered job, then we're done with it
# to run the tests, so use chrome. retention-days: 1
browser: chrome
start: npx serve -p 8080 webapp cypress:
- name: Upload Artifact name: "Cypress End to End Tests"
if: failure() needs: build
uses: actions/upload-artifact@v2 runs-on: ubuntu-latest
with: steps:
name: cypress-results - uses: actions/checkout@v2
path: |
cypress/screenshots - name: Download build
cypress/videos uses: actions/download-artifact@v3
cypress/synapselogs with:
name: previewbuild
path: webapp
- name: Run Cypress tests
uses: cypress-io/github-action@v2
with:
# The built in Electron runner seems to grind to a halt trying
# to run the tests, so use chrome.
browser: chrome
start: npx serve -p 8080 webapp
- name: Upload Artifact
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress-results
path: |
cypress/screenshots
cypress/videos
cypress/synapselogs
app-tests:
name: Element Web Integration Tests
runs-on: ubuntu-latest
env:
# This must be set for fetchdep.sh to get the right branch
PR_NUMBER: ${{github.event.number}}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Run tests
run: "./scripts/ci/app-tests.sh"

View file

@ -1,47 +1,58 @@
name: End-to-end Tests name: End-to-end Tests
on: on:
# These tests won't work for non-develop branches at the moment as they # These tests won't work for non-develop branches at the moment as they
# won't pull in the right versions of other repos, so they're only enabled # won't pull in the right versions of other repos, so they're only enabled
# on develop. # on develop.
push: push:
branches: [develop] branches: [ develop ]
pull_request: pull_request:
branches: [develop] branches: [ develop ]
repository_dispatch:
types: [ upstream-sdk-notify ]
jobs: jobs:
end-to-end: end-to-end:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
# This must be set for fetchdep.sh to get the right branch # This must be set for fetchdep.sh to get the right branch
PR_NUMBER: ${{github.event.number}} PR_NUMBER: ${{github.event.number}}
container: vectorim/element-web-ci-e2etests-env:latest container: vectorim/element-web-ci-e2etests-env:latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Prepare End-to-End tests
run: ./scripts/ci/prepare-end-to-end-tests.sh - uses: actions/setup-node@v3
- name: Run End-to-End tests with:
run: ./scripts/ci/run-end-to-end-tests.sh cache: 'yarn'
- name: Archive logs
uses: actions/upload-artifact@v2 - name: Prepare End-to-End tests
if: ${{ always() }} run: ./scripts/ci/prepare-end-to-end-tests.sh
with:
path: | - name: Run End-to-End tests
test/end-to-end-tests/logs/**/* run: ./scripts/ci/run-end-to-end-tests.sh
test/end-to-end-tests/synapse/installations/consent/homeserver.log
retention-days: 14 - name: Archive logs
- name: Download previous benchmark data uses: actions/upload-artifact@v2
uses: actions/cache@v1 if: ${{ always() }}
with: with:
path: ./cache path: |
key: ${{ runner.os }}-benchmark test/end-to-end-tests/logs/**/*
- name: Store benchmark result test/end-to-end-tests/synapse/installations/consent/homeserver.log
uses: matrix-org/github-action-benchmark@jsperfentry-1 retention-days: 14
with:
tool: 'jsperformanceentry' - name: Download previous benchmark data
output-file-path: test/end-to-end-tests/performance-entries.json uses: actions/cache@v1
fail-on-alert: false with:
comment-on-alert: false path: ./cache
# Only temporary to monitor where failures occur key: ${{ runner.os }}-benchmark
alert-comment-cc-users: '@gsouquet'
github-token: ${{ secrets.DEPLOY_GH_PAGES }} - name: Store benchmark result
auto-push: ${{ github.ref == 'refs/heads/develop' }} uses: matrix-org/github-action-benchmark@jsperfentry-1
with:
tool: 'jsperformanceentry'
output-file-path: test/end-to-end-tests/performance-entries.json
fail-on-alert: false
comment-on-alert: false
# Only temporary to monitor where failures occur
alert-comment-cc-users: '@gsouquet'
github-token: ${{ secrets.DEPLOY_GH_PAGES }}
auto-push: ${{ github.ref == 'refs/heads/develop' }}

View file

@ -2,76 +2,79 @@
# and uploading it to netlify # and uploading it to netlify
name: Upload Preview Build to Netlify name: Upload Preview Build to Netlify
on: on:
workflow_run: workflow_run:
workflows: ["Element Web - Build and Test"] workflows: [ "Element Web - Build and Test" ]
types: types:
- completed - completed
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: > if: >
${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
steps: steps:
- name: "🔍 Read PR number" - name: "🔍 Read PR number"
id: readctx id: readctx
# we need to find the PR number that corresponds to the branch, which we do by # we need to find the PR number that corresponds to the branch, which we do by
# searching the GH API # searching the GH API
# The workflow_run event includes a list of pull requests, but it doesn't get populated for # The workflow_run event includes a list of pull requests, but it doesn't get populated for
# forked PRs: https://docs.github.com/en/rest/reference/checks#create-a-check-run # forked PRs: https://docs.github.com/en/rest/reference/checks#create-a-check-run
run: | run: |
head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}' head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}'
echo "head branch: $head_branch" echo "head branch: $head_branch"
pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)"
pr_number=$(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | pr_number=$(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" |
jq -r '.[] | .number') jq -r '.[] | .number')
echo "PR number: $pr_number" echo "PR number: $pr_number"
echo "::set-output name=prnumber::$pr_number" echo "::set-output name=prnumber::$pr_number"
# There's a 'download artifact' action but it hasn't been updated for the
# workflow_run action (https://github.com/actions/download-artifact/issues/60)
# so instead we get this mess:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "previewbuild"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/previewbuild.zip', Buffer.from(download.data));
- name: Extract Artifacts
run: unzip -d webapp previewbuild.zip && rm previewbuild.zip
- name: Deploy to Netlify
id: netlify
uses: nwtgck/actions-netlify@v1.2
with:
publish-dir: webapp
deploy-message: "Deploy from GitHub Actions"
# These don't work because we're in workflow_run
enable-pull-request-comment: false
enable-commit-comment: false
alias: pr${{ steps.readctx.outputs.prnumber }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: Edit PR Description
uses: Beakyn/gha-comment-pull-request@2167a7aee24f9e61ce76a23039f322e49a990409
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
pull-request-number: ${{ steps.readctx.outputs.prnumber }}
description-message: |
Preview: ${{ steps.netlify.outputs.deploy-url }}
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.
# There's a 'download artifact' action but it hasn't been updated for the
# workflow_run action (https://github.com/actions/download-artifact/issues/60)
# so instead we get this mess:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "previewbuild"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/previewbuild.zip', Buffer.from(download.data));
- name: Extract Artifacts
run: unzip -d webapp previewbuild.zip && rm previewbuild.zip
- name: Deploy to Netlify
id: netlify
uses: nwtgck/actions-netlify@v1.2
with:
publish-dir: webapp
deploy-message: "Deploy from GitHub Actions"
# These don't work because we're in workflow_run
enable-pull-request-comment: false
enable-commit-comment: false
alias: pr${{ steps.readctx.outputs.prnumber }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
- name: Edit PR Description
uses: Beakyn/gha-comment-pull-request@2167a7aee24f9e61ce76a23039f322e49a990409
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
pull-request-number: ${{ steps.readctx.outputs.prnumber }}
description-message: |
Preview: ${{ steps.netlify.outputs.deploy-url }}
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.

View file

@ -1,15 +1,18 @@
name: Notify element-web name: Notify element-web
on: on:
push: push:
branches: [develop] branches: [ develop ]
repository_dispatch:
types: [ upstream-sdk-notify ]
jobs: jobs:
notify-element-web: notify-element-web:
runs-on: ubuntu-latest name: "Notify Element Web"
environment: develop runs-on: ubuntu-latest
steps: environment: develop
- name: Notify element-web repo that a new SDK build is on develop steps:
uses: peter-evans/repository-dispatch@v1 - name: Notify element-web repo that a new SDK build is on develop
with: uses: peter-evans/repository-dispatch@v1
token: ${{ secrets.ELEMENT_WEB_NOTIFY_TOKEN }} with:
repository: vector-im/element-web token: ${{ secrets.ELEMENT_BOT_TOKEN }}
event-type: element-web-notify repository: vector-im/element-web
event-type: element-web-notify

View file

@ -3,10 +3,10 @@ on:
pull_request_target: pull_request_target:
types: [ opened, edited, labeled ] types: [ opened, edited, labeled ]
jobs: jobs:
changelog: changelog:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Preview Changelog - name: Preview Changelog
uses: matrix-org/allchange@main uses: matrix-org/allchange@main
with: with:
ghToken: ${{ secrets.GITHUB_TOKEN }} ghToken: ${{ secrets.GITHUB_TOKEN }}

88
.github/workflows/static_analysis.yaml vendored Normal file
View file

@ -0,0 +1,88 @@
name: Static Analysis
on:
pull_request: { }
push:
branches: [ develop, master ]
repository_dispatch:
types: [ upstream-sdk-notify ]
jobs:
ts_lint:
name: "Typescript Syntax Check"
runs-on: ubuntu-latest
env:
# This must be set for fetchdep.sh to get the right branch
PR_NUMBER: ${{github.event.number}}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install Deps
run: "./scripts/ci/install-deps.sh --ignore-scripts"
- name: Typecheck
run: "yarn run lint:types"
- name: Switch js-sdk to release mode
run: |
scripts/ci/js-sdk-to-release.js
cd node_modules/matrix-js-sdk
yarn install
yarn run build:compile
yarn run build:types
- name: Typecheck (release mode)
run: "yarn run lint:types"
i18n_lint:
name: "i18n Diff Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'yarn'
# Does not need branch matching as only analyses this layer
- name: Install Deps
run: "yarn install"
- name: i18n Check
run: "yarn run diff-i18n"
js_lint:
name: "ESLint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'yarn'
# Does not need branch matching as only analyses this layer
- name: Install Deps
run: "yarn install"
- name: Run Linter
run: "yarn run lint:js"
style_lint:
name: "Style Lint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'yarn'
# Does not need branch matching as only analyses this layer
- name: Install Deps
run: "yarn install"
- name: Run Linter
run: "yarn run lint:style"

View file

@ -1,10 +1,13 @@
name: Test coverage name: Tests
on: on:
pull_request: {} pull_request: { }
push: push:
branches: [develop, main, master] branches: [ develop, master ]
repository_dispatch:
types: [ upstream-sdk-notify ]
jobs: jobs:
test-coverage: jest:
name: Jest with Codecov
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
# This must be set for fetchdep.sh to get the right branch # This must be set for fetchdep.sh to get the right branch
@ -19,13 +22,15 @@ jobs:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }} ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
- name: Yarn cache - name: Yarn cache
uses: c-hive/gha-yarn-cache@v2 uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install Deps - name: Install Deps
run: "./scripts/ci/install-deps.sh --ignore-scripts" run: "./scripts/ci/install-deps.sh --ignore-scripts"
- name: Run tests with coverage - name: Run tests with coverage
run: "yarn install && yarn coverage" run: "yarn coverage"
- name: Upload coverage - name: Upload coverage
uses: codecov/codecov-action@v2 uses: codecov/codecov-action@v2

View file

@ -1,27 +0,0 @@
name: Type Check
on:
pull_request:
branches: [develop]
jobs:
build:
runs-on: ubuntu-latest
env:
# This must be set for fetchdep.sh to get the right branch
PR_NUMBER: ${{github.event.number}}
steps:
- uses: actions/checkout@v2
- uses: c-hive/gha-yarn-cache@v2
- name: Install Deps
run: "./scripts/ci/install-deps.sh --ignore-scripts"
- name: Typecheck
run: "yarn run lint:types"
- name: Switch js-sdk to release mode
run: |
scripts/ci/js-sdk-to-release.js
cd node_modules/matrix-js-sdk
yarn install
yarn run build:compile
yarn run build:types
- name: Typecheck (release mode)
run: "yarn run lint:types"