Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-6213
Browse files Browse the repository at this point in the history
  • Loading branch information
jamil314 authored Jan 8, 2025
2 parents 8a0b37d + 4ed93eb commit 6e0d174
Show file tree
Hide file tree
Showing 95 changed files with 2,836 additions and 2,015 deletions.
173 changes: 163 additions & 10 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
#
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.

name: Lint, run unit tests and security scans
name: Lint and run unit tests

on: [pull_request]
on:
pull_request:
push:
branches:
- develop

jobs:
setup:
name: Setup tests
permissions:
contents: read
pull-requests: write
Expand All @@ -28,6 +33,7 @@ jobs:
# forked repos cannot access secrets.GITHUB_TOKEN which causes this step
# to fail
continue-on-error: true
if: github.event_name == 'pull_request'
with:
message: >
Oops! Looks like you forgot to update the changelog.
Expand All @@ -44,6 +50,7 @@ jobs:
echo "matrix=${PACKAGES}" >> $GITHUB_OUTPUT
test:
name: Test
needs: setup
runs-on: ubuntu-22.04
strategy:
Expand Down Expand Up @@ -136,27 +143,173 @@ jobs:
if: steps.check-scripts.outputs.skip != 'true'
run: CI="" yarn install --frozen-lockfile

# TODO: Move out of the matrix to be built once and shared
- name: Build common package
if: steps.check-scripts.outputs.skip != 'true' && contains(env.DEPENDENCIES, 'packages/commons')
if: matrix.package != 'packages/client' && steps.check-scripts.outputs.skip != 'true' && contains(env.DEPENDENCIES, 'packages/commons')
run: cd packages/commons && yarn build

- name: Build components client and login
if: steps.check-scripts.outputs.skip != 'true' && contains(env.DEPENDENCIES, 'packages/components')
- name: Build components
if: matrix.package != 'packages/client' && steps.check-scripts.outputs.skip != 'true' && contains(env.DEPENDENCIES, 'packages/components')
run: |
cd packages/components && yarn build
# TODO: should run parallel to unit tests as can take as much as unit tests
- name: Run linting
if: steps.check-scripts.outputs.skip != 'true' && steps.check-scripts.outputs.skip-lint != 'true'
if: matrix.package != 'packages/client' && steps.check-scripts.outputs.skip != 'true' && steps.check-scripts.outputs.skip-lint != 'true'
run: cd ${{ matrix.package }} && yarn lint

- name: Run Unit Test
if: steps.check-scripts.outputs.skip != 'true' && steps.check-scripts.outputs.skip-test != 'true'
if: matrix.package != 'packages/client' && steps.check-scripts.outputs.skip != 'true' && steps.check-scripts.outputs.skip-test != 'true'
run: cd ${{ matrix.package }} && yarn test

