Skip to content
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v6.0.2

- uses: actions/setup-node@v6.2.0
- uses: actions/setup-node@v6.3.0
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
Expand All @@ -33,6 +33,6 @@ jobs:
yarn test

- name: Uploade CodeCov Report
uses: codecov/codecov-action@v5.5.2
uses: codecov/codecov-action@v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v6.0.2

- uses: actions/setup-node@v6.2.0
- uses: actions/setup-node@v6.3.0
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
ref: dev

# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v6.2.0
- uses: actions/setup-node@v6.3.0
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v6.2.0
- uses: actions/setup-node@v6.3.0
with:
node-version-file: '.node-version'
registry-url: 'https://npm.pkg.github.com'
Expand Down
5 changes: 2 additions & 3 deletions __tests__/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {retrieveData, generateExport} from '../src/fetch'

jest.setTimeout(1000000)
import {jest, describe, it, expect, afterEach} from '@jest/globals'
import {retrieveData, generateExport} from '../src/fetch.js'

describe('fetch', () => {
describe('retrieveData', () => {
Expand Down
33 changes: 21 additions & 12 deletions __tests__/lib.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import {exportVariable, setFailed} from '@actions/core'
import {action} from '../src/constants'
import run from '../src/lib'
import '../src/main'
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals'
import type {Mock} from 'jest-mock'

const originalAction = JSON.stringify(action)

jest.mock('@actions/core', () => ({
jest.unstable_mockModule('@actions/core', () => ({
info: jest.fn(),
setFailed: jest.fn(),
getInput: jest.fn(),
exportVariable: jest.fn()
exportVariable: jest.fn(),
debug: jest.fn(),
setOutput: jest.fn()
}))

const {exportVariable: mockExportVariable, setFailed: mockSetFailed} =
(await import('@actions/core')) as {
exportVariable: Mock
setFailed: Mock
}
const {action} = await import('../src/constants.js')
const {default: run} = await import('../src/lib.js')
await import('../src/main.js')

const originalAction = JSON.stringify(action)

describe('lib', () => {
beforeEach(() => {
jest.clearAllMocks()
Expand All @@ -36,7 +45,7 @@ describe('lib', () => {

await run(action)

expect(exportVariable).toHaveBeenCalledTimes(1)
expect(mockExportVariable).toHaveBeenCalledTimes(1)
expect(global.fetch).toHaveBeenCalledWith(
'https://jives.dev',
expect.any(Object)
Expand All @@ -52,7 +61,7 @@ describe('lib', () => {

await run(action)

expect(exportVariable).toHaveBeenCalledTimes(0)
expect(mockExportVariable).toHaveBeenCalledTimes(0)
expect(global.fetch).toHaveBeenCalledWith(
'https://jives.dev',
expect.any(Object)
Expand All @@ -69,7 +78,7 @@ describe('lib', () => {
await run(action)
} catch (error) {
console.error(error)
expect(setFailed).toHaveBeenCalled()
expect(mockSetFailed).toHaveBeenCalled()
}
})

Expand All @@ -85,7 +94,7 @@ describe('lib', () => {
await run(action)
} catch (error) {
console.error(error)
expect(setFailed).toHaveBeenCalled()
expect(mockSetFailed).toHaveBeenCalled()
}
})
})
3 changes: 2 additions & 1 deletion __tests__/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {extractErrorMessage, isNullOrUndefined} from '../src/util'
import {describe, it, expect} from '@jest/globals'
import {extractErrorMessage, isNullOrUndefined} from '../src/util.js'

describe('util', () => {
describe('isNullOrUndefined', () => {
Expand Down
11 changes: 9 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ import eslintConfigPrettier from 'eslint-config-prettier'
import jest from 'eslint-plugin-jest'

export default tseslint.config(
{ignores: ['lib/', 'coverage/']},
{
files: ['**/*.cjs'],
languageOptions: {
sourceType: 'commonjs',
globals: {module: 'readonly', require: 'readonly', exports: 'writable'}
}
},
eslintConfigPrettier,
jest.configs['flat/recommended'],
eslint.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: {
process: true,
module: true
process: true
}
},
rules: {
Expand Down
23 changes: 23 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
clearMocks: true,
extensionsToTreatAsEsm: ['.ts'],
moduleFileExtensions: ['js', 'mjs', 'ts'],
moduleNameMapper: {
'^(\\.{1,2}/.+)\\.js$': '$1'
},
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': [
'ts-jest',
{
useESM: true,
tsconfig: 'tsconfig.test.json'
}
]
},
verbose: true,
collectCoverage: true,
collectCoverageFrom: ['src/*.ts', '!src/constants.ts']
}
13 changes: 0 additions & 13 deletions jest.config.js

This file was deleted.

33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
"version": "2.5.0",
"license": "MIT",
"type": "module",
"main": "lib/lib.js",
"types": "lib/lib.d.ts",
"root": true,
"scripts": {
"build": "rm -rf lib && tsc --declaration",
"test": "jest",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"lint": "eslint --fix .",
"lint:check": "eslint .",
"lint:format": "prettier --write .",
Expand All @@ -35,28 +36,32 @@
"github-action"
],
"dependencies": {
"@actions/core": "2.0.2",
"@actions/io": "2.0.0",
"@actions/core": "3.0.0",
"@actions/io": "3.0.2",
"async-retry": "1.3.3",
"mustache": "4.2.0"
},
"devDependencies": {
"@eslint/js": "10.0.0",
"@types/async-retry": "1.4.9",
"@types/jest": "30.0.0",
"@types/mustache": "4.2.6",
"@types/node": "25.0.9",
"@types/node": "25.5.0",
"@types/retry": "0.12.5",
"@typescript-eslint/eslint-plugin": "8.53.0",
"@typescript-eslint/parser": "8.53.0",
"eslint": "9.39.2",
"@typescript-eslint/eslint-plugin": "8.58.0",
"@typescript-eslint/parser": "8.58.0",
"eslint": "10.1.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-jest": "29.12.1",
"eslint-plugin-jest": "29.15.1",
"eslint-plugin-prettier": "5.5.5",
"jest": "30.2.0",
"jest-circus": "30.2.0",
"prettier": "3.8.0",
"ts-jest": "29.4.6",
"typescript": "5.9.3",
"typescript-eslint": "8.53.0"
"jest": "30.3.0",
"jest-circus": "30.3.0",
"prettier": "3.8.1",
"ts-jest": "29.4.9",
"typescript": "6.0.2",
"typescript-eslint": "8.58.0"
},
"resolutions": {
"@typescript-eslint/utils": "8.58.0"
}
}
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {getInput} from '@actions/core'
import {isNullOrUndefined} from './util'
import {isNullOrUndefined} from './util.js'

/**
* Required action data that gets initialized when running within the GitHub Actions environment.
Expand Down
11 changes: 7 additions & 4 deletions src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
} from '@actions/core'
import {mkdirP} from '@actions/io'
import {promises as fs} from 'fs'
import {render} from 'mustache'
import Mustache from 'mustache'
import retryRequest from 'async-retry'
import {DataInterface, ExportInterface, Status} from './constants'
import {parseData} from './util'
import type {DataInterface, ExportInterface} from './constants.js'
import {Status} from './constants.js'
import {parseData} from './util.js'

/**
* Retrieves data from an API endpoint.
Expand All @@ -30,7 +31,9 @@ export async function retrieveData({
)

const settings = configuration
? JSON.parse(render(configuration, auth ? parseData(auth) : null))
? JSON.parse(
Mustache.render(configuration, auth ? parseData(auth) : null)
)
: {}

if (settings.body) {
Expand Down
9 changes: 5 additions & 4 deletions src/lib.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {info, setFailed} from '@actions/core'
import {action, ActionInterface, Status} from './constants'
import {generateExport, retrieveData} from './fetch'
import {extractErrorMessage, hasRequiredParameters} from './util'
import {action, Status} from './constants.js'
import type {ActionInterface} from './constants.js'
import {generateExport, retrieveData} from './fetch.js'
import {extractErrorMessage, hasRequiredParameters} from './util.js'

/**
* Initializes and runs the action.
Expand Down Expand Up @@ -72,4 +73,4 @@ export default async function run(
}
}

export {retrieveData, generateExport, ActionInterface}
export {retrieveData, generateExport, type ActionInterface}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import run from './lib'
import run from './lib.js'

run()
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ActionInterface} from './constants'
import type {ActionInterface} from './constants.js'

/**
* Checks to see if a value is null or undefined.
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"target": "es2022",
"module": "NodeNext",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true
"esModuleInterop": true,
"types": ["node"]
},
"exclude": ["node_modules", "**/*.test.ts"]
}
9 changes: 9 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"types": ["node", "jest"],
"isolatedModules": true
},
"exclude": ["node_modules"]
}
Loading
Loading