Latest update #1
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: CI | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
NODE_OPTIONS: "--max-old-space-size=6144" | |
NODE_ENV: test | |
NODE_MODULES_PATHS: | | |
node_modules | |
packages/*/node_modules | |
!packages/mobile/node_modules | |
jobs: | |
node_modules_cache: | |
name: Cache node modules | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- uses: actions/cache/save@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
test: | |
needs: node_modules_cache | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { package: "@tamanu/facility-server", shard: 1/4, postgres: 14 } | |
- { package: "@tamanu/facility-server", shard: 2/4, postgres: 14 } | |
- { package: "@tamanu/facility-server", shard: 3/4, postgres: 14 } | |
- { package: "@tamanu/facility-server", shard: 4/4, postgres: 14 } | |
- { package: "@tamanu/central-server", shard: 1/4, postgres: 14 } | |
- { package: "@tamanu/central-server", shard: 2/4, postgres: 14 } | |
- { package: "@tamanu/central-server", shard: 3/4, postgres: 14 } | |
- { package: "@tamanu/central-server", shard: 4/4, postgres: 14 } | |
- { package: "@tamanu/meta-server" } | |
- { package: "@tamanu/shared", postgres: 12 } | |
- { package: "@tamanu/shared", postgres: 14 } | |
- { package: "@tamanu/shared", postgres: 16 } | |
- { package: "@tamanu/web-frontend" } | |
name: Test ${{ matrix.package }} ${{ matrix.shard }} (pg=${{ matrix.postgres || 'no' }}) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- run: yarn build-shared | |
- run: yarn workspace ${{ matrix.package }} run build | |
- name: Install and start postgres if needed | |
if: matrix.postgres | |
run: | | |
source .github/scripts/install-postgres-ubuntu.sh ${{ matrix.postgres }} | |
.github/scripts/setup-postgres-for-one-package.sh ${{ matrix.package }} | |
- name: Run tests | |
env: | |
package: ${{ matrix.package }} | |
shard: ${{ matrix.shard }} | |
run: | | |
[[ -z "$shard" ]] || shard="--shard $shard" | |
yarn workspace "$package" run test $shard | |
build-all: | |
needs: node_modules_cache | |
name: Build all packages | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- run: yarn build | |
lint: | |
needs: node_modules_cache | |
name: Lint packages | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- name: Lint errors | |
run: yarn lint-all --quiet | |
- name: Lint warnings | |
run: yarn lint-all | |
storybook: | |
needs: node_modules_cache | |
# Workaround for define plugin conflict warning | |
env: | |
NODE_ENV: development | |
continue-on-error: true | |
name: Test storybook | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- run: yarn build-shared | |
- run: yarn workspace @tamanu/web-frontend run test-storybook | |
migrations: | |
needs: node_modules_cache | |
strategy: | |
fail-fast: false | |
matrix: | |
server: | |
- central-server | |
- facility-server | |
postgres: | |
- '12' | |
- '14' | |
- '15' | |
- '16' | |
name: Test migrations server=${{ matrix.server }} pg=${{ matrix.postgres }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- run: yarn build-shared | |
- name: Install and start postgres ${{ matrix.postgres }} | |
run: | | |
source .github/scripts/install-postgres-ubuntu.sh ${{ matrix.postgres }} | |
.github/scripts/setup-postgres-for-one-package.sh migrations | |
- run: scripts/apply_and_revert_server_migrations.sh ${{ matrix.server }} | |
test-mobile: | |
name: Test mobile | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarnmobile-${{ hashFiles('mobile/yarn.lock') }} | |
path: mobile/node_modules | |
- run: yarn | |
working-directory: packages/mobile | |
- uses: actions/cache/save@v3 | |
with: | |
key: ${{ runner.os }}-yarnmobile-${{ hashFiles('mobile/yarn.lock') }} | |
path: mobile/node_modules | |
- run: yarn test | |
working-directory: packages/mobile | |
test-facility-offline: | |
needs: node_modules_cache | |
name: Test the facility server with the central server being down | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- uses: actions/cache/restore@v3 | |
with: | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
path: ${{ env.NODE_MODULES_PATHS }} | |
- run: yarn | |
- name: Install and start postgres | |
run: | | |
source .github/scripts/install-postgres-ubuntu.sh 16 | |
.github/scripts/test-facility-offline.sh setup-postgres | |
- name: Build central and facility servers | |
run: .github/scripts/test-facility-offline.sh build | |
- name: Start a central server | |
run: .github/scripts/test-facility-offline.sh central-start | |
- name: Start a facility server | |
run: .github/scripts/test-facility-offline.sh facility-start | |
- name: Stop the servers and print logs | |
run: .github/scripts/test-facility-offline.sh stop-and-print | |
- name: Start a facility server again without a central one | |
run: .github/scripts/test-facility-offline.sh facility-start-again | |
test-yarn-lock: | |
strategy: | |
fail-fast: false | |
matrix: | |
workdir: | |
- . | |
- packages/mobile | |
name: Check ${{ matrix.workdir }}/yarn.lock is up to date | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: yarn | |
- run: yarn | |
working-directory: ${{ matrix.workdir }} | |
- run: git diff --exit-code | |
# Dummy job to have a stable name for PR requirements | |
tests-pass: | |
if: always() # always run even if dependencies fail | |
name: Tests pass | |
needs: | |
- test | |
- build-all | |
- lint | |
- migrations | |
- test-mobile | |
- test-facility-offline | |
- test-yarn-lock | |
runs-on: ubuntu-latest | |
steps: | |
- uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} |