Skip to content

Commit

Permalink
Merge branch 'skohub-io:main' into feature-webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
awagner-mainz authored Oct 4, 2023
2 parents 6bd7c5f + b498e8d commit 092c54b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build

on: push


jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: echo Using node version $(node --version)
- run: echo Using npm version $(npm --version)
- run: cp .env.sample .env

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list

- run: npm install
- run: npm run test

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ENV NODE_ENV production

WORKDIR /app

RUN mkdir uploads

RUN chown -R node:node /app

COPY --chown=node:node . .
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- uploads:/app/uploads
networks:
- reconcile-backend
restart: on-failure

volumes:
uploads:
Expand Down
2 changes: 1 addition & 1 deletion src/publishToReconciliation/buildJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const buildJSON = async (ttlString, account) => {

if (node.type === "ConceptScheme") {
dataset = node.id;
if (!node.hasOwnProperty("preferredNamespaceUri")) {
if (node?.preferredNamespaceUri === undefined) {
throw new NoPrefNamespaceUriError(
`ConceptScheme ${node.id} does not have a preferredNamespaceUri`
);
Expand Down
12 changes: 6 additions & 6 deletions src/publishToReconciliation/buildJSON.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {describe, expect, it, vi} from "vitest";
import {buildJSON} from "./buildJSON.js";
import { describe, expect, it, vi } from "vitest";
import { buildJSON } from "./buildJSON.js";
import { hcrt_jsonld } from "./__mocks__/valid/hcrt_jsonld.js";
import fs from "fs";

describe("buildJSON", () => {
it("throws error if no preferredNamespaceUri is provided", async () => {
const filePath = "./src/publishToReconciliation/__mocks__/no_prefNamespace_hcrt.ttl"
const ttlString = await fs.readFileSync(filePath).toString();
const ttlString = await fs.readFileSync(filePath).toString();
await expect(() => buildJSON(ttlString.toString(), "test")).rejects.toThrowError(/preferredNamespaceUri/i);
})

it("throws no error if no preferredNamespaceUri is provided", async () => {
it.skip("throws no error if no preferredNamespaceUri is provided", async () => {
const filePath = "./src/publishToReconciliation/__mocks__/hcrt.ttl"
const ttlString = await fs.readFileSync(filePath).toString();
const ttlString = await fs.readFileSync(filePath).toString();
const j = await buildJSON(ttlString.toString(), "test")
expect(j).toEqual(hcrt_jsonld)
})
});
});

0 comments on commit 092c54b

Please sign in to comment.