Skip to content
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
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
Expand All @@ -20,7 +21,7 @@ jobs:
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-20.04'
- 'ubuntu-24.04'
- 'ubuntu-latest'
- 'macos-latest'
- 'windows-latest'
Expand All @@ -29,9 +30,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: peaceiris/workflows/setup-node@v0.20.1
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: 'npm'

- name: Dump version
run: |
Expand Down Expand Up @@ -68,7 +70,7 @@ jobs:

- uses: codecov/codecov-action@v4

- name: Run ncc
- name: Run build
run: npm run build

- name: Remove lint-staged husky
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
24
18 changes: 18 additions & 0 deletions __tests__/jest.setup.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from 'path';
import fs from 'fs';
import os from 'os';
import {fileURLToPath} from 'url';
import {jest} from '@jest/globals';

const testDir = path.dirname(fileURLToPath(import.meta.url));
const testHome = path.join(os.tmpdir(), 'actions-gh-pages-test-home');
fs.mkdirSync(testHome, {recursive: true});

if (process.platform === 'win32') {

Check warning on line 11 in __tests__/jest.setup.mjs

View check run for this annotation

codefactor.io / CodeFactor

__tests__/jest.setup.mjs#L11

'process' is not defined. (no-undef)
process.env.USERPROFILE = process.env.USERPROFILE || testHome;

Check warning on line 12 in __tests__/jest.setup.mjs

View check run for this annotation

codefactor.io / CodeFactor

__tests__/jest.setup.mjs#L12

'process' is not defined. (no-undef)

Check warning on line 12 in __tests__/jest.setup.mjs

View check run for this annotation

codefactor.io / CodeFactor

__tests__/jest.setup.mjs#L12

'process' is not defined. (no-undef)
} else {
process.env.HOME = testHome;

Check warning on line 14 in __tests__/jest.setup.mjs

View check run for this annotation

codefactor.io / CodeFactor

__tests__/jest.setup.mjs#L14

'process' is not defined. (no-undef)
}

globalThis.jest = jest;
globalThis.__dirname = testDir;
47 changes: 9 additions & 38 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,15 @@ async function getTime(): Promise<string> {

describe('getHomeDir()', () => {
test('get home directory name', async () => {
let test = '';
if (process.platform === 'win32') {
test = 'C:\\Users\\runneradmin';
} else {
test = `${process.env.HOME}`;
}
const test = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
const expected = await getHomeDir();
expect(test).toMatch(expected);
});
});

describe('getWorkDirName()', () => {
test('get work directory name', async () => {
let home = '';
if (process.platform === 'win32') {
home = 'C:\\Users\\runneradmin';
} else {
home = `${process.env.HOME}`;
}
const home = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
const unixTime = await getTime();
const expected = path.join(home, `actions_github_pages_${unixTime}`);
const test = await getWorkDirName(`${unixTime}`);
Expand All @@ -63,18 +53,14 @@ describe('createDir()', () => {

async function getWorkDir(): Promise<string> {
const unixTime = await getTime();
let workDir = '';
workDir = await getWorkDirName(`${unixTime}`);
const workDir = await getWorkDirName(`${unixTime}`);
await createDir(workDir);
return workDir;
}

describe('addNoJekyll()', () => {
test('add .nojekyll', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, '.nojekyll');

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

test('.nojekyll already exists', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, '.nojekyll');
fs.closeSync(fs.openSync(filepath, 'w'));

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

test('not add .nojekyll disable_nojekyll', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, '.nojekyll');

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

describe('addCNAME()', () => {
test('add CNAME', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, 'CNAME');

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

test('do nothing', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, 'CNAME');

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

test('CNAME already exists', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, 'CNAME');

await addCNAME(workDir, 'github.io');
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'GitHub Pages action'
description: 'GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.'
author: 'peaceiris'
runs:
using: 'node20'
using: 'node24'
main: 'lib/index.js'
branding:
icon: 'upload-cloud'
Expand Down
29 changes: 29 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import js from '@eslint/js';
import globals from 'globals';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import jestPlugin from 'eslint-plugin-jest';
import prettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
{
ignores: ['coverage/**', 'lib/**', 'node_modules/**']
},
js.configs.recommended,
...tsPlugin.configs['flat/recommended'],
{
files: ['src/**/*.ts', '__tests__/**/*.ts'],
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.es2022,
...globals.node
},
sourceType: 'module'
}
},
{
files: ['__tests__/**/*.ts'],
...jestPlugin.configs['flat/recommended']
},
prettierRecommended
];
13 changes: 12 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
module.exports = {

Check warning on line 1 in jest.config.js

View check run for this annotation

codefactor.io / CodeFactor

jest.config.js#L1

'module' is not defined. (no-undef)
clearMocks: true,
extensionsToTreatAsEsm: ['.ts'],
moduleFileExtensions: ['js', 'ts'],
setupFiles: ['<rootDir>/__tests__/jest.setup.mjs'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
'^.+\\.ts$': [
'ts-jest',
{
tsconfig: {
module: 'ES2022',
target: 'ES2022'
},
useESM: true
}
]
},
verbose: true
};
Loading
Loading