mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* Ensure connection state always explicitly states all keys, even if some are undefined. * changelog * Fix type * fix test types * Add support for E2E testing * Add CI job for e2e test * Ensure integration test only runs when regular tests complete * Add homerunner image * Disallow concurrent runs * Add concurrency to other expensive steps * changelog * Fix mq test * Cache rust deps * Drop only * Use a shared key
162 lines
4.6 KiB
YAML
162 lines
4.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
paths-ignore:
|
|
- changelog.d/**'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths-ignore:
|
|
- changelog.d/**'
|
|
|
|
workflow_dispatch:
|
|
merge_group:
|
|
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint-node:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: .node-version
|
|
- run: yarn --ignore-scripts
|
|
- run: yarn lint:js
|
|
|
|
lint-rust:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
components: rustfmt
|
|
- run: cargo fmt --all -- --check
|
|
- run: cargo clippy -- -Dwarnings
|
|
|
|
config:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: .node-version
|
|
- run: yarn # Need to build scripts to get rust bindings
|
|
- run: yarn --silent ts-node src/config/Defaults.ts --config | diff config.sample.yml -
|
|
|
|
metrics-docs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: .node-version
|
|
- run: yarn # Need to build scripts to get rust bindings
|
|
- run: yarn --silent ts-node ./scripts/build-metrics-docs.ts | diff docs/metrics.md -
|
|
|
|
test:
|
|
# Test on LTS-1
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
matrix:
|
|
node_version: [20, 21]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js ${{ matrix.node_version }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node_version }}
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
shared-key: rust-cache
|
|
- run: yarn
|
|
- run: yarn test:cover
|
|
|
|
build-homerunner:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
homerunnersha: ${{ steps.gitsha.outputs.sha }}
|
|
steps:
|
|
- name: Checkout matrix-org/complement
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: matrix-org/complement
|
|
- name: Get complement git sha
|
|
id: gitsha
|
|
run: echo sha=`git rev-parse --short HEAD` >> "$GITHUB_OUTPUT"
|
|
- name: Cache homerunner
|
|
id: cached
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: homerunner
|
|
key: ${{ runner.os }}-homerunner-${{ steps.gitsha.outputs.sha }}
|
|
- name: "Set Go Version"
|
|
if: ${{ steps.cached.outputs.cache-hit != 'true' }}
|
|
run: |
|
|
echo "$GOROOT_1_18_X64/bin" >> $GITHUB_PATH
|
|
echo "~/go/bin" >> $GITHUB_PATH
|
|
# Build and install homerunner
|
|
- name: Install Complement Dependencies
|
|
if: ${{ steps.cached.outputs.cache-hit != 'true' }}
|
|
run: |
|
|
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
|
|
- name: Build homerunner
|
|
if: ${{ steps.cached.outputs.cache-hit != 'true' }}
|
|
run: |
|
|
go build ./cmd/homerunner
|
|
|
|
integration-test:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
needs:
|
|
- test
|
|
- build-homerunner
|
|
steps:
|
|
- name: Install Complement Dependencies
|
|
run: |
|
|
sudo apt-get update && sudo apt-get install -y libolm3
|
|
- name: Load cached homerunner bin
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: homerunner
|
|
key: ${{ runner.os }}-homerunner-${{ needs.build-synapse.outputs.homerunnersha }}
|
|
fail-on-cache-miss: true # Shouldn't happen, we build this in the needs step.
|
|
- name: Checkout matrix-hookshot
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: matrix-hookshot
|
|
# Setup node & run tests
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: matrix-hookshot/.node-version
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: matrix-hookshot
|
|
shared-key: rust-cache
|
|
- name: Run Homerunner tests
|
|
timeout-minutes: 10
|
|
env:
|
|
HOMERUNNER_SPAWN_HS_TIMEOUT_SECS: 100
|
|
HOMERUNNER_IMAGE: ghcr.io/element-hq/synapse/complement-synapse:latest
|
|
NODE_OPTIONS: --dns-result-order ipv4first
|
|
run: |
|
|
docker pull $HOMERUNNER_IMAGE
|
|
cd matrix-hookshot
|
|
yarn --strict-semver --frozen-lockfile
|
|
../homerunner &
|
|
bash -ic 'yarn test:e2e' |