refactor: testing and file writing within
This commit is contained in:
parent
fd55670ce1
commit
a340798676
22
.github/workflows/ci.yml
vendored
Normal file
22
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
uses: ./.github/workflows/node.yml
|
||||
with:
|
||||
run: npm run lint
|
||||
test:
|
||||
uses: ./.github/workflows/node.yml
|
||||
with:
|
||||
run: npm run -- test -p 360000
|
||||
build:
|
||||
uses: ./.github/workflows/node.yml
|
||||
with:
|
||||
run: npm run build
|
18
.github/workflows/e2e.yml
vendored
18
.github/workflows/e2e.yml
vendored
|
@ -7,18 +7,6 @@ on:
|
|||
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18.x, 20.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- run: npm config set registry ${{ vars.NPM_CI_REGISTRY }}
|
||||
if: ${{ vars.NPM_CI_REGISTRY }}
|
||||
- run: npm ci
|
||||
- run: npm run -- test -t 120000 -p e2e
|
||||
uses: ./.github/workflows/node.yml
|
||||
with:
|
||||
run: npm run -- test -t 360000 -p e2e
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
name: CI
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch: {}
|
||||
workflow_call:
|
||||
inputs:
|
||||
run:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
node:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
|
@ -20,7 +20,8 @@ jobs:
|
|||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
- run: npm ${{ vars.NPM_CI_FLAGS }} ci
|
||||
- run: npm run lint
|
||||
- run: npm run test
|
||||
- run: npm run build
|
||||
- run: npm config set registry ${{ vars.NPM_CI_REGISTRY }}
|
||||
if: ${{ vars.NPM_CI_REGISTRY }}
|
||||
- run: |
|
||||
npm ci
|
||||
${{ inputs.run }}
|
|
@ -2,13 +2,14 @@ const {Buffer} = require('buffer');
|
|||
const {exec} = require('child_process');
|
||||
const {createHash} = require('crypto');
|
||||
const {createReadStream} = require('fs');
|
||||
const {cp, mkdir, writeFile} = require('fs/promises');
|
||||
const {cp, mkdir} = require('fs/promises');
|
||||
const {join} = require('path');
|
||||
|
||||
const {
|
||||
processCode,
|
||||
run,
|
||||
spawnWith,
|
||||
writeFile,
|
||||
} = require('@flecks/core/src/server');
|
||||
const Arborist = require('@npmcli/arborist');
|
||||
const {glob} = require('glob');
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "node build/tasks npm run build",
|
||||
"ci": "act -j verify",
|
||||
"dox:bump": "npm run dox:gh-pages && cd dox && git add . && git commit -m $(git -C .. rev-parse HEAD) && git push origin gh-pages",
|
||||
"dox:gh-pages": "flecks dox docusaurus && cd website && DOCUSAURUS_GENERATED_FILES_DIR_NAME=node_modules/.cache/docusaurus node_modules/.bin/docusaurus build --out-dir ../dox-tmp && cd .. && rm -rf dox/* && mv dox-tmp/* dox && rmdir dox-tmp",
|
||||
"dox:serve": "flecks dox docusaurus && cd website && DOCUSAURUS_GENERATED_FILES_DIR_NAME=node_modules/.cache/docusaurus node_modules/.bin/docusaurus build --no-minify --out-dir ../dox-tmp && node_modules/.bin/docusaurus serve --dir ../dox-tmp",
|
||||
"dox": "flecks dox docusaurus && cd website && DOCUSAURUS_GENERATED_FILES_DIR_NAME=node_modules/.cache/docusaurus node_modules/.bin/docusaurus",
|
||||
"lint": "node build/tasks npm run lint",
|
||||
"publish": "node build/publish --provenance",
|
||||
"test": "node build/tasks npm run -- test"
|
||||
"test": "node build/tasks npm run -- test",
|
||||
"verify": "act workflow_dispatch"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
|
|
|
@ -2,7 +2,6 @@ const {
|
|||
access,
|
||||
constants: {R_OK, W_OK},
|
||||
readFile,
|
||||
writeFile,
|
||||
} = require('fs/promises');
|
||||
const {
|
||||
dirname,
|
||||
|
@ -27,6 +26,7 @@ const {
|
|||
loadYml,
|
||||
lockFile,
|
||||
spawnWith,
|
||||
writeFile,
|
||||
} = require('@flecks/core/src/server');
|
||||
const chokidar = require('chokidar');
|
||||
const {glob} = require('glob');
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {createWorkspace} from '@flecks/core/build/testing';
|
||||
|
@ -7,6 +6,7 @@ import {
|
|||
pipesink,
|
||||
processCode,
|
||||
spawnWith,
|
||||
writeFile,
|
||||
} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import {mkdir, writeFile} from 'fs/promises';
|
||||
import {mkdir} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {expect} from 'chai';
|
||||
|
||||
import explicate from '@flecks/build/build/explicate';
|
||||
import Resolver from '@flecks/build/build/resolver';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
|
||||
const {
|
||||
FLECKS_CORE_ROOT = process.cwd(),
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {createWorkspace} from '@flecks/core/build/testing';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import Resolver from '@flecks/build/build/resolver';
|
||||
import {createWorkspace} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
it('uses NODE_PATH when resolving', async () => {
|
||||
const workspace = await createWorkspace();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import addPathsToYml from '@flecks/core/build/add-paths-to-yml';
|
||||
import {loadYml} from '@flecks/core/server';
|
||||
import {loadYml, writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
import {readFile, writeFile} from 'fs/promises';
|
||||
import {readFile} from 'fs/promises';
|
||||
|
||||
it('can add paths to YML', async () => {
|
||||
await writeFile(
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const {readFile, writeFile} = require('fs/promises');
|
||||
const {readFile} = require('fs/promises');
|
||||
const {join} = require('path');
|
||||
|
||||
const {dump: dumpYml, load: loadYml} = require('js-yaml');
|
||||
|
||||
const {writeFile} = require('../src/server/fs');
|
||||
|
||||
const {
|
||||
FLECKS_CORE_ROOT = process.cwd(),
|
||||
} = process.env;
|
||||
|
|
17
packages/core/src/server/fs.js
Normal file
17
packages/core/src/server/fs.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const {open, writeFile} = require('fs/promises');
|
||||
|
||||
exports.writeFile = async (
|
||||
path,
|
||||
content,
|
||||
paramaterizedOptions,
|
||||
) => {
|
||||
const options = {
|
||||
flags: 'w',
|
||||
mode: 0o666,
|
||||
...paramaterizedOptions,
|
||||
};
|
||||
const filehandle = await open(path, options.flags, options.mode);
|
||||
await writeFile(filehandle, content, options);
|
||||
await filehandle.sync();
|
||||
await filehandle.close();
|
||||
};
|
|
@ -7,6 +7,7 @@ module.exports = {
|
|||
glob: require('glob').glob,
|
||||
loadYml,
|
||||
...require('../../build/stream'),
|
||||
...require('./fs'),
|
||||
...require('./package-manager'),
|
||||
...require('./process'),
|
||||
};
|
||||
|
|
17
packages/core/test/server/write-files.js
Normal file
17
packages/core/test/server/write-files.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* eslint-disable camelcase */
|
||||
|
||||
import {access} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {createWorkspace} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
|
||||
it('writes files', async () => {
|
||||
const workspace = await createWorkspace();
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
const path = join(workspace, `${i}`);
|
||||
await writeFile(path, '');
|
||||
await access(path);
|
||||
}
|
||||
});
|
|
@ -16,9 +16,6 @@ before(heavySetup(async () => {
|
|||
artifact = true;
|
||||
}
|
||||
catch (error) {
|
||||
// intermittent failure...
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
artifact = false;
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -16,8 +16,6 @@ before(heavySetup(async () => {
|
|||
artifact = true;
|
||||
}
|
||||
catch (error) {
|
||||
// intermittent failure...
|
||||
console.error(error); // eslint-disable-line no-console
|
||||
artifact = false;
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {heavySetup} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {build, createApplication} from './build/build';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {heavySetup} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {buildChild, createApplication} from './build/build';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {heavySetup} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {build, createApplication} from './build/build';
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import {mkdir, writeFile} from 'fs/promises';
|
||||
import {mkdir} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {heavySetup} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {build, createApplication, serverActions} from './build/build';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {heavySetup} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {build, createApplication, serverActions} from './build/build';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
|
||||
import {heavySetup} from '@flecks/core/build/testing';
|
||||
import {writeFile} from '@flecks/core/server';
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {buildChild, createApplication} from './build/build';
|
||||
|
|
Loading…
Reference in New Issue
Block a user