Skip to content

Commit e462000

Browse files
authored
Merge pull request #68 from pkgjs/modernize
2 parents 49e52bd + b70b07f commit e462000

6 files changed

Lines changed: 320 additions & 264 deletions

File tree

.github/actions/prepare-dynamic-steps/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/actions/prepare-dynamic-steps/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
'use strict';
22

3-
process.on('unhandledRejection', (err) => {
4-
5-
throw err;
6-
});
7-
8-
93
const ActionsCore = require('@actions/core');
10-
const Fs = require('fs');
11-
const Path = require('path');
4+
const Fs = require('node:fs');
5+
const Path = require('node:path');
126
const Yaml = require('yaml');
137

148

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
'use strict';
22

3-
process.on('unhandledRejection', (err) => {
3+
const Assert = require('node:assert');
4+
const Fs = require('node:fs');
5+
const Os = require('node:os');
6+
const Path = require('node:path');
7+
const { describe, it, beforeEach } = require('node:test');
48

5-
throw err;
6-
});
7-
8-
9-
const Assert = require('assert');
10-
const Fs = require('fs');
11-
const Path = require('path');
129
const PrepareDynamicStepsAction = require('..');
1310

1411

@@ -20,34 +17,36 @@ runs:
2017
- run: echo ohai again
2118
`;
2219

23-
24-
exports.main = function () {
20+
describe('PrepareDynamicStepsAction', () => {
2521

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

28-
const tmpFolder = Path.join(__dirname, '.tmp', `${Date.now()}`);
24+
let tmpFolder;
25+
26+
beforeEach(() => {
2927

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

3230
Fs.mkdirSync(tmpFolder, { recursive: true });
3331
process.chdir(tmpFolder);
32+
});
33+
34+
it('creates a file when INPUT_STEPS contains valid yaml', () => {
3435

3536
process.env = { ...originalEnv, INPUT_PATH: 'test1', INPUT_STEPS: '- run: echo ohai\n- run: echo ohai again' };
3637
PrepareDynamicStepsAction.main();
3738
Assert.strictEqual(Fs.readFileSync(Path.join(tmpFolder, '.github', 'tmp', 'test1', 'action.yaml')).toString().trim(), expectedResult1.trim());
39+
});
40+
41+
it('throws when INPUT_STEPS contains invalid yaml', () => {
3842

3943
process.env = { ...originalEnv, INPUT_PATH: 'test2', INPUT_STEPS: '- item\n-invalid' };
4044
Assert.throws(() => PrepareDynamicStepsAction.main(), { message: 'Invalid `steps` - unable to parse YAML.' });
45+
});
46+
47+
it('throws when INPUT_STEPS does not contain an array', () => {
4148

4249
process.env = { ...originalEnv, INPUT_PATH: 'test3', INPUT_STEPS: 'not an array' };
4350
Assert.throws(() => PrepareDynamicStepsAction.main(), { message: 'Invalid `steps` - not an array.' });
44-
}
45-
finally {
46-
Fs.rmSync(Path.join(__dirname, '.tmp'), { recursive: true });
47-
}
48-
};
49-
50-
51-
if (require.main === module) {
52-
exports.main();
53-
}
51+
});
52+
});

.github/actions/prepare-node-test-matrix-action/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
'use strict';
22

3-
process.on('unhandledRejection', (err) => {
4-
5-
throw err;
6-
});
7-
8-
93
const ActionsCore = require('@actions/core');
10-
const Path = require('path');
4+
const Path = require('node:path');
115
const Schedule = require('./schedule.json'); // https://raw.githubusercontent.com/nodejs/Release/master/schedule.json
126
const Semver = require('semver');
137
const Yaml = require('yaml');
@@ -57,7 +51,7 @@ internals.normalizeRunsOn = function (runsOnInput) {
5751

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

60-
if (!pkg.engines || !pkg.engines.node) {
54+
if (!pkg.engines?.node) {
6155
throw new Error('`engines.node` range not defined in `package.json`.');
6256
}
6357

.github/actions/prepare-node-test-matrix-action/schedule.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"lts": "2022-10-25",
101101
"maintenance": "2023-10-18",
102102
"end": "2025-04-30",
103-
"codename": ""
103+
"codename": "Hydrogen"
104104
},
105105
"v19": {
106106
"start": "2022-10-18",
@@ -112,6 +112,30 @@
112112
"lts": "2023-10-24",
113113
"maintenance": "2024-10-22",
114114
"end": "2026-04-30",
115+
"codename": "Iron"
116+
},
117+
"v21": {
118+
"start": "2023-10-17",
119+
"maintenance": "2024-04-01",
120+
"end": "2024-06-01"
121+
},
122+
"v22": {
123+
"start": "2024-04-23",
124+
"lts": "2024-10-29",
125+
"maintenance": "2025-10-21",
126+
"end": "2027-04-30",
127+
"codename": ""
128+
},
129+
"v23": {
130+
"start": "2024-10-15",
131+
"maintenance": "2025-04-01",
132+
"end": "2025-06-01"
133+
},
134+
"v24": {
135+
"start": "2025-04-22",
136+
"lts": "2025-10-28",
137+
"maintenance": "2026-10-20",
138+
"end": "2028-04-30",
115139
"codename": ""
116140
}
117141
}

0 commit comments

Comments
 (0)