Merge pull request #27 from matrix-org/kegan/js-only-latest-main #231
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: [ 'main' ] | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
check-signoff: | |
if: "github.event_name == 'pull_request'" | |
uses: "matrix-org/backend-meta/.github/workflows/sign-off.yml@v2" | |
js-latest-main: | |
name: Tests (JS only, latest main) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # Checkout crypto tests | |
- name: Setup | Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
cache-dependency-path: "internal/api/js/js-sdk/yarn.lock" | |
- name: Setup | Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Setup | Rust # TODO: Remove when we have conditional builds | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Check out Rust SDK # TODO: Remove when we have conditional builds | |
run: | | |
./install_uniffi_bindgen_go.sh | |
mkdir rust-sdk # don't use HTTPS path in rebuild_rust_sdk.sh so we can use the rust-cache before building | |
(wget -O - "https://github.com/matrix-org/matrix-rust-sdk/archive/kegan/complement-crypto.tar.gz" | tar -xz --strip-components=1 -C rust-sdk) | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "rust-sdk" | |
- name: Build Rust SDK # TODO: Remove when we have conditional builds | |
run: | | |
./rebuild_rust_sdk.sh ./rust-sdk | |
- name: "Install Complement Dependencies" | |
run: | | |
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev | |
go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest | |
- name: Build JS SDK (branch 'develop') | |
run: | | |
./rebuild_js_sdk.sh matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk#develop | |
- name: Pull synapse service v1.94.0 and mitmproxy | |
shell: bash | |
run: | | |
docker pull ghcr.io/matrix-org/synapse-service:v1.94.0 | |
docker pull mitmproxy/mitmproxy:10.1.5 | |
docker tag ghcr.io/matrix-org/synapse-service:v1.94.0 homeserver:latest | |
- run: | | |
export LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
export LD_LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
set -o pipefail && | |
go test -v -json -timeout 15m ./tests | gotestfmt | |
shell: bash # required for pipefail to be A Thing. pipefail is required to stop gotestfmt swallowing non-zero exit codes | |
name: Run Complement Crypto Tests | |
env: | |
COMPLEMENT_BASE_IMAGE: homeserver | |
COMPLEMENT_ENABLE_DIRTY_RUNS: 1 | |
COMPLEMENT_CRYPTO_WRITE_CONTAINER_LOGS: 1 | |
COMPLEMENT_CRYPTO_TEST_CLIENT_MATRIX: jj # only run JS tests (TODO: also runs some rust tests regardless) | |
COMPLEMENT_SHARE_ENV_PREFIX: PASS_ | |
PASS_SYNAPSE_COMPLEMENT_DATABASE: sqlite | |
DOCKER_BUILDKIT: 1 | |
- name: Upload logs | |
uses: actions/upload-artifact@v2 | |
if: ${{ always() }} # do this even if the tests fail | |
with: | |
name: Logs - ${{ job.status }} | |
path: | | |
./tests/logs/* | |
rust-latest-main: | |
name: Tests (Rust only, latest main) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # Checkout crypto tests | |
- name: Setup | Node.js 18.x # TODO: Remove when we have conditional builds | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
cache-dependency-path: "internal/api/js/js-sdk/yarn.lock" | |
- name: Setup | Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Setup | Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Check out Rust SDK (branch 'main') | |
run: | | |
./install_uniffi_bindgen_go.sh | |
mkdir rust-sdk # don't use HTTPS path in rebuild_rust_sdk.sh so we can use the rust-cache before building | |
(wget -O - "https://github.com/matrix-org/matrix-rust-sdk/archive/main.tar.gz" | tar -xz --strip-components=1 -C rust-sdk) | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "rust-sdk" | |
- name: Build Rust SDK | |
run: | | |
./rebuild_rust_sdk.sh ./rust-sdk | |
- name: "Install Complement Dependencies" | |
run: | | |
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev | |
go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest | |
- name: Build JS SDK # TODO: Remove when we have conditional builds | |
run: | | |
cat ./internal/api/js/js-sdk/package.json | |
(cd ./internal/api/js/js-sdk && yarn install --frozen-lockfile && yarn build) | |
cp -r ./internal/api/js/js-sdk/dist/. ./internal/api/js/chrome/dist | |
- name: Pull synapse service v1.94.0 and mitmproxy | |
shell: bash | |
run: | | |
docker pull ghcr.io/matrix-org/synapse-service:v1.94.0 | |
docker pull mitmproxy/mitmproxy:10.1.5 | |
docker tag ghcr.io/matrix-org/synapse-service:v1.94.0 homeserver:latest | |
- run: | | |
export LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
export LD_LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
set -o pipefail && | |
go test -v -json -timeout 15m ./tests | gotestfmt | |
shell: bash # required for pipefail to be A Thing. pipefail is required to stop gotestfmt swallowing non-zero exit codes | |
name: Run Complement Crypto Tests | |
env: | |
COMPLEMENT_BASE_IMAGE: homeserver | |
COMPLEMENT_ENABLE_DIRTY_RUNS: 1 | |
COMPLEMENT_CRYPTO_WRITE_CONTAINER_LOGS: 1 | |
COMPLEMENT_CRYPTO_TEST_CLIENT_MATRIX: rr # only run rust tests (TODO: also runs some js tests regardless) | |
COMPLEMENT_SHARE_ENV_PREFIX: PASS_ | |
PASS_SYNAPSE_COMPLEMENT_DATABASE: sqlite | |
DOCKER_BUILDKIT: 1 | |
- name: Upload logs | |
uses: actions/upload-artifact@v2 | |
if: ${{ always() }} # do this even if the tests fail | |
with: | |
name: Logs - ${{ job.status }} | |
path: | | |
./tests/logs/* | |
complement: | |
name: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # Checkout crypto tests | |
# Install Node, Go and Rust, along with libolm and gotestfmt | |
- name: Setup | Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
cache-dependency-path: "internal/api/js/js-sdk/yarn.lock" | |
- name: Setup | Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Setup | Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Checkout matrix-rust-sdk | |
run: | | |
mkdir rust-sdk | |
(wget -O - "https://github.com/matrix-org/matrix-rust-sdk/archive/kegan/complement-crypto.tar.gz" | tar -xz --strip-components=1 -C rust-sdk) | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: "rust-sdk" | |
- name: "Install Complement Dependencies" | |
run: | | |
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev | |
go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest | |
# Install whatever version of the JS SDK is in package.json | |
- name: Build JS SDK | |
run: | | |
cat ./internal/api/js/js-sdk/package.json | |
(cd ./internal/api/js/js-sdk && yarn install --frozen-lockfile && yarn build) | |
cp -r ./internal/api/js/js-sdk/dist/. ./internal/api/js/chrome/dist | |
- name: Build Rust FFI bindings | |
run: | | |
(cd rust-sdk && cargo build -p matrix-sdk-ffi) | |
ls -alh rust-sdk/target/debug | |
# Temporary: as it takes 3m to build the complement synapse image >:( | |
- name: Pull synapse service v1.94.0 and mitmproxy | |
shell: bash | |
run: | | |
docker pull ghcr.io/matrix-org/synapse-service:v1.94.0 | |
docker pull mitmproxy/mitmproxy:10.1.5 | |
docker tag ghcr.io/matrix-org/synapse-service:v1.94.0 homeserver:latest | |
# Build homeserver image, honouring branch names | |
#- name: "Checkout corresponding Synapse branch" | |
#shell: bash | |
#run: | | |
#mkdir -p homeserver | |
# | |
## Attempt to use the version of the homeserver which best matches the | |
## current build. | |
## | |
## 1. If we are not on complement's default branch, check if there's a | |
## similarly named branch (GITHUB_HEAD_REF for pull requests, | |
## otherwise GITHUB_REF). | |
## 2. otherwise, use the default homeserver branch ("HEAD") | |
# | |
#for BRANCH_NAME in "$GITHUB_HEAD_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do | |
## Skip empty branch names, merge commits, and our default branch. | |
## (If we are on complement's default branch, we want to fall through to the HS's default branch | |
## rather than using the HS's 'master'/'main'). | |
#case "$BRANCH_NAME" in | |
#"" | refs/pull/* | main | master) | |
#continue | |
#;; | |
#esac | |
#(wget -O - "https://github.com/matrix-org/synapse/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C homeserver) && break | |
#done | |
## Build the base Synapse dockerfile and then build a Complement-specific image from that base. | |
#- run: | | |
#docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile . | |
#docker build -t matrixdotorg/synapse-workers:latest -f docker/Dockerfile-workers . | |
#docker build -t homeserver -f docker/complement/Dockerfile docker/complement | |
#working-directory: homeserver | |
#env: | |
#DOCKER_BUILDKIT: 1 | |
- name: "Run Complement-Crypto unit tests" | |
run: | | |
export LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
export LD_LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
env | |
go test $(go list ./internal/... | grep -v 'internal/tests') -timeout 60s | |
- name: "Ensuring client implementations work..." | |
run: | | |
export LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
export LD_LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
set -o pipefail && | |
go test -v -json -timeout 15m ./internal/tests | gotestfmt | |
shell: bash # required for pipefail to be A Thing. pipefail is required to stop gotestfmt swallowing non-zero exit codes | |
env: | |
COMPLEMENT_BASE_IMAGE: homeserver | |
COMPLEMENT_ENABLE_DIRTY_RUNS: 1 | |
COMPLEMENT_CRYPTO_WRITE_CONTAINER_LOGS: 1 | |
COMPLEMENT_SHARE_ENV_PREFIX: PASS_ | |
PASS_SYNAPSE_COMPLEMENT_DATABASE: sqlite | |
DOCKER_BUILDKIT: 1 | |
- run: | | |
export LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
export LD_LIBRARY_PATH="$(pwd)/rust-sdk/target/debug" | |
set -o pipefail && | |
go test -v -json -timeout 15m ./tests | gotestfmt | |
shell: bash # required for pipefail to be A Thing. pipefail is required to stop gotestfmt swallowing non-zero exit codes | |
name: Run Complement Crypto Tests | |
env: | |
COMPLEMENT_BASE_IMAGE: homeserver | |
COMPLEMENT_ENABLE_DIRTY_RUNS: 1 | |
COMPLEMENT_CRYPTO_WRITE_CONTAINER_LOGS: 1 | |
COMPLEMENT_SHARE_ENV_PREFIX: PASS_ | |
PASS_SYNAPSE_COMPLEMENT_DATABASE: sqlite | |
DOCKER_BUILDKIT: 1 | |
- name: Upload logs | |
uses: actions/upload-artifact@v2 | |
if: ${{ always() }} # do this even if the tests fail | |
with: | |
name: Logs - ${{ job.status }} | |
path: | | |
./tests/logs/* |