chore: fix unit tests, split e2e tests

github-actions
Nolan Lawson 2022-11-25 09:02:11 -08:00
rodzic 81a7b06329
commit 4ea595b7ae
6 zmienionych plików z 61 dodań i 11 usunięć

Wyświetl plik

@ -0,0 +1,48 @@
name: Read-only e2e tests
on:
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:12.2
env:
POSTGRES_USER: pinafore
POSTGRES_PASSWORD: pinafore
POSTGRES_DB: pinafore_development
POSTGRES_HOST: 127.0.0.1
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.3'
- name: Install Mastodon system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
ffmpeg \
fonts-noto-color-emoji \
imagemagick \
libicu-dev \
libidn11-dev \
libprotobuf-dev \
postgresql-contrib \
protobuf-compiler
- run: yarn --frozen-lockfile
- run: yarn build
- name: Read-only e2e tests
run: yarn test-in-ci-suite0

Wyświetl plik

@ -1,4 +1,4 @@
name: End-to-end tests
name: Read-write e2e tests
on:
pull_request:
branches: [ master ]
@ -30,8 +30,6 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.3'
# - name: Setup pinafore Postgres user
# run: sudo -u postgres psql -h 127.0.0.1 -d template1 -c "CREATE USER pinafore WITH PASSWORD 'pinafore' CREATEDB;"
- name: Install Mastodon system dependencies
run: |
sudo apt-get update
@ -46,7 +44,5 @@ jobs:
protobuf-compiler
- run: yarn --frozen-lockfile
- run: yarn build
- name: Read-only e2e tests
run: yarn test-in-ci-suite0
- name: Read-write e2e tests
run: yarn test-in-ci-suite1

Wyświetl plik

@ -13,6 +13,5 @@ jobs:
cache: 'yarn'
- run: yarn --frozen-lockfile
- run: yarn lint
- run: yarn build
- run: yarn test-vercel-json-unchanged
- run: yarn test-vercel-json
- run: yarn test-unit

Wyświetl plik

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Designed to be run before yarn build, and then tested with test-vercel-json-unchanged.sh
cp ./vercel.json /tmp/vercel-old.json

Wyświetl plik

@ -3,8 +3,8 @@
# In CI, we need to make sure the vercel.json file is built correctly,
# or else it will mess up the deployment to Vercel
if ! diff -q vercel-old.json vercel.json &>/dev/null; then
diff vercel-old.json vercel.json
if ! diff -q /tmp/vercel-old.json ./vercel.json &>/dev/null; then
diff /tmp/vercel-old.json ./vercel.json
echo "vercel.json changed, run yarn build and make sure everything looks okay"
exit 1
fi

Wyświetl plik

@ -31,12 +31,14 @@
"test-mastodon-suite0": "run-s wait-for-mastodon-to-start wait-for-mastodon-data testcafe-suite0",
"test-mastodon-suite1": "run-s wait-for-mastodon-to-start wait-for-mastodon-data testcafe-suite1",
"testcafe": "run-s testcafe-suite0 testcafe-suite1",
"testcafe-suite0": "cross-env-shell testcafe $BROWSER tests/spec/0*",
"testcafe-suite0": "cross-env-shell testcafe -c 2 $BROWSER tests/spec/0*",
"testcafe-suite1": "cross-env-shell testcafe $BROWSER tests/spec/1*",
"test-unit": "NODE_ENV=test mocha -r bin/browser-shim.js tests/unit/",
"test-in-ci-suite0": "cross-env BROWSER=chrome:headless run-p --race run-mastodon start test-mastodon-suite0",
"test-in-ci-suite1": "cross-env BROWSER=chrome:headless run-p --race run-mastodon start test-mastodon-suite1",
"test-vercel-json-unchanged": "./bin/test-vercel-json-unchanged.sh",
"test-vercel-json": "run-s test-vercel-json-copy build test-vercel-json-test",
"test-vercel-json-copy": "./bin/copy-vercel-json.sh",
"test-vercel-json-test": "./bin/test-vercel-json-unchanged.sh",
"wait-for-mastodon-to-start": "node bin/wait-for-mastodon-to-start.js",
"wait-for-mastodon-data": "node bin/wait-for-mastodon-data.js",
"backup-mastodon-data": "./bin/backup-mastodon-data.sh",