Skip to content

Commit 954f6bf

Browse files
peaceiriscodex
andauthored
chore: update Node runtime and dependencies (#1147)
Co-authored-by: Codex <noreply@openai.com>
1 parent a1f94b5 commit 954f6bf

15 files changed

Lines changed: 7030 additions & 4834 deletions

.eslintrc.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
1516

1617
jobs:
1718
test:
@@ -20,7 +21,7 @@ jobs:
2021
matrix:
2122
os:
2223
- 'ubuntu-22.04'
23-
- 'ubuntu-20.04'
24+
- 'ubuntu-24.04'
2425
- 'ubuntu-latest'
2526
- 'macos-latest'
2627
- 'windows-latest'
@@ -29,9 +30,10 @@ jobs:
2930
steps:
3031
- uses: actions/checkout@v4
3132

32-
- uses: peaceiris/workflows/setup-node@v0.20.1
33+
- uses: actions/setup-node@v4
3334
with:
3435
node-version-file: ".nvmrc"
36+
cache: 'npm'
3537

3638
- name: Dump version
3739
run: |
@@ -68,7 +70,7 @@ jobs:
6870

6971
- uses: codecov/codecov-action@v4
7072

71-
- name: Run ncc
73+
- name: Run build
7274
run: npm run build
7375

7476
- name: Remove lint-staged husky

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.11.1
1+
24

__tests__/jest.setup.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import path from 'path';
2+
import fs from 'fs';
3+
import os from 'os';
4+
import {fileURLToPath} from 'url';
5+
import {jest} from '@jest/globals';
6+
7+
const testDir = path.dirname(fileURLToPath(import.meta.url));
8+
const testHome = path.join(os.tmpdir(), 'actions-gh-pages-test-home');
9+
fs.mkdirSync(testHome, {recursive: true});
10+
11+
if (process.platform === 'win32') {
12+
process.env.USERPROFILE = process.env.USERPROFILE || testHome;
13+
} else {
14+
process.env.HOME = testHome;
15+
}
16+
17+
globalThis.jest = jest;
18+
globalThis.__dirname = testDir;

__tests__/utils.test.ts

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,15 @@ async function getTime(): Promise<string> {
2525

2626
describe('getHomeDir()', () => {
2727
test('get home directory name', async () => {
28-
let test = '';
29-
if (process.platform === 'win32') {
30-
test = 'C:\\Users\\runneradmin';
31-
} else {
32-
test = `${process.env.HOME}`;
33-
}
28+
const test = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
3429
const expected = await getHomeDir();
3530
expect(test).toMatch(expected);
3631
});
3732
});
3833

3934
describe('getWorkDirName()', () => {
4035
test('get work directory name', async () => {
41-
let home = '';
42-
if (process.platform === 'win32') {
43-
home = 'C:\\Users\\runneradmin';
44-
} else {
45-
home = `${process.env.HOME}`;
46-
}
36+
const home = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
4737
const unixTime = await getTime();
4838
const expected = path.join(home, `actions_github_pages_${unixTime}`);
4939
const test = await getWorkDirName(`${unixTime}`);
@@ -63,18 +53,14 @@ describe('createDir()', () => {
6353

6454
async function getWorkDir(): Promise<string> {
6555
const unixTime = await getTime();
66-
let workDir = '';
67-
workDir = await getWorkDirName(`${unixTime}`);
56+
const workDir = await getWorkDirName(`${unixTime}`);
6857
await createDir(workDir);
6958
return workDir;
7059
}
7160

7261
describe('addNoJekyll()', () => {
7362
test('add .nojekyll', async () => {
74-
let workDir = '';
75-
(async (): Promise<void> => {
76-
workDir = await getWorkDir();
77-
})();
63+
const workDir = await getWorkDir();
7864
const filepath = path.join(workDir, '.nojekyll');
7965

8066
await addNoJekyll(workDir, false);
@@ -85,10 +71,7 @@ describe('addNoJekyll()', () => {
8571
});
8672

8773
test('.nojekyll already exists', async () => {
88-
let workDir = '';
89-
(async (): Promise<void> => {
90-
workDir = await getWorkDir();
91-
})();
74+
const workDir = await getWorkDir();
9275
const filepath = path.join(workDir, '.nojekyll');
9376
fs.closeSync(fs.openSync(filepath, 'w'));
9477

@@ -100,10 +83,7 @@ describe('addNoJekyll()', () => {
10083
});
10184

10285
test('not add .nojekyll disable_nojekyll', async () => {
103-
let workDir = '';
104-
(async (): Promise<void> => {
105-
workDir = await getWorkDir();
106-
})();
86+
const workDir = await getWorkDir();
10787
const filepath = path.join(workDir, '.nojekyll');
10888

10989
await addNoJekyll(workDir, true);
@@ -114,10 +94,7 @@ describe('addNoJekyll()', () => {
11494

11595
describe('addCNAME()', () => {
11696
test('add CNAME', async () => {
117-
let workDir = '';
118-
(async (): Promise<void> => {
119-
workDir = await getWorkDir();
120-
})();
97+
const workDir = await getWorkDir();
12198
const filepath = path.join(workDir, 'CNAME');
12299

123100
await addCNAME(workDir, 'github.com');
@@ -128,10 +105,7 @@ describe('addCNAME()', () => {
128105
});
129106

130107
test('do nothing', async () => {
131-
let workDir = '';
132-
(async (): Promise<void> => {
133-
workDir = await getWorkDir();
134-
})();
108+
const workDir = await getWorkDir();
135109
const filepath = path.join(workDir, 'CNAME');
136110

137111
await addCNAME(workDir, '');
@@ -140,10 +114,7 @@ describe('addCNAME()', () => {
140114
});
141115

142116
test('CNAME already exists', async () => {
143-
let workDir = '';
144-
(async (): Promise<void> => {
145-
workDir = await getWorkDir();
146-
})();
117+
const workDir = await getWorkDir();
147118
const filepath = path.join(workDir, 'CNAME');
148119

149120
await addCNAME(workDir, 'github.io');

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'GitHub Pages action'
22
description: 'GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.'
33
author: 'peaceiris'
44
runs:
5-
using: 'node20'
5+
using: 'node24'
66
main: 'lib/index.js'
77
branding:
88
icon: 'upload-cloud'

eslint.config.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin';
4+
import jestPlugin from 'eslint-plugin-jest';
5+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
6+
7+
export default [
8+
{
9+
ignores: ['coverage/**', 'lib/**', 'node_modules/**']
10+
},
11+
js.configs.recommended,
12+
...tsPlugin.configs['flat/recommended'],
13+
{
14+
files: ['src/**/*.ts', '__tests__/**/*.ts'],
15+
languageOptions: {
16+
ecmaVersion: 2022,
17+
globals: {
18+
...globals.es2022,
19+
...globals.node
20+
},
21+
sourceType: 'module'
22+
}
23+
},
24+
{
25+
files: ['__tests__/**/*.ts'],
26+
...jestPlugin.configs['flat/recommended']
27+
},
28+
prettierRecommended
29+
];

jest.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
module.exports = {
22
clearMocks: true,
3+
extensionsToTreatAsEsm: ['.ts'],
34
moduleFileExtensions: ['js', 'ts'],
5+
setupFiles: ['<rootDir>/__tests__/jest.setup.mjs'],
46
testEnvironment: 'node',
57
testMatch: ['**/*.test.ts'],
68
testRunner: 'jest-circus/runner',
79
transform: {
8-
'^.+\\.ts$': 'ts-jest'
10+
'^.+\\.ts$': [
11+
'ts-jest',
12+
{
13+
tsconfig: {
14+
module: 'ES2022',
15+
target: 'ES2022'
16+
},
17+
useESM: true
18+
}
19+
]
920
},
1021
verbose: true
1122
};

0 commit comments

Comments
 (0)