Convert to ESM
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
lib/
|
|
||||||
dist/
|
|
||||||
node_modules/
|
|
||||||
coverage/
|
|
||||||
@@ -26,10 +26,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# Checkout the repository.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Setup Node.js using the version specified in `.node-version`.
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
id: setup-node
|
id: setup-node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -37,10 +39,12 @@ jobs:
|
|||||||
node-version-file: .node-version
|
node-version-file: .node-version
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
|
# Install dependencies using `npm ci`.
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
id: install
|
id: install
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
|
# Build the `dist/` directory.
|
||||||
- name: Build dist/ Directory
|
- name: Build dist/ Directory
|
||||||
id: build
|
id: build
|
||||||
run: npm run bundle
|
run: npm run bundle
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
# This workflow will lint the entire codebase using the
|
||||||
|
# `super-linter/super-linter` action.
|
||||||
|
#
|
||||||
|
# For more information, see the super-linter repository:
|
||||||
|
# https://github.com/super-linter/super-linter
|
||||||
name: Lint Codebase
|
name: Lint Codebase
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -19,12 +24,14 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# Checkout the repository.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# Setup Node.js using the version specified in `.node-version`.
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
id: setup-node
|
id: setup-node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -32,10 +39,12 @@ jobs:
|
|||||||
node-version-file: .node-version
|
node-version-file: .node-version
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
|
# Install dependencies using `npm ci`.
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
id: install
|
id: install
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
|
# Lint the codebase using the `super-linter/super-linter` action.
|
||||||
- name: Lint Codebase
|
- name: Lint Codebase
|
||||||
id: super-linter
|
id: super-linter
|
||||||
uses: super-linter/super-linter/slim@v7
|
uses: super-linter/super-linter/slim@v7
|
||||||
@@ -43,6 +52,9 @@ jobs:
|
|||||||
DEFAULT_BRANCH: main
|
DEFAULT_BRANCH: main
|
||||||
FILTER_REGEX_EXCLUDE: dist/**/*
|
FILTER_REGEX_EXCLUDE: dist/**/*
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
VALIDATE_JAVASCRIPT_STANDARD: false
|
LINTER_RULES_PATH: ${{ github.workspace }}
|
||||||
VALIDATE_ALL_CODEBASE: true
|
VALIDATE_ALL_CODEBASE: true
|
||||||
|
VALIDATE_JAVASCRIPT_ES: false
|
||||||
|
VALIDATE_JAVASCRIPT_STANDARD: false
|
||||||
VALIDATE_JSCPD: false
|
VALIDATE_JSCPD: false
|
||||||
|
VALIDATE_JSON: false
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# See: https://github.com/DavidAnson/markdownlint
|
||||||
|
|
||||||
|
# Unordered list style
|
||||||
|
MD004:
|
||||||
|
style: dash
|
||||||
|
|
||||||
|
# Disable line length for tables
|
||||||
|
MD013:
|
||||||
|
tables: false
|
||||||
|
|
||||||
|
# Ordered list item prefix
|
||||||
|
MD029:
|
||||||
|
style: one
|
||||||
|
|
||||||
|
# Spaces after list markers
|
||||||
|
MD030:
|
||||||
|
ul_single: 1
|
||||||
|
ol_single: 1
|
||||||
|
ul_multi: 1
|
||||||
|
ol_multi: 1
|
||||||
|
|
||||||
|
# Code block style
|
||||||
|
MD046:
|
||||||
|
style: fenced
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
20.6.0
|
22.9.0
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
.DS_Store
|
||||||
dist/
|
dist/
|
||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": false,
|
|
||||||
"singleQuote": true,
|
|
||||||
"quoteProps": "as-needed",
|
|
||||||
"jsxSingleQuote": false,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"bracketSpacing": true,
|
|
||||||
"bracketSameLine": true,
|
|
||||||
"arrowParens": "avoid",
|
|
||||||
"proseWrap": "always",
|
|
||||||
"htmlWhitespaceSensitivity": "css",
|
|
||||||
"endOfLine": "lf"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# See: https://prettier.io/docs/en/configuration
|
||||||
|
|
||||||
|
printWidth: 80
|
||||||
|
tabWidth: 2
|
||||||
|
useTabs: false
|
||||||
|
semi: false
|
||||||
|
singleQuote: true
|
||||||
|
quoteProps: as-needed
|
||||||
|
jsxSingleQuote: false
|
||||||
|
trailingComma: none
|
||||||
|
bracketSpacing: true
|
||||||
|
bracketSameLine: true
|
||||||
|
arrowParens: always
|
||||||
|
proseWrap: always
|
||||||
|
htmlWhitespaceSensitivity: css
|
||||||
|
endOfLine: lf
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# See: https://yamllint.readthedocs.io/en/stable/
|
||||||
|
|
||||||
|
rules:
|
||||||
|
document-end: disable
|
||||||
|
document-start:
|
||||||
|
level: warning
|
||||||
|
present: false
|
||||||
|
line-length:
|
||||||
|
level: warning
|
||||||
|
max: 80
|
||||||
|
allow-non-breakable-words: true
|
||||||
|
allow-non-breakable-inline-mappings: true
|
||||||
+5
-1
@@ -1,3 +1,7 @@
|
|||||||
# Repository CODEOWNERS
|
############################################################################
|
||||||
|
# Repository CODEOWNERS #
|
||||||
|
# Order is important! The last matching pattern takes the most precedence. #
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Default owners, unless a later match takes precedence.
|
||||||
* @actions/actions-oss-maintainers
|
* @actions/actions-oss-maintainers
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* This file is used to mock the `@actions/core` module in tests.
|
||||||
|
*/
|
||||||
|
import { jest } from '@jest/globals'
|
||||||
|
|
||||||
|
export const debug = jest.fn()
|
||||||
|
export const error = jest.fn()
|
||||||
|
export const info = jest.fn()
|
||||||
|
export const getInput = jest.fn()
|
||||||
|
export const setOutput = jest.fn()
|
||||||
|
export const setFailed = jest.fn()
|
||||||
|
export const warning = jest.fn()
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { jest } from '@jest/globals'
|
||||||
|
|
||||||
|
export const wait = jest.fn()
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* Unit tests for the action's entrypoint, src/index.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
const { run } = require('../src/main')
|
|
||||||
|
|
||||||
// Mock the action's entrypoint
|
|
||||||
jest.mock('../src/main', () => ({
|
|
||||||
run: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
describe('index', () => {
|
|
||||||
it('calls run when imported', async () => {
|
|
||||||
require('../src/index')
|
|
||||||
|
|
||||||
expect(run).toHaveBeenCalled()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
+40
-74
@@ -1,96 +1,62 @@
|
|||||||
/**
|
/**
|
||||||
* Unit tests for the action's main functionality, src/main.js
|
* Unit tests for the action's main functionality, src/main.js
|
||||||
|
*
|
||||||
|
* To mock dependencies in ESM, you can create fixtures that export mock
|
||||||
|
* functions and objects. For example, the core module is mocked in this test,
|
||||||
|
* so that the actual '@actions/core' module is not imported.
|
||||||
*/
|
*/
|
||||||
const core = require('@actions/core')
|
import { jest } from '@jest/globals'
|
||||||
const main = require('../src/main')
|
import * as core from '../__fixtures__/core.js'
|
||||||
|
import { wait } from '../__fixtures__/wait.js'
|
||||||
|
|
||||||
// Mock the GitHub Actions core library
|
// Mocks should be declared before the module being tested is imported.
|
||||||
const debugMock = jest.spyOn(core, 'debug').mockImplementation()
|
jest.unstable_mockModule('@actions/core', () => core)
|
||||||
const getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
|
jest.unstable_mockModule('../src/wait.js', () => ({ wait }))
|
||||||
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
|
|
||||||
const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
|
|
||||||
|
|
||||||
// Mock the action's main function
|
// The module being tested should be imported dynamically. This ensures that the
|
||||||
const runMock = jest.spyOn(main, 'run')
|
// mocks are used in place of any actual dependencies.
|
||||||
|
const { run } = await import('../src/main.js')
|
||||||
|
|
||||||
// Other utilities
|
describe('main.js', () => {
|
||||||
const timeRegex = /^\d{2}:\d{2}:\d{2}/
|
|
||||||
|
|
||||||
describe('action', () => {
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks()
|
// Set the action's inputs as return values from core.getInput().
|
||||||
|
core.getInput.mockImplementation(() => '500')
|
||||||
|
|
||||||
|
// Mock the wait function so that it does not actually wait.
|
||||||
|
wait.mockImplementation(() => Promise.resolve('done!'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the time output', async () => {
|
afterEach(() => {
|
||||||
// Set the action's inputs as return values from core.getInput()
|
jest.resetAllMocks()
|
||||||
getInputMock.mockImplementation(name => {
|
})
|
||||||
switch (name) {
|
|
||||||
case 'milliseconds':
|
|
||||||
return '500'
|
|
||||||
default:
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await main.run()
|
it('Sets the time output', async () => {
|
||||||
expect(runMock).toHaveReturned()
|
await run()
|
||||||
|
|
||||||
// Verify that all of the core library functions were called correctly
|
// Verify the time output was set.
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
|
expect(core.setOutput).toHaveBeenNthCalledWith(
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(
|
|
||||||
2,
|
|
||||||
expect.stringMatching(timeRegex)
|
|
||||||
)
|
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(
|
|
||||||
3,
|
|
||||||
expect.stringMatching(timeRegex)
|
|
||||||
)
|
|
||||||
expect(setOutputMock).toHaveBeenNthCalledWith(
|
|
||||||
1,
|
1,
|
||||||
'time',
|
'time',
|
||||||
expect.stringMatching(timeRegex)
|
// Simple regex to match a time string in the format HH:MM:SS.
|
||||||
|
expect.stringMatching(/^\d{2}:\d{2}:\d{2}/)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets a failed status', async () => {
|
it('Sets a failed status', async () => {
|
||||||
// Set the action's inputs as return values from core.getInput()
|
// Clear the getInput mock and return an invalid value.
|
||||||
getInputMock.mockImplementation(name => {
|
core.getInput.mockClear().mockReturnValueOnce('this is not a number')
|
||||||
switch (name) {
|
|
||||||
case 'milliseconds':
|
|
||||||
return 'this is not a number'
|
|
||||||
default:
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await main.run()
|
// Clear the wait mock and return a rejected promise.
|
||||||
expect(runMock).toHaveReturned()
|
wait
|
||||||
|
.mockClear()
|
||||||
|
.mockRejectedValueOnce(new Error('milliseconds is not a number'))
|
||||||
|
|
||||||
// Verify that all of the core library functions were called correctly
|
await run()
|
||||||
expect(setFailedMock).toHaveBeenNthCalledWith(
|
|
||||||
|
// Verify that the action was marked as failed.
|
||||||
|
expect(core.setFailed).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
'milliseconds not a number'
|
'milliseconds is not a number'
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('fails if no input is provided', async () => {
|
|
||||||
// Set the action's inputs as return values from core.getInput()
|
|
||||||
getInputMock.mockImplementation(name => {
|
|
||||||
switch (name) {
|
|
||||||
case 'milliseconds':
|
|
||||||
throw new Error('Input required and not supplied: milliseconds')
|
|
||||||
default:
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await main.run()
|
|
||||||
expect(runMock).toHaveReturned()
|
|
||||||
|
|
||||||
// Verify that all of the core library functions were called correctly
|
|
||||||
expect(setFailedMock).toHaveBeenNthCalledWith(
|
|
||||||
1,
|
|
||||||
'Input required and not supplied: milliseconds'
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Unit tests for src/wait.js
|
* Unit tests for src/wait.js
|
||||||
*/
|
*/
|
||||||
const { wait } = require('../src/wait')
|
import { wait } from '../src/wait.js'
|
||||||
const { expect } = require('@jest/globals')
|
|
||||||
|
|
||||||
describe('wait.js', () => {
|
describe('wait.js', () => {
|
||||||
it('throws an invalid number', async () => {
|
it('Throws an invalid number', async () => {
|
||||||
const input = parseInt('foo', 10)
|
const input = parseInt('foo', 10)
|
||||||
|
|
||||||
expect(isNaN(input)).toBe(true)
|
expect(isNaN(input)).toBe(true)
|
||||||
|
|
||||||
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
|
await expect(wait(input)).rejects.toThrow('milliseconds is not a number')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('waits with a valid number', async () => {
|
it('Waits with a valid number', async () => {
|
||||||
const start = new Date()
|
const start = new Date()
|
||||||
await wait(500)
|
await wait(500)
|
||||||
const end = new Date()
|
const end = new Date()
|
||||||
|
|||||||
+10
-5
@@ -1,18 +1,23 @@
|
|||||||
name: 'The name of your action here'
|
name: The name of your action here
|
||||||
description: 'Provide a description here'
|
description: Provide a description here
|
||||||
author: 'Your name or organization here'
|
author: Your name or organization here
|
||||||
|
|
||||||
|
# Add your action's branding here. This will appear on the GitHub Marketplace.
|
||||||
|
branding:
|
||||||
|
icon: heart
|
||||||
|
color: red
|
||||||
|
|
||||||
# Define your inputs here.
|
# Define your inputs here.
|
||||||
inputs:
|
inputs:
|
||||||
milliseconds:
|
milliseconds:
|
||||||
description: 'Your input description here'
|
description: Your input description here
|
||||||
required: true
|
required: true
|
||||||
default: '1000'
|
default: '1000'
|
||||||
|
|
||||||
# Define your outputs here.
|
# Define your outputs here.
|
||||||
outputs:
|
outputs:
|
||||||
time:
|
time:
|
||||||
description: 'Your output description here'
|
description: Your output description here
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: node20
|
using: node20
|
||||||
|
|||||||
+27235
-3601
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
-84
@@ -1,84 +0,0 @@
|
|||||||
@actions/core
|
|
||||||
MIT
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright 2019 GitHub
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
@actions/exec
|
|
||||||
MIT
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright 2019 GitHub
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
@actions/http-client
|
|
||||||
MIT
|
|
||||||
Actions Http Client for Node.js
|
|
||||||
|
|
||||||
Copyright (c) GitHub, Inc.
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
||||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
||||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
@actions/io
|
|
||||||
MIT
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright 2019 GitHub
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
tunnel
|
|
||||||
MIT
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2012 Koichi Kobayashi
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,61 @@
|
|||||||
|
// See: https://eslint.org/docs/latest/use/configure/configuration-files
|
||||||
|
|
||||||
|
import { fixupPluginRules } from '@eslint/compat'
|
||||||
|
import { FlatCompat } from '@eslint/eslintrc'
|
||||||
|
import js from '@eslint/js'
|
||||||
|
import _import from 'eslint-plugin-import'
|
||||||
|
import jest from 'eslint-plugin-jest'
|
||||||
|
import prettier from 'eslint-plugin-prettier'
|
||||||
|
import globals from 'globals'
|
||||||
|
import path from 'node:path'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all
|
||||||
|
})
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
ignores: ['**/coverage', '**/dist', '**/linter', '**/node_modules']
|
||||||
|
},
|
||||||
|
...compat.extends(
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:jest/recommended',
|
||||||
|
'plugin:prettier/recommended'
|
||||||
|
),
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
import: fixupPluginRules(_import),
|
||||||
|
jest,
|
||||||
|
prettier
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.jest,
|
||||||
|
Atomics: 'readonly',
|
||||||
|
SharedArrayBuffer: 'readonly'
|
||||||
|
},
|
||||||
|
|
||||||
|
ecmaVersion: 2023,
|
||||||
|
sourceType: 'module'
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
camelcase: 'off',
|
||||||
|
'eslint-comments/no-use': 'off',
|
||||||
|
'eslint-comments/no-unused-disable': 'off',
|
||||||
|
'i18n-text/no-en': 'off',
|
||||||
|
'import/no-namespace': 'off',
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-shadow': 'off',
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'prettier/prettier': 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// See: https://jestjs.io/docs/configuration
|
||||||
|
|
||||||
|
/** @type {import('jest').Config} */
|
||||||
|
const jestConfig = {
|
||||||
|
clearMocks: true,
|
||||||
|
collectCoverage: true,
|
||||||
|
collectCoverageFrom: ['./src/**'],
|
||||||
|
coverageDirectory: './coverage',
|
||||||
|
coveragePathIgnorePatterns: ['/node_modules/', '/dist/'],
|
||||||
|
coverageReporters: ['json-summary', 'text', 'lcov'],
|
||||||
|
// Uncomment the below lines if you would like to enforce a coverage threshold
|
||||||
|
// for your action. This will fail the build if the coverage is below the
|
||||||
|
// specified thresholds.
|
||||||
|
// coverageThreshold: {
|
||||||
|
// global: {
|
||||||
|
// branches: 100,
|
||||||
|
// functions: 100,
|
||||||
|
// lines: 100,
|
||||||
|
// statements: 100
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
moduleFileExtensions: ['js'],
|
||||||
|
reporters: ['default'],
|
||||||
|
testEnvironment: 'node',
|
||||||
|
testMatch: ['**/*.test.js'],
|
||||||
|
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
|
||||||
|
verbose: true
|
||||||
|
}
|
||||||
|
|
||||||
|
export default jestConfig
|
||||||
Generated
+4556
-5921
File diff suppressed because it is too large
Load Diff
+19
-43
@@ -3,6 +3,7 @@
|
|||||||
"description": "GitHub Actions JavaScript Template",
|
"description": "GitHub Actions JavaScript Template",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"author": "",
|
"author": "",
|
||||||
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://github.com/actions/javascript-action#readme",
|
"homepage": "https://github.com/actions/javascript-action#readme",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -13,71 +14,46 @@
|
|||||||
"url": "https://github.com/actions/javascript-action/issues"
|
"url": "https://github.com/actions/javascript-action/issues"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"GitHub",
|
"actions"
|
||||||
"Actions",
|
|
||||||
"JavaScript"
|
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/index.js"
|
".": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=21"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bundle": "npm run format:write && npm run package",
|
"bundle": "npm run format:write && npm run package",
|
||||||
"ci-test": "npx jest",
|
"ci-test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest",
|
||||||
"coverage": "npx make-coverage-badge --output-path ./badges/coverage.svg",
|
"coverage": "npx make-coverage-badge --output-path ./badges/coverage.svg",
|
||||||
"format:write": "npx prettier --write .",
|
"format:write": "npx prettier --write .",
|
||||||
"format:check": "npx prettier --check .",
|
"format:check": "npx prettier --check .",
|
||||||
"lint": "npx eslint . -c ./.github/linters/.eslintrc.yml",
|
"lint": "npx eslint .",
|
||||||
"package": "npx ncc build src/index.js -o dist --source-map --license licenses.txt",
|
"local-action": "npx local-action . src/main.js .env",
|
||||||
|
"package": "npx rollup --config rollup.config.js",
|
||||||
"package:watch": "npm run package -- --watch",
|
"package:watch": "npm run package -- --watch",
|
||||||
"test": "npx jest",
|
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest",
|
||||||
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
|
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"eslintConfig": {
|
|
||||||
"extends": "./.github/linters/.eslintrc.yml"
|
|
||||||
},
|
|
||||||
"jest": {
|
|
||||||
"verbose": true,
|
|
||||||
"clearMocks": true,
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"js"
|
|
||||||
],
|
|
||||||
"testMatch": [
|
|
||||||
"**/*.test.js"
|
|
||||||
],
|
|
||||||
"testPathIgnorePatterns": [
|
|
||||||
"/node_modules/",
|
|
||||||
"/dist/"
|
|
||||||
],
|
|
||||||
"coverageReporters": [
|
|
||||||
"json-summary",
|
|
||||||
"text",
|
|
||||||
"lcov"
|
|
||||||
],
|
|
||||||
"collectCoverage": true,
|
|
||||||
"collectCoverageFrom": [
|
|
||||||
"./src/**"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.11.1"
|
"@actions/core": "^1.11.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.26.0",
|
"@eslint/compat": "^1.2.3",
|
||||||
"@babel/eslint-parser": "^7.25.9",
|
|
||||||
"@babel/preset-env": "^7.26.0",
|
|
||||||
"@github/local-action": "^2.2.0",
|
"@github/local-action": "^2.2.0",
|
||||||
"@vercel/ncc": "^0.38.2",
|
"@jest/globals": "^29.7.0",
|
||||||
"babel-preset-jest": "^29.6.3",
|
"@rollup/plugin-commonjs": "^28.0.1",
|
||||||
"eslint": "^8.57.1",
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
"eslint-plugin-github": "^5.0.2",
|
"eslint": "^9.14.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jest": "^28.9.0",
|
"eslint-plugin-jest": "^28.9.0",
|
||||||
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"make-coverage-badge": "^1.2.0",
|
"make-coverage-badge": "^1.2.0",
|
||||||
"prettier": "^3.3.3"
|
"prettier": "^3.3.3",
|
||||||
|
"prettier-eslint": "^16.3.0",
|
||||||
|
"rollup": "^4.27.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// See: https://rollupjs.org/introduction/
|
||||||
|
|
||||||
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
input: 'src/index.js',
|
||||||
|
output: {
|
||||||
|
esModule: true,
|
||||||
|
file: 'dist/index.js',
|
||||||
|
format: 'es',
|
||||||
|
sourcemap: true
|
||||||
|
},
|
||||||
|
plugins: [commonjs(), nodeResolve()]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* The entrypoint for the action.
|
* The entrypoint for the action. This file simply imports and runs the action's
|
||||||
|
* main logic.
|
||||||
*/
|
*/
|
||||||
const { run } = require('./main')
|
import { run } from './main.js'
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
run()
|
run()
|
||||||
|
|||||||
+6
-9
@@ -1,13 +1,14 @@
|
|||||||
const core = require('@actions/core')
|
import * as core from '@actions/core'
|
||||||
const { wait } = require('./wait')
|
import { wait } from './wait.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main function for the action.
|
* The main function for the action.
|
||||||
|
*
|
||||||
* @returns {Promise<void>} Resolves when the action is complete.
|
* @returns {Promise<void>} Resolves when the action is complete.
|
||||||
*/
|
*/
|
||||||
async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const ms = core.getInput('milliseconds', { required: true })
|
const ms = core.getInput('milliseconds')
|
||||||
|
|
||||||
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
|
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
|
||||||
core.debug(`Waiting ${ms} milliseconds ...`)
|
core.debug(`Waiting ${ms} milliseconds ...`)
|
||||||
@@ -21,10 +22,6 @@ async function run() {
|
|||||||
core.setOutput('time', new Date().toTimeString())
|
core.setOutput('time', new Date().toTimeString())
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fail the workflow run if an error occurs
|
// Fail the workflow run if an error occurs
|
||||||
core.setFailed(error.message)
|
if (error instanceof Error) core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
run
|
|
||||||
}
|
|
||||||
|
|||||||
+4
-8
@@ -1,17 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Wait for a number of milliseconds.
|
* Waits for a number of milliseconds.
|
||||||
*
|
*
|
||||||
* @param {number} milliseconds The number of milliseconds to wait.
|
* @param {number} milliseconds The number of milliseconds to wait.
|
||||||
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
|
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
|
||||||
*/
|
*/
|
||||||
async function wait(milliseconds) {
|
export async function wait(milliseconds) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
if (isNaN(milliseconds)) {
|
if (isNaN(milliseconds)) throw new Error('milliseconds is not a number')
|
||||||
throw new Error('milliseconds not a number')
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => resolve('done!'), milliseconds)
|
setTimeout(() => resolve('done!'), milliseconds)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { wait }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user