Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/bree v8 #8

Merged
merged 3 commits into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
os:
- ubuntu-latest
node_version:
- 12
- 14
- 16
- 18

name: Node ${{ matrix.node_version }} on ${{ matrix.os }}

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ async function get(ctx) {
body = body.map((j) => {
j.status = 'done';

if (bree.workers[j.name]) j.status = 'active';
else if (bree.timeouts[j.name]) j.status = 'delayed';
else if (bree.intervals[j.name]) j.status = 'waiting';
if (bree.workers.has(j.name)) j.status = 'active';
else if (bree.timeouts.has(j.name)) j.status = 'delayed';
else if (bree.intervals.has(j.name)) j.status = 'waiting';

return j;
});
Expand Down
41 changes: 22 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@
]
},
"dependencies": {
"@hapi/boom": "^9.1.1",
"@hapi/boom": "^10.0.0",
"@koa/router": "^10.0.0",
"@ladjs/api": "^6.0.0",
"@ladjs/api": "^9.0.2",
"@ladjs/env": "^3.0.0",
"@ladjs/graceful": "^1.0.5",
"@ladjs/shared-config": "^4.0.0",
"@ladjs/graceful": "^2.0.1",
"@ladjs/shared-config": "^7.0.3",
"@slack/web-api": "^6.0.0",
"axe": "^8.0.0",
"crypto-random-string": "^3.3.1",
"crypto-random-string": "^5.0.0",
"del": "^6.0.0",
"humanize-string": "^2.1.0",
"humanize-string": "^3.0.0",
"ip": "^1.1.5",
"koa-jwt": "^4.0.1",
"lodash": "^4.17.20",
"markdown-it": "^12.0.4",
"markdown-it": "^13.0.1",
"markdown-it-emoji": "^2.0.0",
"markdown-it-github-headings": "^2.0.0",
"markdown-it-highlightjs": "^3.4.0",
"markdown-it-highlightjs": "^4.0.1",
"markdown-it-task-checkbox": "^1.0.6",
"pino": "^6.11.1",
"pino": "^8.0.0",
"signale": "^1.4.0"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"ava": "^3.15.0",
"bree": "^6.3.0",
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"ava": "^4.3.0",
"bree": "^8.0.0",
"codecov": "^3.8.1",
"delay": "^5.0.0",
"eslint": "^7.19.0",
"eslint": "^8.17.0",
"eslint-config-xo-lass": "^1.0.5",
"eslint-formatter-pretty": "^4.0.0",
"eslint-plugin-compat": "^3.9.0",
"eslint-plugin-compat": "^4.0.2",
"eslint-plugin-no-smart-quotes": "^1.1.0",
"fixpack": "^4.0.0",
"get-port": "^5.1.1",
Expand All @@ -62,9 +62,9 @@
"gulp-livereload": "^4.0.2",
"gulp-remark": "^9.0.0",
"gulp-xo": "^0.25.0",
"husky": "^5.0.9",
"husky": "^8.0.1",
"jsonwebtoken": "^8.5.1",
"lint-staged": "10.5.4",
"lint-staged": "13.0.0",
"make-dir": "^3.1.0",
"ms": "^2.1.3",
"nodemon": "^2.0.7",
Expand All @@ -77,10 +77,10 @@
"remark-cli": "^9.0.0",
"remark-preset-github": "^4.0.1",
"supertest": "^6.1.3",
"xo": "^0.37.1"
"xo": "^0.49.0"
},
"engines": {
"node": ">=12.11.0"
"node": ">=14"
},
"homepage": "https://github.com/breejs/api",
"husky": {
Expand All @@ -104,6 +104,9 @@
"test/**"
]
},
"peerDependencies": {
"bree": "~8.0"
},
"prettier": {
"singleQuote": true,
"bracketSpacing": true,
Expand Down
10 changes: 6 additions & 4 deletions test/api/v1/jobs/get.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const { once } = require('events');
const test = require('ava');
const jwt = require('jsonwebtoken');
const path = require('path');
const delay = require('delay');

const config = require('../../../../config');
Expand Down Expand Up @@ -36,10 +37,11 @@ test.before(async (t) => {
t.context.bree.start();
});

test('successfully', async (t) => {
test.serial('successfully', async (t) => {
const { api, bree } = t.context;

await delay(300);
// wait until the first worker finishes so our expect is correctly timed
await once(bree, 'worker deleted');

const res = await api.get(rootUrl);

Expand Down Expand Up @@ -68,7 +70,7 @@ test('successfully filter by name', async (t) => {
);
});

test('successfully filter by status', async (t) => {
test.serial('successfully filter by status', async (t) => {
const { api, bree } = t.context;

await delay(200);
Expand Down
12 changes: 6 additions & 6 deletions test/api/v1/jobs/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('successfully add one job', async (t) => {

t.truthy(bree.config.jobs.find((j) => j.name === 'successfulOne'));
// ensure job hasn't been started
t.falsy(bree.workers.successfulOne);
t.falsy(bree.workers.has('successfulOne'));
});

test('successfully add multiple jobs', async (t) => {
Expand Down Expand Up @@ -66,9 +66,9 @@ test('successfully add multiple jobs', async (t) => {
t.truthy(bree.config.jobs.find((j) => j.name === 'array2'));
t.truthy(bree.config.jobs.find((j) => j.name === 'array3'));
// ensure job hasn't been started
t.falsy(bree.workers.array1);
t.falsy(bree.workers.array2);
t.falsy(bree.workers.array3);
t.falsy(bree.workers.has('array1'));
t.falsy(bree.workers.has('array2'));
t.falsy(bree.workers.has('array3'));
});

test('fails if data is bad', async (t) => {
Expand Down Expand Up @@ -100,7 +100,7 @@ test('successfully auto start job', async (t) => {

t.truthy(bree.config.jobs.find((j) => j.name === 'auto-start'));
// ensure job hasn't been started
t.truthy(bree.workers['auto-start']);
t.truthy(bree.workers.has('auto-start'));
});

test('successfully duplicate job', async (t) => {
Expand All @@ -121,5 +121,5 @@ test('successfully duplicate job', async (t) => {

t.truthy(bree.config.jobs.find((j) => j.name === 'orig(2)'));

t.falsy(bree.workers['orig(2)']);
t.falsy(bree.workers.has('org(2)'));
});
8 changes: 4 additions & 4 deletions test/api/v1/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ test('successfully run named job', async (t) => {

await delay(200);

t.falsy(bree.workers.active);
t.falsy(bree.intervals.waiting);
t.falsy(bree.timeouts.delayed);
t.truthy(bree.workers.delayed);
t.falsy(bree.workers.has('active'));
t.falsy(bree.intervals.has('waiting'));
t.falsy(bree.timeouts.has('delayed'));
t.truthy(bree.workers.has('delayed'));
});
10 changes: 5 additions & 5 deletions test/api/v1/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ test.serial('successfully start all jobs', async (t) => {

await delay(200);

t.truthy(bree.workers.active);
t.truthy(bree.timeouts.delayed);
t.truthy(bree.intervals.waiting);
t.truthy(bree.workers.has('active'));
t.truthy(bree.timeouts.has('delayed'));
t.truthy(bree.intervals.has('waiting'));
});

test.serial('successfully start named job', async (t) => {
Expand Down Expand Up @@ -73,6 +73,6 @@ test.serial('successfully start named job', async (t) => {

await delay(200);

t.falsy(bree.workers.immediate);
t.truthy(bree.timeouts.timeout);
t.falsy(bree.workers.has('immediate'));
t.truthy(bree.timeouts.has('timeout'));
});
14 changes: 7 additions & 7 deletions test/api/v1/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ test.before(async (t) => {
test.serial('successfully stop named job', async (t) => {
const { api, bree } = t.context;

t.truthy(bree.workers.active);
t.truthy(bree.workers.has('active'));

const res = await api.post(`${rootUrl}/active`).send({});

t.is(res.status, 200);

t.falsy(bree.workers.active);
t.falsy(bree.workers.has('active'));
});

test.serial('successfully stop all jobs', async (t) => {
const { bree, api } = t.context;

t.not(Object.values(bree.timeouts).length, 0);
t.not(Object.values(bree.intervals).length, 0);
t.not(bree.timeouts.size, 0);
t.not(bree.intervals.size, 0);

const res = await api.post(rootUrl).send({});

t.is(res.status, 200);

t.is(Object.values(bree.workers).length, 0);
t.is(Object.values(bree.timeouts).length, 0);
t.is(Object.values(bree.intervals).length, 0);
t.is(bree.workers.size, 0);
t.is(bree.timeouts.size, 0);
t.is(bree.intervals.size, 0);
});
Loading