Skip to content

Commit

Permalink
Merge pull request #68 from pkgjs/modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Nov 6, 2023
2 parents 49e52bd + b70b07f commit e462000
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 264 deletions.
1 change: 0 additions & 1 deletion .github/actions/prepare-dynamic-steps/.gitignore

This file was deleted.

10 changes: 2 additions & 8 deletions .github/actions/prepare-dynamic-steps/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
'use strict';

process.on('unhandledRejection', (err) => {

throw err;
});


const ActionsCore = require('@actions/core');
const Fs = require('fs');
const Path = require('path');
const Fs = require('node:fs');
const Path = require('node:path');
const Yaml = require('yaml');


Expand Down
43 changes: 21 additions & 22 deletions .github/actions/prepare-dynamic-steps/test/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict';

process.on('unhandledRejection', (err) => {
const Assert = require('node:assert');
const Fs = require('node:fs');
const Os = require('node:os');
const Path = require('node:path');
const { describe, it, beforeEach } = require('node:test');

throw err;
});


const Assert = require('assert');
const Fs = require('fs');
const Path = require('path');
const PrepareDynamicStepsAction = require('..');


Expand All @@ -20,34 +17,36 @@ runs:
- run: echo ohai again
`;


exports.main = function () {
describe('PrepareDynamicStepsAction', () => {

const originalEnv = { ...process.env };

const tmpFolder = Path.join(__dirname, '.tmp', `${Date.now()}`);
let tmpFolder;

beforeEach(() => {

try {
tmpFolder = Fs.mkdtempSync(`${Os.tmpdir()}${Path.sep}prepare-dynamic-steps-action-test-`);

Fs.mkdirSync(tmpFolder, { recursive: true });
process.chdir(tmpFolder);
});

it('creates a file when INPUT_STEPS contains valid yaml', () => {

process.env = { ...originalEnv, INPUT_PATH: 'test1', INPUT_STEPS: '- run: echo ohai\n- run: echo ohai again' };
PrepareDynamicStepsAction.main();
Assert.strictEqual(Fs.readFileSync(Path.join(tmpFolder, '.github', 'tmp', 'test1', 'action.yaml')).toString().trim(), expectedResult1.trim());
});

it('throws when INPUT_STEPS contains invalid yaml', () => {

process.env = { ...originalEnv, INPUT_PATH: 'test2', INPUT_STEPS: '- item\n-invalid' };
Assert.throws(() => PrepareDynamicStepsAction.main(), { message: 'Invalid `steps` - unable to parse YAML.' });
});

it('throws when INPUT_STEPS does not contain an array', () => {

process.env = { ...originalEnv, INPUT_PATH: 'test3', INPUT_STEPS: 'not an array' };
Assert.throws(() => PrepareDynamicStepsAction.main(), { message: 'Invalid `steps` - not an array.' });
}
finally {
Fs.rmSync(Path.join(__dirname, '.tmp'), { recursive: true });
}
};


if (require.main === module) {
exports.main();
}
});
});
10 changes: 2 additions & 8 deletions .github/actions/prepare-node-test-matrix-action/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
'use strict';

process.on('unhandledRejection', (err) => {

throw err;
});


const ActionsCore = require('@actions/core');
const Path = require('path');
const Path = require('node:path');
const Schedule = require('./schedule.json'); // https://raw.githubusercontent.com/nodejs/Release/master/schedule.json
const Semver = require('semver');
const Yaml = require('yaml');
Expand Down Expand Up @@ -57,7 +51,7 @@ internals.normalizeRunsOn = function (runsOnInput) {

exports.main = function ({ now = new Date(), pkg = Package, debug = console.info } = {}) {

if (!pkg.engines || !pkg.engines.node) {
if (!pkg.engines?.node) {
throw new Error('`engines.node` range not defined in `package.json`.');
}

Expand Down
26 changes: 25 additions & 1 deletion .github/actions/prepare-node-test-matrix-action/schedule.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"lts": "2022-10-25",
"maintenance": "2023-10-18",
"end": "2025-04-30",
"codename": ""
"codename": "Hydrogen"
},
"v19": {
"start": "2022-10-18",
Expand All @@ -112,6 +112,30 @@
"lts": "2023-10-24",
"maintenance": "2024-10-22",
"end": "2026-04-30",
"codename": "Iron"
},
"v21": {
"start": "2023-10-17",
"maintenance": "2024-04-01",
"end": "2024-06-01"
},
"v22": {
"start": "2024-04-23",
"lts": "2024-10-29",
"maintenance": "2025-10-21",
"end": "2027-04-30",
"codename": ""
},
"v23": {
"start": "2024-10-15",
"maintenance": "2025-04-01",
"end": "2025-06-01"
},
"v24": {
"start": "2025-04-22",
"lts": "2025-10-28",
"maintenance": "2026-10-20",
"end": "2028-04-30",
"codename": ""
}
}
Loading

0 comments on commit e462000

Please sign in to comment.