Skip to content

Commit 387d71d

Browse files
authored
ci: add pre-commit hooks and CI jobs (#420)
Add CI workflow with main jobs to run pre-commit, REUSE, and build the container image. Fix typos and whitespacing after running pre-commit.
1 parent 6684c8d commit 387d71d

File tree

19 files changed

+149
-24
lines changed

19 files changed

+149
-24
lines changed

.github/workflows/ci.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SPDX-FileCopyrightText: Copyright (C) 2025 Opal Health Informatics Group at the Research Institute of the McGill University Health Centre <[email protected]>
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
name: CI
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
workflow_dispatch:
12+
merge_group:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
23+
lint:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/[email protected]
27+
with:
28+
persist-credentials: false
29+
- uses: mschoettle/[email protected]
30+
if: '!cancelled()'
31+
env:
32+
SKIP: reuse-lint-file
33+
34+
35+
run-reuse-workflow:
36+
uses: opalmedapps/.github/.github/workflows/reuse.yaml@main
37+
38+
build-image:
39+
needs:
40+
- lint
41+
permissions:
42+
contents: read
43+
packages: write
44+
uses: opalmedapps/.github/.github/workflows/docker-build.yaml@main
45+
with:
46+
test-command: node /app/src/utility/version

.gitlab/merge_request_templates/Default.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
1414

1515
### Dependencies
1616
<!-- Link to dependent pull requests. Specify whether the MRs are just related, or require each other to run. Write N/A if there are none. -->
17-
- **App**:
17+
- **App**:
1818

1919
### Acceptance Tests
2020
<!-- Put an x in the checkbox when done. -->

.pre-commit-config.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: Copyright (C) 2025 Opal Health Informatics Group at the Research Institute of the McGill University Health Centre <[email protected]>
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v5.0.0
8+
hooks:
9+
- id: check-added-large-files
10+
- id: check-merge-conflict
11+
- id: check-shebang-scripts-are-executable
12+
- id: check-json
13+
- id: check-toml
14+
- id: check-yaml
15+
- id: double-quote-string-fixer
16+
- id: end-of-file-fixer
17+
- id: trailing-whitespace
18+
19+
- repo: https://github.com/fsfe/reuse-tool
20+
rev: v5.0.2
21+
hooks:
22+
- id: reuse-lint-file
23+
24+
- repo: https://github.com/crate-ci/typos
25+
rev: v1.31.1
26+
hooks:
27+
- id: typos
28+
29+
# zizmor detects security vulnerabilities in GitHub Actions workflows.
30+
- repo: https://github.com/woodruffw/zizmor-pre-commit
31+
rev: v1.5.2
32+
hooks:
33+
- id: zizmor
34+
35+
- repo: https://github.com/python-jsonschema/check-jsonschema
36+
rev: 0.32.1
37+
hooks:
38+
- id: check-github-workflows
39+
args: ["--verbose"]
40+
- id: check-compose-spec
41+
args: ["--verbose"]
42+
- id: check-renovate
43+
args: ["--verbose"]
44+
additional_dependencies: ['json5']
45+
46+
# `actionlint` hook, for verifying correct syntax in GitHub Actions workflows.
47+
# Some additional configuration for `actionlint` can be found in `.github/actionlint.yaml`.
48+
- repo: https://github.com/rhysd/actionlint
49+
rev: v1.7.7
50+
hooks:
51+
- id: actionlint
52+
language: golang
53+
additional_dependencies:
54+
# actionlint has a shellcheck integration which extracts shell scripts in `run:` steps from GitHub Actions
55+
# and checks these with shellcheck.
56+
# see also: https://github.com/rhysd/actionlint/pull/482
57+
- "github.com/wasilibs/go-shellcheck/cmd/[email protected]"

.typos.toml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: Copyright (C) 2025 Opal Health Informatics Group at the Research Institute of the McGill University Health Centre <[email protected]>
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
[default.extend-words]
6+
# part of SerNum
7+
ser = "ser"
8+
readby = "readby"
9+
# SQL queries
10+
tge = "tge"
11+
# not worth it to fix
12+
aggreement = "aggreement"
13+
# name in THIRDPART.md
14+
childs = "childs"
15+
16+
[default]
17+
extend-ignore-identifiers-re = [
18+
# auto-generated index name
19+
"[a-z_]+_[a-f0-9]{6}_idx"
20+
]
21+
22+
[files]
23+
extend-exclude = [
24+
"opal/tests/sql/*.sql",
25+
"**/locale/fr/**/*.po",
26+
]

CHANGES

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Version 1.8.0.0:
112112
- fix: update check-permissions endpoint
113113
- Revert "QSCCD-812 Temporary DEV/QA separation"
114114
- QSCCD-812 Temporary DEV/QA separation
115-
- QSCCD-664: Change queries to PatientDeviceIndentifier to save username and security question answer
115+
- QSCCD-664: Change queries to PatientDeviceIdentifier to save username and security question answer
116116
- chore(deps): update dependency jsdoc to v4
117117
- fix: extract ser nums from rows so 'setCheckInUsername' query doesn't fail
118118
- fix: fix the query function for educational materials in listener (QSCCD-914)
@@ -147,7 +147,7 @@ Version 1.8.0.0:
147147
- feat: add api retrieve patient data from new backend (QSCCD-667)
148148
- Feat add api calls add and get firebase user to listener (QSCCD-666)
149149
- QSCCD-87: Save questionnaire respondentUsername in the database (!124)
150-
- QSCCD-461: Add missing field for multiple patient annoucements filtering
150+
- QSCCD-461: Add missing field for multiple patient announcements filtering
151151
- QSCCD-427: Allow multiple possible salts (RAMQ, MRNs) for registration requests (!121)
152152
- Feat: Add request service to call registration apis in backend (QSCCD-565)
153153
- QSCCD-445: Cache encryption data in-memory for subsequent requests
@@ -353,7 +353,7 @@ Version 1.0.3.2:
353353
- Merge branch 'Issue_482' into staging
354354

355355
Version 1.0.3.1:
356-
- -- Add app verion to patient activity logging -- block logging of LogPatientAction request
356+
- -- Add app version to patient activity logging -- block logging of LogPatientAction request
357357

358358
Version 1.0.3.0:
359359
- Log all requests in the PatientActivityLog
@@ -414,7 +414,7 @@ Version 1.0.1.2:
414414
- Merge branch 'hotfix-1.0.1.1'
415415

416416
Version 1.0.1.1:
417-
- Modified the patient appointment query to use the getTranslation functino
417+
- Modified the patient appointment query to use the getTranslation function
418418
- --- Merging the changes from PreProdDev Merge branch 'PreProdDev'
419419
- --- Images
420420
- --- Adding Images

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The project contains `Dockerfile` and `docker-compose.yml` files to build an im
5050
To build the Docker image and run the container, running the following command at the root of the project
5151

5252
```shell
53-
docker compose up
53+
docker compose up
5454
```
5555

5656
More information about Docker compose can be found on the [Docker Compose page](https://docs.docker.com/compose/).

THIRDPARTY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ SOFTWARE.
519519
520520
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
521521
522-
Copyright (c) 2009-2013 Jeff Mott
522+
Copyright (c) 2009-2013 Jeff Mott
523523
Copyright (c) 2013-2016 Evan Vosberg
524524
525525
Permission is hereby granted, free of charge, to any person obtaining a copy

listener/api/main.js

-2
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,3 @@ function requestLegacyWrapper(context, requestKey, requestObject) {
8585
function apiRequestFormatter(context, requestKey,requestObject) {
8686
return requestLegacyWrapper(context, requestKey, requestObject);
8787
}
88-
89-

listener/api/modules/patient/security-questions/request-handlers/update-security-question-answer.request-handler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class UpdateSecurityQuestionAnswerRequestHandler extends ApiRequestHandler {
7272
answer: questionAnswerArr[key].answer
7373
});
7474
}
75-
// reformat the array value to mathc data structure before and equal version 1.12.2
75+
// reformat the array value to match data structure before and equal version 1.12.2
7676
await SecurityDjango.updateSecurityQuestionAndAnswerList(requestObject.meta.UserID, questionAnswerForLowerVersion);
7777
}
7878
// new data structure after version 1.12.2