prepare-client-tests:
name: Prepare client tests
runs-on: ubuntu-22.04
steps:
- name: Checking out git repo
uses: actions/checkout@v4

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Extract dependencies for client
id: extract-dependencies
run: |
DEPENDENCIES=$(node -e "
const { execSync } = require('child_process');
const output = execSync('yarn --silent workspaces info', { encoding: 'utf-8' });
const json = JSON.parse(output.replaceAll('@opencrvs', 'packages'));
const getDependencies = (pkg) =>
json[pkg].workspaceDependencies.concat(
json[pkg].workspaceDependencies.flatMap(getDependencies)
);
console.log(
getDependencies('packages/client').join(' ')
);
")
echo "DEPENDENCIES=${DEPENDENCIES}" >> $GITHUB_ENV
echo "Found dependencies: $DEPENDENCIES"
- name: Remove other package directories
run: |
for dir in packages/*; do
if echo "packages/client $DEPENDENCIES" | grep -q -w "$dir"; then
echo "Skipping $dir"
else
echo "Removing $dir"
rm -rf "$dir"
fi
done
- name: Cache Node.js dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.cache/yarn/v6
key: node-${{ hashFiles('**/yarn.lock', format('{0}/{1}','packages/client','package.json')) }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: CI="" yarn install --frozen-lockfile

- name: Build common package
run: cd packages/commons && yarn build

- name: Build components
run: |
cd packages/components && yarn build
- name: Upload filesystem as artifact
uses: actions/upload-artifact@v4.5.0
with:
name: client
include-hidden-files: true
path: |
.
!**/node_modules
lint-client:
name: Lint client
needs: prepare-client-tests
runs-on: ubuntu-22.04

steps:
- name: Download filesystem artifact
uses: actions/download-artifact@v4.1.8
with:
name: client
path: .

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Cache Node.js dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.cache/yarn/v6
key: node-${{ hashFiles('**/yarn.lock', format('{0}/{1}','packages/client','package.json')) }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: CI="" yarn install --frozen-lockfile

- name: Compile
run: cd packages/client && yarn test:compilation

- name: Run linting
run: cd packages/client && yarn lint

test-client:
name: Test client
needs: prepare-client-tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
shards: [1, 2, 3, 4, 5]

steps:
- name: Download filesystem artifact
uses: actions/download-artifact@v4.1.8
with:
name: client
path: .

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Cache Node.js dependencies
uses: actions/cache@v4
with:
path: |
**/node_modules
~/.cache/yarn/v6
key: node-${{ hashFiles('**/yarn.lock', format('{0}/{1}','packages/client','package.json')) }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: CI="" yarn install --frozen-lockfile

- name: Run Unit Test
run: cd packages/client && yarn test -- --shard $(( ${{ strategy.job-index }} + 1 ))/${{ strategy.job-total }}

lint-knip:
name: Lint unused exports with Knip
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request'
steps:
- name: Checkout base branch
uses: actions/checkout@v4
Expand All @@ -183,7 +336,7 @@ jobs:
- name: Run knip on base branch
id: knip_base
run: |
npx knip --tags=-knipignore --no-exit-code --exports --reporter=markdown > knip_report.md
npx knip --tags=-knipignore --no-exit-code --exports --reporter=markdown | sed -E 's/ +/ /g' | sed -E 's/:[0-9]+:[0-9]+//' > knip_report.md
TOTAL=$(grep -oP '## [A-Za-z\s]+ \(\K[0-9]+' knip_report.md | awk '{sum+=$1} END {print sum}')
echo "Total $TOTAL issue(s) on base branch."
echo "total=${TOTAL}" >> $GITHUB_OUTPUT
Expand All @@ -192,7 +345,7 @@ jobs:
- name: Run knip on PR branch
id: knip_pr
run: |
npx knip --tags=-knipignore --no-exit-code --exports --reporter=markdown > knip_report.md
npx knip --tags=-knipignore --no-exit-code --exports --reporter=markdown | sed -E 's/ +/ /g' | sed -E 's/:[0-9]+:[0-9]+//' > knip_report.md
TOTAL=$(grep -oP '## [A-Za-z\s]+ \(\K[0-9]+' knip_report.md | awk '{sum+=$1} END {print sum}')
echo "Total $TOTAL issue(s) on PR branch."
echo "total=${TOTAL}" >> $GITHUB_OUTPUT
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

### New features

- Misc new feature
- Allow configuring the default search criteria for record search [#6924](https://github.com/opencrvs/opencrvs-core/issues/6924)
- Add checks to validate client and server are always on the same version. This prevents browsers with a cached or outdated client versions from making potentially invalid requests to the backend [#6695](https://github.com/opencrvs/opencrvs-core/issues/6695)
- Two new statuses of record are added: `Validated` and `Correction Requested` for advanced search parameters [#6365](https://github.com/opencrvs/opencrvs-core/issues/6365)
Expand All @@ -24,6 +23,8 @@
- **Template Selection Dropdown**: Updated print workflow to include a dropdown menu for template selection when issuing a certificate.
- Auth now allows exchanging user's token for a new record-specific token [#7728](https://github.com/opencrvs/opencrvs-core/issues/7728)
- A new GraphQL mutation `upsertRegistrationIdentifier` is added to allow updating the patient identifiers of a registration record such as NID [#8034](https://github.com/opencrvs/opencrvs-core/pull/8034)
- Updated GraphQL mutation `confirmRegistration` to allow adding a `comment` for record audit [#8197](https://github.com/opencrvs/opencrvs-core/pull/8197)
- Introduced a new customisable UI component: Banner [#8276](https://github.com/opencrvs/opencrvs-core/issues/8276)

### Improvements

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ services:
- MONGO_URL=mongodb://mongo1/events
- ES_HOST=elasticsearch:9200
- COUNTRY_CONFIG_URL=http://countryconfig:3040/
- DOCUMENTS_URL=http://documents:9050

# User facing services
workflow:
Expand Down
3 changes: 1 addition & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"build": "NODE_OPTIONS=--max_old_space_size=8000 vite build",
"docker:build": "docker build ../../ -f ../../Dockerfile-register -t ocrvs-client",
"docker:run": "docker run -it --rm -p 5000:80 --name ocrvs-client ocrvs-client",
"test": "yarn test:compilation && NODE_OPTIONS=--max_old_space_size=8000 vitest run --coverage --silent --dangerouslyIgnoreUnhandledErrors",
"test": "NODE_OPTIONS=--max_old_space_size=8000 vitest run --silent --dangerouslyIgnoreUnhandledErrors",
"test:watch": "vitest",
"open:cov": "yarn test && opener coverage/index.html",
"lint": "yarn lint:css && yarn lint:ts",
"lint:css": "stylelint 'src/**/*.{ts,tsx}'",
"lint:ts": "eslint --fix './src/**/*.{ts,tsx}' --max-warnings=353",
Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/src-sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { NetworkFirst, CacheFirst } from 'workbox-strategies'
import { clientsClaim } from 'workbox-core'
import { MINIO_REGEX } from '@opencrvs/commons/client'

// eslint-disable-next-line @typescript-eslint/no-use-before-define
self.__WB_DISABLE_DEV_LOGS = true

declare let self: ServiceWorkerGlobalScope

self.addEventListener('install', (event) => {
Expand Down
Loading

0 comments on commit 6e0d174

Please sign in to comment.