Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/beyondessential/tamanu into…
Browse files Browse the repository at this point in the history
… epic-medication-enhancements-and-mar-2
  • Loading branch information
huytranbes committed Feb 19, 2025
2 parents 5e4ae47 + 07c18bd commit fd5ca16
Show file tree
Hide file tree
Showing 149 changed files with 6,546 additions and 2,621 deletions.
113 changes: 0 additions & 113 deletions .github/workflows/ci-fake-db-dump.yml

This file was deleted.

64 changes: 41 additions & 23 deletions .github/workflows/ci-non-deterministic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Migrations for Determinism
name: Migration determinism

on:
workflow_dispatch:
Expand All @@ -17,9 +17,6 @@ env:
jobs:
test-for-non-determinism:
permissions:
id-token: write # allow accessing OIDC token for AWS
contents: read
strategy:
fail-fast: false
matrix:
Expand All @@ -28,18 +25,28 @@ jobs:
- "14"
- "15"
- "16"
name: Test Migrations for Determinism on pg${{ matrix.postgres }}
- "17"
name: on pg=${{ matrix.postgres }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ap-southeast-2
role-to-assume: arn:aws:iam::143295493206:role/gha-tamanu-test-data-snapshots-s3
role-session-name: GHA@fake=generate
- uses: actions/checkout@v4
with:
fetch-depth: 4000
fetch-depth: 0
ref: ${{ github.base_ref }}
- run: git switch ${{ github.event.pull_request.head.ref || github.ref_name }}

# Deal with the case where base_ref diverges from this branch
# (e.g. main has gone beyond the point where this branch forked)
#
# Test from the base of the PR or one commit back if on main/release.
- name: Find base
id: base
run: |
realbase=$(git merge-base ${{ github.base_ref || 'HEAD~1' }} HEAD)
echo "realbase=$realbase" | tee -a "$GITHUB_OUTPUT"
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
Expand All @@ -49,25 +56,36 @@ jobs:
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
path: ${{ env.NODE_MODULES_PATHS }}

- run: npm install
- run: npm ci
- run: npm run build-shared

- name: Precheck
id: precheck
run: |
set +e
npm run --silent --workspace scripts test-determinism -- --since-ref ${{ steps.base.outputs.realbase }} --check-precondition --skip-db-check --skip-env-check
code=$?
echo "code=$code" | tee -a "$GITHUB_OUTPUT"
[[ "$code" = "1" ]] && exit 1
true
- name: Install and start postgres ${{ matrix.postgres }}
if: steps.precheck.outputs.code != '2'
run: |
source .github/scripts/install-postgres-ubuntu.sh ${{ matrix.postgres }}
.github/scripts/setup-postgres-for-one-package.sh fake
- run: python3 -m pip install boto3

- id: commit-finder
run: |
commit=$(.github/scripts/find-dumped.py)
(( $? == 0 )) || exit 1
echo "commit=$commit" >> $GITHUB_OUTPUT
- run: aws s3 cp s3://bes-tamanu-test-data-snapshots/${{ steps.commit-finder.outputs.commit }}/fake-pg${{ matrix.postgres }}.dump ./ --no-progress
- name: Test central migrations
if: steps.precheck.outputs.code != '2'
env:
NODE_CONFIG_DIR: ${{ github.workspace }}/packages/central-server/config
run: npm run --silent --workspace scripts test-determinism -- --since-ref ${{ steps.base.outputs.realbase }}

- run: npm run --workspace scripts test-determinism -- --dump-path $(realpath fake-pg${{ matrix.postgres }}.dump)
- name: Test facility migrations
if: steps.precheck.outputs.code != '2'
env:
NODE_CONFIG_DIR: ${{ github.workspace }}/packages/facility-server/config
run: npm run --silent --workspace scripts test-determinism -- --since-ref ${{ steps.base.outputs.realbase }}

# Dummy job to have a stable name for PR requirements
tests-pass:
Expand Down
6 changes: 3 additions & 3 deletions common.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"ignoreDeprecations": "5.0",
"verbatimModuleSyntax": false,
"isolatedModules": true,
"module": "ES2020",
"lib": ["es2020"],
"module": "ES2022",
"lib": ["es2022"],
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"skipLibCheck": true,
"strict": true,
"target": "es2020"
"target": "es2022"
},
"exclude": [
"build",
Expand Down
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/encounters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in encounters."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in encounters."
data_tests:
- not_null
4 changes: 4 additions & 0 deletions database/model/central-server/fhir/generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ Timestamp of when this FHIR resource was last materialised.
{% docs fhir__generic__is_live %}
Whether or not a FHIR resource is live. If a resource is not live, it won't be rematerialised if upstream changes are made.
{% enddocs %}

{% docs fhir__generic__resolved %}
If this FHIR resource has resolved all of its references to other resources.
{% enddocs %}
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/immunizations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in immunizations."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in immunizations."
data_tests:
- not_null
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/non_fhir_medici_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in non_fhir_medici_report."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in non_fhir_medici_report."
data_tests:
- not_null
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/organizations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in organizations."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in organizations."
data_tests:
- not_null
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/patients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in patients."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in patients."
data_tests:
- not_null
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/practitioners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in practitioners."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in practitioners."
data_tests:
- not_null
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/service_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in service_requests."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in service_requests."
data_tests:
- not_null
5 changes: 5 additions & 0 deletions database/model/central-server/fhir/specimens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ sources:
description: "{{ doc('fhir__generic__is_live') }} in specimens."
data_tests:
- not_null
- name: resolved
data_type: boolean
description: "{{ doc('fhir__generic__resolved') }} in specimens."
data_tests:
- not_null
Loading

0 comments on commit fd5ca16

Please sign in to comment.