listener/api/sqlInterface.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ exports.setNewPassword = function(password, username) {
947947
*@module sqlInterface
948948
*@name inputEducationalMaterialRating
949949
*@require queries
950-
*@descrption Inputs educational material rating
950+
*@description Inputs educational material rating
951951
*@parameter {string} patientSerNum SerNum in database for user that rated the material
952952
*@parameter {string} edumaterialSerNum serNum for educational material
953953
*@parameter {string} ratingValue value from 1 to 5 for educational material

listener/logs/logger.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const {createLogger, format, transports} = require('winston');
88

9-
// Choose log level according to environement.
9+
// Choose log level according to environment.
1010
const LoggerLevel = process.env.NODE_ENV === 'production' ? 'info' : 'debug';
1111

1212
// Set custom format for login.
@@ -16,7 +16,7 @@ const opalLogFormat = format.printf((info) => {
1616
return `${timestamp} - ${level.toUpperCase()}: ${message}${formattedData ? `: ${formattedData}` : ''}`;
1717
});
1818

19-
// Format error data according to data type passed to the logger wraper
19+
// Format error data according to data type passed to the logger wrapper
2020
const formatErrorData = (data) => {
2121
if (typeof data === 'undefined') return '';
2222
else if (data instanceof Error) return `${data}${data.cause ? `: ${formatErrorData(data.cause)}` : ''}`;
@@ -27,7 +27,7 @@ const formatErrorData = (data) => {
2727

2828
// Initialize winston logger
2929
const WinstonLogger = createLogger({
30-
// Silent logger when runing unit tests.
30+
// Silent logger when running unit tests.
3131
silent: process.env.DISABLED_LOGGING === 'true',
3232
// Set level log level
3333
level: LoggerLevel,

listener/mailer/mailer.js

-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ function Mail(){
3939
}
4040

4141
module.exports = Mail;
42-

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"sinon": "19.0.2"
5151
},
5252
"keywords": [
53-
"muhc",
5453
"opal",
5554
"health",
5655
"oncology"

renovate.json5

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"gitlab>opalmedapps/renovate-bot//presets/docker-alpine.json5",
2222
],
2323
// Extra rules for node images. See: https://github.com/renovatebot/renovate/discussions/29501
24-
// Ensure that node docker versioning doesn't interfer with the custom managers.
24+
// Ensure that node docker versioning doesn't interfere with the custom managers.
2525
"ignorePresets": ["workarounds:nodeDockerVersioning"],
2626
"assignees": ["staceybeard"],
2727
"labels": ["dependencies"],

src/core/request-handler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class RequestHandler {
4444
* @description Handle requests with requestType 'api'. Then upload response ti Firebase
4545
* Need to add timestamp after encryption to give a valid value to Firebase.
4646
* @param {string} requestType Firebase request unique identifier
47-
* @param {object} snapshot Data snapshot from firebase or and formated error to be handle by the app.
47+
* @param {object} snapshot Data snapshot from firebase or and formatted error to be handle by the app.
4848
*/
4949
async processRequest(requestType, snapshot) {
5050
legacyLogger.log('debug', `API: Processing API request of type ${requestType}`);

src/encryption/encryption.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class EncryptionUtilities {
145145

146146
/**
147147
* @description SQL query to get security question hash used for encryption and decryption
148-
* @param {string} userId ID used to retrive salt.
148+
* @param {string} userId ID used to retrieve salt.
149149
* @param {string} deviceId ID of the device use to make the request.
150150
* @returns {string} Security question hash.
151151
*/

src/error/const.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// SPDX-License-Identifier: AGPL-3.0-or-later
55

66
/**
7-
* @description Contains contants use to handle error from Django backend, legacy-listener, and new listerner structure.
7+
* @description Contains constants use to handle error from Django backend, legacy-listener, and new listener structure.
88
* logMessage: is use by winston logger in the console and the log file.
9-
* statusCode and clientMessage: are return to the app to give informations about the error to the client
9+
* statusCode and clientMessage: are return to the app to give information about the error to the client
1010
* clientMessage: is associated to a Qplus translation to display the correct message.
1111
* encrypt: In somecase we want to return an encryption error message that can't be encrypt
1212
* because of the error.

src/error/handler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ErrorHandler {
1313
/**
1414
* @description Format error throw by the listener to be uploaded to Firebase and handled by the App.
1515
* @param {object} error Error throw
16-
* @returns {object} Formated error to be upload to Firebase.
16+
* @returns {object} Formatted error to be upload to Firebase.
1717
*/
1818
static getErrorResponse(error) {
1919
const errorKey = error.message;
@@ -32,7 +32,7 @@ class ErrorHandler {
3232

3333
/**
3434
* @description Log error in console and log files using legacy Winston logger
35-
* @param {string} message Error message thown
35+
* @param {string} message Error message thrown
3636
* @param {object} errorObject Error data
3737
*/
3838
static logError(message, errorObject) {

src/test/simulate-request/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SimulateRequest {
5959
* @description Upload a mock request to firebase to be picked up by the listener
6060
* This file need to be run inside the docker container using the command:
6161
* `docker exec -it opal-listener npm run simulateRequest`
62-
* It can also be use for in tests scripts using the instanciation of the class
62+
* It can also be use for in tests scripts using the instantiation of the class
6363
* and passing the desired mock request
6464
* `new SimulateRequest(DefaultRequestData);`
6565
* Mock request data is located in `./mock-request.js`

0 commit comments

Comments
 (0)