Skip to content

Commit

Permalink
Merge branch 'epic-medication-enhancements-and-mar' into epic-medicat…
Browse files Browse the repository at this point in the history
…ion-enhancements-and-mar-2
  • Loading branch information
khoi-bes committed Feb 19, 2025
2 parents 527d1e7 + 7d9e610 commit 7606272
Show file tree
Hide file tree
Showing 454 changed files with 17,308 additions and 9,422 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ jobs:
matrix:
platform:
- arch: amd64
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
- arch: arm64
runs-on: Linux-ARM64-Ubuntu-24.04
runs-on: ubuntu-24.04-arm
package:
- name: central
path: central-server
Expand Down
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
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"humao.rest-client",
"streetsidesoftware.code-spell-checker",
"styled-components.vscode-styled-components"
]
}
25 changes: 12 additions & 13 deletions alerts/certificate-notification-error.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ sql: |
SELECT *
FROM certificate_notifications
WHERE status = 'Error'
AND created_at > $1;
AND created_at > $1
ORDER BY created_at DESC
send:
- target: external
id: default
subject: '[Tamanu Alert] Certificate notification error ({{ hostname }})'
template: |
<p>Server: {{ hostname }}</p>
<h1>Patient notifications errored</h1>
<p>There are {{ rows | length }} certificate notifications that have failed to process.</p>
<ul>
{% for row in rows | slice(end=5) %}
<li><b>{{ row.id }}</b>: {{ row.type }} - <i>{{ row.error }}</i></li>
{% endfor %}
{% if rows | length > 5 %}
<li>... and {{ rows | length - 5 }} more</li>
{% endif %}
</ul>
<p>For more information, please check the logs.</p>
- Server: {{ hostname }}
- Alert: {{ filename }}
There are {{ rows | length }} certificate notifications that have failed to process:
{% for row in rows | slice(end=5) %}
- **{{ row.type }} ({{ row.id }})**: {{ row.error }}
{% endfor %}
{% if rows | length > 5 %}
- ... and {{ rows | length - 5 }} more
{% endif %}
25 changes: 12 additions & 13 deletions alerts/fhir-error.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ sql: |
SELECT *
FROM fhir.jobs
WHERE error IS NOT NULL
AND created_at > $1;
AND created_at > $1
ORDER BY created_at DESC
send:
- target: external
id: default
subject: '[Tamanu Alert] FHIR job error ({{ hostname }})'
template: |
<p>Server: {{ hostname }}</p>
<h1>FHIR jobs errored</h1>
<p>There are {{ rows | length }} FHIR jobs that have failed to process.</p>
<ul>
{% for row in rows | slice(end=5) %}
<li><b>{{ row.created_at }}</b>: {{ row.topic }} - <i>{{ row.error }}</i></li>
{% endfor %}
{% if rows | length > 5 %}
<li>... and {{ rows | length - 5 }} more</li>
{% endif %}
</ul>
<p>For more information, please check the logs.</p>
- Server: {{ hostname }}
- Alert: {{ filename }}
There are {{ rows | length }} FHIR jobs that have failed to process:
{% for row in rows | slice(end=5) %}
- **{{ row.topic }} ({{ row.created_at }})**: {{ row.error }}
{% endfor %}
{% if rows | length > 5 %}
- ... and {{ rows | length - 5 }} more
{% endif %}
10 changes: 5 additions & 5 deletions alerts/fhir-queue-incredibly-large.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ sql: |
COUNT(*) AS job_count
FROM fhir.jobs
WHERE status = 'Queued'
HAVING COUNT(*) > 1000;
HAVING COUNT(*) > 1000
send:
- target: external
id: default
subject: '[Tamanu Alert] FHIR job queue abnormally large ({{ hostname }})'
template: |
<p>Server: {{ hostname }}</p>
<p>Alert: {{ filename }}</p>
<h1>FHIR queued jobs count is abnormally high</h1>
<p>Currently queued jobs: {{ rows[0].job_count }}</p>
- Server: {{ hostname }}
- Alert: {{ filename }}
Currently queued jobs: {{ rows[0].job_count }}
28 changes: 14 additions & 14 deletions alerts/fhir-queued-job-long.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
sql: |
SELECT
id,
topic,
payload->>'resource' AS resource,
ROUND(EXTRACT(EPOCH FROM (NOW() - created_at)) / 60)::text AS duration_minutes
ROUND(EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - created_at)) / 60)::text AS duration_minutes
FROM fhir.jobs
WHERE status = 'Queued'
AND NOW() - created_at > INTERVAL '15 minutes';
AND CURRENT_TIMESTAMP - created_at > INTERVAL '15 minutes'
AND topic != 'fhir.resolver'
ORDER BY created_at ASC
send:
- target: external
id: default
subject: '[Tamanu Alert] Long queued FHIR jobs ({{ hostname }})'
template: |
<p>Server: {{ hostname }}</p>
<p>Alert: {{ filename }}</p>
<h1>Long queued FHIR jobs detected</h1>
<ul>
{% for row in rows | slice(end=5) %}
<li><b>{{row.resource}}</> ID: <b>{{ row.id }}</b> - Duration: <i>{{ row.duration_minutes }} minutes</i></li>
{% endfor %}
{% if rows | length > 5 %}
<li>... and {{ rows | length - 5 }} more</li>
{% endif %}
</ul>
<p>For more information, please check the logs.</p>
- Server: {{ hostname }}
- Alert: {{ filename }}
{% for row in rows | slice(end=5) %}
- **{{ row.topic }}** {{row.resource}} ({{ row.id }}) for {{ row.duration_minutes }} minutes
{% endfor %}
{% if rows | length > 5 %}
- ... and {{ rows | length - 5 }} more
{% endif %}
Loading

0 comments on commit 7606272

Please sign in to comment.