Skip to content

Commit

Permalink
Node 16 (#4974)
Browse files Browse the repository at this point in the history
* upgrade nvmrc and a couple of packages

* use nodejs version from .nvmrc on github workflows

* fix spec

* fix ci_e2e_puppeteer workflow

* fix testsuite

* downgrade to 16.10
  • Loading branch information
daneryl authored Aug 5, 2022
1 parent 999031c commit 638fa9f
Show file tree
Hide file tree
Showing 17 changed files with 568 additions and 270 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci_check_translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
ports:
- 27017/tcp
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_e2e_puppeteer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- 27017/tcp
steps:
- name: Checkout reposistory
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Setup Nodejs
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci_eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_legacy_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
ports:
- 27017/tcp
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Nodejs
uses: actions/setup-node@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci_ts_emit_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
check-emitted-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci_ts_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
check-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
MINIO_ROOT_PASSWORD: minioadmin
options: --name=minio --health-cmd "curl http://localhost:9000/minio/health/live"
steps:
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
- uses: actions/checkout@v2
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -75,11 +75,11 @@ jobs:
app_unit_tests:
runs-on: ubuntu-latest
steps:
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
- uses: actions/checkout@v2
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create_pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
with:
ref: 'staging'
fetch-depth: 0
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/[email protected]
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
with:
ref: 'production'
fetch-depth: 0
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/[email protected]
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/security_audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
yarn-audit:
runs-on: ubuntu-latest
steps:
- name: Use Node.js 14.18.3
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.18.3'
- uses: actions/checkout@v2
node-version-file: '.nvmrc'
- name: Cache node modules
uses: actions/cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.18.3
16.10.0
3 changes: 2 additions & 1 deletion app/api/files/exportRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export default (app: Application) => {

await exporter.export(results, req.query.types, fileStream, exporterOptions);

res.download(temporalFilePath, generateExportFileName(site_name), () => {
res.download(temporalFilePath, generateExportFileName(site_name), err => {
if (err) next(err);
//eslint-disable-next-line @typescript-eslint/no-floating-promises
removeTempFile(temporalFilePath)();
});
Expand Down
11 changes: 9 additions & 2 deletions app/api/files/specs/exportRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Writable } from 'stream';
import request from 'supertest';
import { setUpApp } from 'api/utils/testingRoutes';
import { search } from 'api/search';
import csvExporter from 'api/csv/csvExporter';
import csvExporter, { SearchResults } from 'api/csv/csvExporter';
import * as filesystem from 'api/files/filesystem';
import { NextFunction, Request, Response } from 'express';
import authMiddleware from 'api/auth/authMiddleware';
Expand Down Expand Up @@ -48,7 +48,14 @@ describe('export routes', () => {
};
await testingEnvironment.setUp(fixtures);

exportMock = jest.fn().mockImplementation(async () => Promise.resolve());
exportMock = jest.fn().mockImplementation(
async (_searchResults: SearchResults, _types: string[] = [], writeStream: Writable) =>
new Promise(resolve => {
writeStream.write('content');
writeStream.on('finish', resolve);
writeStream.end();
})
);
(csvExporter as any).mockImplementation(() => ({
export: exportMock,
}));
Expand Down
7 changes: 3 additions & 4 deletions app/api/files/uwaziFS.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//eslint-disable-next-line node/no-restricted-import
import fs from 'fs';

const { createWriteStream, createReadStream } = fs;
import { createReadStream, createWriteStream } from 'fs';
import fs from 'fs/promises';

const uwaziFS = {
...fs.promises,
...fs,
createWriteStream,
createReadStream,
};
Expand Down
15 changes: 13 additions & 2 deletions app/api/services/pdfsegmentation/specs/PDFSegmentation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ import { ExternalDummyService } from '../../tasksmanager/specs/ExternalDummyServ

jest.mock('api/services/tasksmanager/TaskManager.ts');

const deleteFolder = async (folderPath: string) => {
try {
await fs.rm(folderPath, { recursive: true });
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
};

describe('PDFSegmentation', () => {
let segmentPdfs: PDFSegmentation;

Expand Down Expand Up @@ -206,7 +216,7 @@ describe('PDFSegmentation', () => {
await fixturer.clearAllAndLoad(dbOne, fixturesOneFile);
await segmentPdfs.segmentPdfs();
segmentationFolder = path.join(tenantOne.uploadedDocuments, 'segmentation');
await fs.rmdir(segmentationFolder, { recursive: true });
await deleteFolder(segmentationFolder);
segmentationExternalService = new ExternalDummyService(1235);
await segmentationExternalService.start();

Expand All @@ -230,8 +240,9 @@ describe('PDFSegmentation', () => {

afterEach(async () => {
await segmentationExternalService.stop();
await fs.rmdir(segmentationFolder, { recursive: true });
await deleteFolder(segmentationFolder);
});

it('should store the segmentation', async () => {
await segmentPdfs.processResults({
tenant: tenantOne.name,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@
"nightmare-real-mouse": "^1.1.0",
"nightmare-upload": "^0.1.1",
"node-polyfill-webpack-plugin": "^2.0.0",
"node-sass": "4.14.1",
"node-sass": "7.0.1",
"nodemon": "^2.0.19",
"plop": "^2.7.6",
"prettier": "2.5.1",
"puppeteer": "^13.5.2",
"react-dnd-test-backend": "15.1.1",
"redux-mock-store": "^1.5.4",
"rtlcss-webpack-plugin": "4.0.7",
"sass-loader": "10.0.2",
"sass-loader": "10.3.1",
"sharp": "^0.30.6",
"stream-mock": "^2.0.5",
"supertest": "6.2.3",
Expand Down
Loading

0 comments on commit 638fa9f

Please sign in to comment.