Add tests as a Docker build step to ensure no container with failing tests can be published

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-08-02 21:32:58 +01:00
parent ab2aa09861
commit 5504439ce0
5 changed files with 17 additions and 25 deletions

View File

@ -3,6 +3,8 @@ WORKDIR /usr/src/app
COPY ./package*.json ./
RUN npm i
COPY . .
# Ideally the tests should be run separately in a CI/CD workflow rather than during the build
RUN npm run test
RUN npm run build
FROM node:20-slim

22
package-lock.json generated
View File

@ -24,7 +24,7 @@
"zlib": "^1.0.5"
},
"devDependencies": {
"@owlboard/ts-types": "^0.0.3",
"@owlboard/ts-types": "^0.0.5",
"@types/jest": "^29.5.3",
"eslint": "^8.39.0",
"jest": "^29.6.2",
@ -1855,9 +1855,9 @@
}
},
"node_modules/@owlboard/ts-types": {
"version": "0.0.3",
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fts-types/-/0.0.3/ts-types-0.0.3.tgz",
"integrity": "sha512-7PvFVNzYhIRsYxGPWLQVg1ldMSI0H6a5DA0WJ8dNT3boL+PREZybxA4rWUUKkcND+ct/nO8xax2SODYcWjY7Hw==",
"version": "0.0.5",
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fts-types/-/0.0.5/ts-types-0.0.5.tgz",
"integrity": "sha512-MuQlBydSXjHZIKQa6RgCdvDwHjFfG1wJXHioXPQno6GEdsxaDDoN06JCDkPf/l+hPjK/jMYrNNmVI1l5ZorYcg==",
"dev": true,
"license": "GPL-3.0-or-later"
},
@ -3964,20 +3964,6 @@
"dev": true,
"license": "ISC"
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"license": "MIT"

View File

@ -31,7 +31,7 @@
"zlib": "^1.0.5"
},
"devDependencies": {
"@owlboard/ts-types": "^0.0.3",
"@owlboard/ts-types": "^0.0.5",
"@types/jest": "^29.5.3",
"eslint": "^8.39.0",
"jest": "^29.6.2",

View File

@ -89,10 +89,11 @@ function transformTrainServices(input: any): TrainServices[] {
function transformLocation(input: any): ServiceLocation[] {
console.debug(`staffStation.transformLocation running`)
let output: ServiceLocation[] = []
if (!Array.isArray(input)) {
input = [input]
let locations: any[] = input.location
if (!Array.isArray(input.location)) {
locations = [input.location]
}
for (const item of input) {
for (const item of locations) {
const location: ServiceLocation = {
tiploc: item?.tiploc,
name: item?.locationName

View File

@ -1,4 +1,7 @@
export const outputs: any[] = [
import type { StaffLdb, NrccMessage, TrainServices,
ServiceLocation } from '@owlboard/ts-types';
export const outputs: StaffLdb[] = [
{
generatedAt: expect.any(Date),
locationName: "Railway Station",
@ -25,13 +28,13 @@ export const outputs: any[] = [
origin: [
{
tiploc: "PLYMTH",
locationName: "Plymouth"
name: "Plymouth"
}
],
destination: [
{
tiploc: "BHAMNWS",
locationName: "Birmingham New Street"
name: "Birmingham New Street"
}
]
}