mirror of
https://github.com/actions/javascript-action.git
synced 2025-12-10 20:56:57 +00:00
Compare commits
308 Commits
v1
...
ncalteen/l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf07408ed9 | ||
|
|
a76d098d06 | ||
|
|
725300a6e2 | ||
|
|
ad27785903 | ||
|
|
b20bf2e912 | ||
|
|
ec57a4c31b | ||
|
|
14c6df91f7 | ||
|
|
f89c074fba | ||
|
|
fa9d73a3f7 | ||
|
|
e62c6fb586 | ||
|
|
9792e7c295 | ||
|
|
9020a2af63 | ||
|
|
3d977ce510 | ||
|
|
8a1d297bda | ||
|
|
05854d806b | ||
|
|
d3fa3fa915 | ||
|
|
48f6b7e1c9 | ||
|
|
78cf8d293c | ||
|
|
ab0a836a6e | ||
|
|
81f37580f8 | ||
|
|
fa6ce62a7f | ||
|
|
92ced6f207 | ||
|
|
8866d6e98e | ||
|
|
ddfd38ef6d | ||
|
|
7d8b19ec32 | ||
|
|
89f1f8b86e | ||
|
|
0162b739ab | ||
|
|
1bab47cf53 | ||
|
|
e8deae9ecb | ||
|
|
6c0950181d | ||
|
|
aa81e86d55 | ||
|
|
376ade8d59 | ||
|
|
79d1b397fa | ||
|
|
e440420ba2 | ||
|
|
0c1056335d | ||
|
|
b0ea639bf1 | ||
|
|
276175d1e5 | ||
|
|
713f6464fe | ||
|
|
081d9e881a | ||
|
|
14c58ed4a7 | ||
|
|
8daef5da3d | ||
|
|
abc55e3728 | ||
|
|
1c7a606db9 | ||
|
|
c72e19afaf | ||
|
|
2cbc99bed9 | ||
|
|
1fd4a6984e | ||
|
|
2d33d612fa | ||
|
|
53595c19bb | ||
|
|
fec286fee8 | ||
|
|
88c5eb7241 | ||
|
|
b0cc677b01 | ||
|
|
b8d78a8a7a | ||
|
|
a1ede79991 | ||
|
|
023fbfd7d2 | ||
|
|
936ae24c2b | ||
|
|
c383447706 | ||
|
|
558c75a530 | ||
|
|
56bfdb077e | ||
|
|
46f003afee | ||
|
|
e3dfacee59 | ||
|
|
b26ac78134 | ||
|
|
9acd878b07 | ||
|
|
be84a65df0 | ||
|
|
ed1c2b2498 | ||
|
|
3753d504de | ||
|
|
8fc1990490 | ||
|
|
2c9206ccfe | ||
|
|
4220638be2 | ||
|
|
74547d3030 | ||
|
|
5f0848d183 | ||
|
|
899af482b5 | ||
|
|
1a80f52c26 | ||
|
|
5a272f48d5 | ||
|
|
986a3ff119 | ||
|
|
13fcf84361 | ||
|
|
d169b850ac | ||
|
|
3edf76a5ea | ||
|
|
473a2fab9b | ||
|
|
7b453b8e76 | ||
|
|
a4aad6151c | ||
|
|
1182e81f6d | ||
|
|
e5fc95cfe4 | ||
|
|
c823d3af85 | ||
|
|
da309b50df | ||
|
|
eefa2ac8c8 | ||
|
|
0751b4ffc1 | ||
|
|
0f53b2bbd7 | ||
|
|
ecb5f8624e | ||
|
|
49d301d563 | ||
|
|
bb823dc371 | ||
|
|
4fc08f31c8 | ||
|
|
bc16f8bef7 | ||
|
|
6a8c7c2956 | ||
|
|
33bf57385d | ||
|
|
c085f59c93 | ||
|
|
7259ba6451 | ||
|
|
821f1b75ba | ||
|
|
c1a5b39886 | ||
|
|
33a94a0cb1 | ||
|
|
6ae654c69b | ||
|
|
eab41dd25f | ||
|
|
32834a0ed0 | ||
|
|
5f89e98a15 | ||
|
|
c4ac35c7fd | ||
|
|
c19f22c380 | ||
|
|
b07e85e31e | ||
|
|
6e827e7bb9 | ||
|
|
7ab0d1919b | ||
|
|
d8da8cf29d | ||
|
|
d0859adef1 | ||
|
|
40e7a56c70 | ||
|
|
ff88501abb | ||
|
|
2733e2b6fb | ||
|
|
31d38679a6 | ||
|
|
d2e5770e9b | ||
|
|
9fb32514e8 | ||
|
|
03f313d310 | ||
|
|
6395e9c332 | ||
|
|
aae059972e | ||
|
|
528442b226 | ||
|
|
2c5b4091cd | ||
|
|
a4c53ef4d8 | ||
|
|
90439f50d4 | ||
|
|
3517fa9e21 | ||
|
|
e8e4e44106 | ||
|
|
c4a216827e | ||
|
|
4ddec86476 | ||
|
|
284d09c510 | ||
|
|
8328af8f54 | ||
|
|
89d575c59c | ||
|
|
8f6845463f | ||
|
|
dae1ebf03a | ||
|
|
aa4a812b5a | ||
|
|
3c97216ab6 | ||
|
|
03ac2df7aa | ||
|
|
412eae295a | ||
|
|
a657264b53 | ||
|
|
784a44373a | ||
|
|
dfbc9e31c9 | ||
|
|
0e60f52628 | ||
|
|
356fc0bbf7 | ||
|
|
c378125386 | ||
|
|
742e711d64 | ||
|
|
db1c8c28bf | ||
|
|
8ce00a89d8 | ||
|
|
7d23979b4f | ||
|
|
b2e9b9516a | ||
|
|
3cd31bd72d | ||
|
|
d425230c5e | ||
|
|
38c5d3568b | ||
|
|
a8ca6dad2e | ||
|
|
35e142ce9e | ||
|
|
16218d61ed | ||
|
|
a458571c7c | ||
|
|
d1f33fc390 | ||
|
|
2567d6256c | ||
|
|
80d7bc0d22 | ||
|
|
285d12f366 | ||
|
|
7856cb2184 | ||
|
|
e763ed850b | ||
|
|
4eb3a60688 | ||
|
|
cc2b5c5668 | ||
|
|
51133cf1a9 | ||
|
|
4e67788bc6 | ||
|
|
7fe1808dde | ||
|
|
3395456687 | ||
|
|
64d63195a5 | ||
|
|
c143cbf903 | ||
|
|
25d0ac5287 | ||
|
|
e6b4f761e8 | ||
|
|
f2e1064251 | ||
|
|
e17da1139b | ||
|
|
2a83311308 | ||
|
|
3590e9b769 | ||
|
|
eaafbb35e7 | ||
|
|
db5989edac | ||
|
|
81784187e0 | ||
|
|
ce9a7394f7 | ||
|
|
58c92eabb5 | ||
|
|
d5e1c58cd7 | ||
|
|
8f331f9f7d | ||
|
|
f47338151d | ||
|
|
f0a4f6e3db | ||
|
|
d665784fdc | ||
|
|
b6cd41f5a7 | ||
|
|
977e5c8305 | ||
|
|
f41bbe2462 | ||
|
|
33fb89eea5 | ||
|
|
a207dc1aff | ||
|
|
e5e3f40b06 | ||
|
|
8dc1bdabf2 | ||
|
|
58a2fedb78 | ||
|
|
2c10e71494 | ||
|
|
40edfb1109 | ||
|
|
915d455dd9 | ||
|
|
f6cdfd00fa | ||
|
|
a63c74031e | ||
|
|
6696ff284c | ||
|
|
78149c470d | ||
|
|
f2218edc81 | ||
|
|
85ce0f4bbc | ||
|
|
d60efca7f1 | ||
|
|
8ecf3fbe83 | ||
|
|
7e03c11e88 | ||
|
|
c60b48b68d | ||
|
|
de5a31270e | ||
|
|
732ea716e3 | ||
|
|
c1c7a9c865 | ||
|
|
8db017fe40 | ||
|
|
2616977857 | ||
|
|
fc7b85018d | ||
|
|
989e8db414 | ||
|
|
029b15a667 | ||
|
|
abda3bf476 | ||
|
|
9d90b08433 | ||
|
|
4cfbeaaa69 | ||
|
|
5cc64e22ed | ||
|
|
01db1198e0 | ||
|
|
84775cb3cd | ||
|
|
280868455c | ||
|
|
a837846a50 | ||
|
|
0241b656cd | ||
|
|
c3c5bfae5d | ||
|
|
ae67aa28b4 | ||
|
|
433d9cdb62 | ||
|
|
019a65318e | ||
|
|
d17ac8ecc5 | ||
|
|
d345eefb2e | ||
|
|
8a93a79723 | ||
|
|
cfa5739bef | ||
|
|
5e56b5be03 | ||
|
|
12426a046a | ||
|
|
ea09560a8d | ||
|
|
570107f4a0 | ||
|
|
36a902841b | ||
|
|
6e72f47586 | ||
|
|
48fa9ea205 | ||
|
|
71f9b03865 | ||
|
|
ce2ce1b47c | ||
|
|
3377b7aab7 | ||
|
|
7112950ce6 | ||
|
|
fc287e4e8e | ||
|
|
fd752b66de | ||
|
|
f95b74224c | ||
|
|
3649ee2b02 | ||
|
|
a824008085 | ||
|
|
f01b85d972 | ||
|
|
d97e7c3fda | ||
|
|
9f221a3d65 | ||
|
|
5868ec70dc | ||
|
|
1d04ca7dc1 | ||
|
|
e831f7f48f | ||
|
|
c06df8672d | ||
|
|
513a8f64b4 | ||
|
|
7f7117c1ee | ||
|
|
c9bffaa4ee | ||
|
|
fc5e765130 | ||
|
|
bd48a7be9a | ||
|
|
906c6909a6 | ||
|
|
7983bf250a | ||
|
|
14c73137d8 | ||
|
|
03c3ae8c48 | ||
|
|
571a71ff01 | ||
|
|
77ad32cf2c | ||
|
|
2a55f4cf94 | ||
|
|
f381d73212 | ||
|
|
0cd86ddeba | ||
|
|
c1c60989a1 | ||
|
|
ef6b1617c7 | ||
|
|
fb36b2b0ca | ||
|
|
6895baf460 | ||
|
|
bc46010419 | ||
|
|
3ef67e76ce | ||
|
|
78c7f1a653 | ||
|
|
ac6fa9ba9e | ||
|
|
8f548752dd | ||
|
|
0850968808 | ||
|
|
b3f90cfda5 | ||
|
|
72f91e5357 | ||
|
|
5c6c92b7a8 | ||
|
|
21d187da69 | ||
|
|
0e72c9e6ac | ||
|
|
6f5b258639 | ||
|
|
08ce66f28a | ||
|
|
a8f4b48334 | ||
|
|
2498a9f3f2 | ||
|
|
84115cd079 | ||
|
|
b80b97586f | ||
|
|
124178fdec | ||
|
|
0a856f0036 | ||
|
|
33e4c34ebf | ||
|
|
1a05163588 | ||
|
|
a3fa564cb1 | ||
|
|
ac503c2e6d | ||
|
|
108a094fb1 | ||
|
|
04451a671c | ||
|
|
dac74783d2 | ||
|
|
7824214cf5 | ||
|
|
47f01080df | ||
|
|
ea25d7269e | ||
|
|
c0a9912bb4 | ||
|
|
6abe6726bc | ||
|
|
0a3eb676d9 | ||
|
|
a4f2467498 | ||
|
|
ba4ed34a8e | ||
|
|
fbd482b8d3 | ||
|
|
c0941600fa | ||
|
|
b447b178e1 |
41
.devcontainer/devcontainer.json
Normal file
41
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "GitHub Actions (JavaScript)",
|
||||
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
|
||||
"postCreateCommand": "npm install",
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"openFiles": ["README.md"]
|
||||
},
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"bierner.markdown-preview-github-styles",
|
||||
"davidanson.vscode-markdownlint",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"github.copilot",
|
||||
"github.copilot-chat",
|
||||
"github.vscode-github-actions",
|
||||
"github.vscode-pull-request-github",
|
||||
"me-dutour-mathieu.vscode-github-actions",
|
||||
"redhat.vscode-yaml",
|
||||
"rvest.vs-code-prettier-eslint",
|
||||
"yzhang.markdown-all-in-one"
|
||||
],
|
||||
"settings": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.tabSize": 2,
|
||||
"editor.formatOnSave": true,
|
||||
"markdown.extension.list.indentationSize": "adaptive",
|
||||
"markdown.extension.italic.indicator": "_",
|
||||
"markdown.extension.orderedList.marker": "one"
|
||||
}
|
||||
}
|
||||
},
|
||||
"remoteEnv": {
|
||||
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
|
||||
},
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers-contrib/features/prettier:1": {}
|
||||
}
|
||||
}
|
||||
59
.env.example
Normal file
59
.env.example
Normal file
@@ -0,0 +1,59 @@
|
||||
# Do not commit your actual .env file to Git! This may contain secrets or other
|
||||
# private information.
|
||||
|
||||
# Enable/disable step debug logging (default: `false`). For local debugging, it
|
||||
# may be useful to set it to `true`.
|
||||
ACTIONS_STEP_DEBUG=true
|
||||
|
||||
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
|
||||
# Hyphens should not be converted to underscores!
|
||||
INPUT_MILLISECONDS=2400
|
||||
|
||||
# GitHub Actions default environment variables. These are set for every run of a
|
||||
# workflow and can be used in your actions. Setting the value here will override
|
||||
# any value set by the local-action tool.
|
||||
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
|
||||
|
||||
# CI="true"
|
||||
# GITHUB_ACTION=""
|
||||
# GITHUB_ACTION_PATH=""
|
||||
# GITHUB_ACTION_REPOSITORY=""
|
||||
# GITHUB_ACTIONS=""
|
||||
# GITHUB_ACTOR=""
|
||||
# GITHUB_ACTOR_ID=""
|
||||
# GITHUB_API_URL=""
|
||||
# GITHUB_BASE_REF=""
|
||||
# GITHUB_ENV=""
|
||||
# GITHUB_EVENT_NAME=""
|
||||
# GITHUB_EVENT_PATH=""
|
||||
# GITHUB_GRAPHQL_URL=""
|
||||
# GITHUB_HEAD_REF=""
|
||||
# GITHUB_JOB=""
|
||||
# GITHUB_OUTPUT=""
|
||||
# GITHUB_PATH=""
|
||||
# GITHUB_REF=""
|
||||
# GITHUB_REF_NAME=""
|
||||
# GITHUB_REF_PROTECTED=""
|
||||
# GITHUB_REF_TYPE=""
|
||||
# GITHUB_REPOSITORY=""
|
||||
# GITHUB_REPOSITORY_ID=""
|
||||
# GITHUB_REPOSITORY_OWNER=""
|
||||
# GITHUB_REPOSITORY_OWNER_ID=""
|
||||
# GITHUB_RETENTION_DAYS=""
|
||||
# GITHUB_RUN_ATTEMPT=""
|
||||
# GITHUB_RUN_ID=""
|
||||
# GITHUB_RUN_NUMBER=""
|
||||
# GITHUB_SERVER_URL=""
|
||||
# GITHUB_SHA=""
|
||||
# GITHUB_STEP_SUMMARY=""
|
||||
# GITHUB_TRIGGERING_ACTOR=""
|
||||
# GITHUB_WORKFLOW=""
|
||||
# GITHUB_WORKFLOW_REF=""
|
||||
# GITHUB_WORKFLOW_SHA=""
|
||||
# GITHUB_WORKSPACE=""
|
||||
# RUNNER_ARCH=""
|
||||
# RUNNER_DEBUG=""
|
||||
# RUNNER_NAME=""
|
||||
# RUNNER_OS=""
|
||||
# RUNNER_TEMP=""
|
||||
# RUNNER_TOOL_CACHE=""
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
dist/** -diff linguist-generated=true
|
||||
5
.github/codeql/codeql-config.yml
vendored
Normal file
5
.github/codeql/codeql-config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
name: JavaScript CodeQL Configuration
|
||||
|
||||
paths-ignore:
|
||||
- node_modules
|
||||
- dist
|
||||
29
.github/dependabot.yml
vendored
29
.github/dependabot.yml
vendored
@@ -1,9 +1,26 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Enable version updates for npm
|
||||
- package-ecosystem: "npm"
|
||||
# Look for `package.json` and `lock` files in the `root` directory
|
||||
directory: "/"
|
||||
# Check the npm registry for updates every day (weekdays)
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: "daily"
|
||||
interval: weekly
|
||||
groups:
|
||||
actions-minor:
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
npm-development:
|
||||
dependency-type: development
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
npm-production:
|
||||
dependency-type: production
|
||||
update-types:
|
||||
- patch
|
||||
|
||||
76
.github/workflows/check-dist.yml
vendored
Normal file
76
.github/workflows/check-dist.yml
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# In JavaScript actions, `dist/` is a special directory. When you reference
|
||||
# an action with the `uses:` property, `dist/index.js` is the code that will be
|
||||
# run. For this project, the `dist/index.js` file is transpiled from other
|
||||
# source files. This workflow ensures the `dist/` directory contains the
|
||||
# expected transpiled code.
|
||||
#
|
||||
# If this workflow is run from a feature branch, it will act as an additional CI
|
||||
# check and fail if the checked-in `dist/` directory does not match what is
|
||||
# expected from the build.
|
||||
name: Check Transpiled JavaScript
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
name: Check dist/
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checkout the repository.
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Setup Node.js using the version specified in `.node-version`.
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
# Install dependencies using `npm ci`.
|
||||
- name: Install Dependencies
|
||||
id: install
|
||||
run: npm ci
|
||||
|
||||
# Build the `dist/` directory.
|
||||
- name: Build dist/ Directory
|
||||
id: build
|
||||
run: npm run bundle
|
||||
|
||||
# This will fail the workflow if the `dist/` directory is different than
|
||||
# expected.
|
||||
- name: Compare Directories
|
||||
id: diff
|
||||
run: |
|
||||
if [ ! -d dist/ ]; then
|
||||
echo "Expected dist/ directory does not exist. See status below:"
|
||||
ls -la ./
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff --ignore-space-at-eol --text dist/
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If `dist/` was different than expected, upload the expected version as a
|
||||
# workflow artifact.
|
||||
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
|
||||
name: Upload Artifact
|
||||
id: upload
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
64
.github/workflows/ci.yml
vendored
Normal file
64
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-javascript:
|
||||
name: JavaScript Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
id: npm-ci
|
||||
run: npm ci
|
||||
|
||||
- name: Check Format
|
||||
id: npm-format-check
|
||||
run: npm run format:check
|
||||
|
||||
- name: Lint
|
||||
id: npm-lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Test
|
||||
id: npm-ci-test
|
||||
run: npm run ci-test
|
||||
|
||||
test-action:
|
||||
name: GitHub Actions Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Test Local Action
|
||||
id: test-action
|
||||
uses: ./
|
||||
with:
|
||||
milliseconds: 1000
|
||||
|
||||
- name: Print Output
|
||||
id: output
|
||||
run: echo "${{ steps.test-action.outputs.time }}"
|
||||
73
.github/workflows/codeql-analysis.yml
vendored
Normal file
73
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: '24 5 * * 6'
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ['javascript']
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
config-file: ./.github/codeql/codeql-config.yml
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
60
.github/workflows/linter.yml
vendored
Normal file
60
.github/workflows/linter.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# 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
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
statuses: write
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint Codebase
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checkout the repository.
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Setup Node.js using the version specified in `.node-version`.
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
# Install dependencies using `npm ci`.
|
||||
- name: Install Dependencies
|
||||
id: install
|
||||
run: npm ci
|
||||
|
||||
# Lint the codebase using the `super-linter/super-linter` action.
|
||||
- name: Lint Codebase
|
||||
id: super-linter
|
||||
uses: super-linter/super-linter/slim@v7
|
||||
env:
|
||||
DEFAULT_BRANCH: main
|
||||
FILTER_REGEX_EXCLUDE: dist/**/*
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
LINTER_RULES_PATH: ${{ github.workspace }}
|
||||
VALIDATE_ALL_CODEBASE: true
|
||||
VALIDATE_JAVASCRIPT_ES: false
|
||||
VALIDATE_JAVASCRIPT_STANDARD: false
|
||||
VALIDATE_JSCPD: false
|
||||
VALIDATE_JSON: false
|
||||
25
.github/workflows/test.yml
vendored
25
.github/workflows/test.yml
vendored
@@ -1,25 +0,0 @@
|
||||
name: "units-test"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'releases/*'
|
||||
|
||||
jobs:
|
||||
# unit tests
|
||||
units:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
||||
# test action works running from the graph
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
milliseconds: 1000
|
||||
49
.gitignore
vendored
49
.gitignore
vendored
@@ -1,14 +1,17 @@
|
||||
node_modules/
|
||||
|
||||
# Editors
|
||||
.vscode
|
||||
# Dependency directory
|
||||
node_modules
|
||||
|
||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
@@ -21,11 +24,12 @@ lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
@@ -37,12 +41,15 @@ bower_components
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Other Dependency directories
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
@@ -60,6 +67,36 @@ typings/
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
|
||||
# IDE files
|
||||
.idea
|
||||
*.code-workspace
|
||||
|
||||
24
.markdown-lint.yml
Normal file
24
.markdown-lint.yml
Normal file
@@ -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
.node-version
Normal file
1
.node-version
Normal file
@@ -0,0 +1 @@
|
||||
20.9.0
|
||||
4
.prettierignore
Normal file
4
.prettierignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
dist/
|
||||
node_modules/
|
||||
coverage/
|
||||
16
.prettierrc.yml
Normal file
16
.prettierrc.yml
Normal file
@@ -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
|
||||
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Action",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "npx",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"args": ["local-action", ".", "src/main.js", ".env"],
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": ["<node_internals>/**", "node_modules/**"]
|
||||
}
|
||||
]
|
||||
}
|
||||
12
.yaml-lint.yml
Normal file
12
.yaml-lint.yml
Normal file
@@ -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
|
||||
7
CODEOWNERS
Normal file
7
CODEOWNERS
Normal file
@@ -0,0 +1,7 @@
|
||||
############################################################################
|
||||
# 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
|
||||
4
LICENSE
4
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 GitHub Actions
|
||||
Copyright 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
|
||||
@@ -18,4 +18,4 @@ 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.
|
||||
SOFTWARE.
|
||||
287
README.md
287
README.md
@@ -1,114 +1,231 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/actions/javascript-action/actions"><img alt="javscript-action status" src="https://github.com/actions/javascript-action/workflows/units-test/badge.svg"></a>
|
||||
</p>
|
||||
|
||||
# Create a JavaScript Action
|
||||
|
||||
Use this template to bootstrap the creation of a JavaScript action.:rocket:
|
||||
[](https://github.com/super-linter/super-linter)
|
||||

|
||||
|
||||
This template includes tests, linting, a validation workflow, publishing, and versioning guidance.
|
||||
Use this template to bootstrap the creation of a JavaScript action. :rocket:
|
||||
|
||||
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
|
||||
This template includes compilation support, tests, a validation workflow,
|
||||
publishing, and versioning guidance.
|
||||
|
||||
## Create an action from this template
|
||||
If you are new, there's also a simpler introduction in the
|
||||
[Hello world JavaScript action repository](https://github.com/actions/hello-world-javascript-action).
|
||||
|
||||
Click the `Use this Template` and provide the new repo details for your action
|
||||
## Create Your Own Action
|
||||
|
||||
## Code in Main
|
||||
To create your own action, you can use this repository as a template! Just
|
||||
follow the below instructions:
|
||||
|
||||
Install the dependencies
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
1. Click the **Use this template** button at the top of the repository
|
||||
1. Select **Create a new repository**
|
||||
1. Select an owner and name for your new repository
|
||||
1. Click **Create repository**
|
||||
1. Clone your new repository
|
||||
|
||||
Run the tests :heavy_check_mark:
|
||||
```bash
|
||||
$ npm test
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> Make sure to remove or update the [`CODEOWNERS`](./CODEOWNERS) file! For
|
||||
> details on how to use this file, see
|
||||
> [About code owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).
|
||||
|
||||
PASS ./index.test.js
|
||||
✓ throws invalid number (3ms)
|
||||
✓ wait 500 ms (504ms)
|
||||
✓ test runs (95ms)
|
||||
## Initial Setup
|
||||
|
||||
...
|
||||
```
|
||||
After you've cloned the repository to your local machine or codespace, you'll
|
||||
need to perform some initial setup steps before you can develop your action.
|
||||
|
||||
## Change action.yml
|
||||
> [!NOTE]
|
||||
>
|
||||
> You'll need to have a reasonably modern version of
|
||||
> [Node.js](https://nodejs.org) handy. If you are using a version manager like
|
||||
> [`nodenv`](https://github.com/nodenv/nodenv) or
|
||||
> [`nvm`](https://github.com/nvm-sh/nvm), you can run `nodenv install` in the
|
||||
> root of your repository to install the version specified in
|
||||
> [`package.json`](./package.json). Otherwise, 20.x or later should work!
|
||||
|
||||
The action.yml contains defines the inputs and output for your action.
|
||||
1. :hammer_and_wrench: Install the dependencies
|
||||
|
||||
Update the action.yml with your name, description, inputs and outputs for your action.
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
|
||||
1. :building_construction: Package the JavaScript for distribution
|
||||
|
||||
## Change the Code
|
||||
```bash
|
||||
npm run bundle
|
||||
```
|
||||
|
||||
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
|
||||
1. :white_check_mark: Run the tests
|
||||
|
||||
```javascript
|
||||
const core = require('@actions/core');
|
||||
...
|
||||
```bash
|
||||
$ npm test
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
...
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
PASS ./index.test.js
|
||||
✓ throws invalid number (3ms)
|
||||
✓ wait 500 ms (504ms)
|
||||
✓ test runs (95ms)
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
## Update the Action Metadata
|
||||
|
||||
The [`action.yml`](action.yml) file defines metadata about your action, such as
|
||||
input(s) and output(s). For details about this file, see
|
||||
[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions).
|
||||
|
||||
When you copy this repository, update `action.yml` with the name, description,
|
||||
inputs, and outputs for your action.
|
||||
|
||||
## Update the Action Code
|
||||
|
||||
The [`src/`](./src/) directory is the heart of your action! This contains the
|
||||
source code that will be run when your action is invoked. You can replace the
|
||||
contents of this directory with your own code.
|
||||
|
||||
There are a few things to keep in mind when writing your action code:
|
||||
|
||||
- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously.
|
||||
In `main.js`, you will see that the action is run in an `async` function.
|
||||
|
||||
```javascript
|
||||
const core = require('@actions/core')
|
||||
//...
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
//...
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
run()
|
||||
For more information about the GitHub Actions toolkit, see the
|
||||
[documentation](https://github.com/actions/toolkit/blob/main/README.md).
|
||||
|
||||
So, what are you waiting for? Go ahead and start customizing your action!
|
||||
|
||||
1. Create a new branch
|
||||
|
||||
```bash
|
||||
git checkout -b releases/v1
|
||||
```
|
||||
|
||||
1. Replace the contents of `src/` with your action code
|
||||
1. Add tests to `__tests__/` for your source code
|
||||
1. Format, test, and build the action
|
||||
|
||||
```bash
|
||||
npm run all
|
||||
```
|
||||
|
||||
> This step is important! It will run [`ncc`](https://github.com/vercel/ncc)
|
||||
> to build the final JavaScript action code with all dependencies included.
|
||||
> If you do not run this step, your action will not work correctly when it is
|
||||
> used in a workflow. This step also includes the `--license` option for
|
||||
> `ncc`, which will create a license file for all of the production node
|
||||
> modules used in your project.
|
||||
|
||||
1. (Optional) Test your action locally
|
||||
|
||||
The [`@github/local-action`](https://github.com/github/local-action) utility
|
||||
can be used to test your action locally. It is a simple command-line tool
|
||||
that "stubs" (or simulates) the GitHub Actions Toolkit. This way, you can run
|
||||
your JavaScript action locally without having to commit and push your changes
|
||||
to a repository.
|
||||
|
||||
The `local-action` utility can be run in the following ways:
|
||||
|
||||
- Visual Studio Code Debugger
|
||||
|
||||
Make sure to review and, if needed, update
|
||||
[`.vscode/launch.json`](./.vscode/launch.json)
|
||||
|
||||
- Terminal/Command Prompt
|
||||
|
||||
```bash
|
||||
# npx local action <action-yaml-path> <entrypoint> <dotenv-file>
|
||||
npx local-action . src/main.js .env
|
||||
```
|
||||
|
||||
You can provide a `.env` file to the `local-action` CLI to set environment
|
||||
variables used by the GitHub Actions Toolkit. For example, setting inputs and
|
||||
event payload data used by your action. For more information, see the example
|
||||
file, [`.env.example`](./.env.example), and the
|
||||
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
|
||||
|
||||
1. Commit your changes
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "My first action is ready!"
|
||||
```
|
||||
|
||||
1. Push them to your repository
|
||||
|
||||
```bash
|
||||
git push -u origin releases/v1
|
||||
```
|
||||
|
||||
1. Create a pull request and get feedback on your action
|
||||
1. Merge the pull request into the `main` branch
|
||||
|
||||
Your action is now published! :rocket:
|
||||
|
||||
For information about versioning your action, see
|
||||
[Versioning](https://github.com/actions/toolkit/blob/main/docs/action-versioning.md)
|
||||
in the GitHub Actions toolkit.
|
||||
|
||||
## Validate the Action
|
||||
|
||||
You can now validate the action by referencing it in a workflow file. For
|
||||
example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an
|
||||
action in the same repository.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Test Local Action
|
||||
id: test-action
|
||||
uses: ./
|
||||
with:
|
||||
milliseconds: 1000
|
||||
|
||||
- name: Print Output
|
||||
id: output
|
||||
run: echo "${{ steps.test-action.outputs.time }}"
|
||||
```
|
||||
|
||||
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
|
||||
|
||||
## Package for distribution
|
||||
|
||||
GitHub Actions will run the entry point from the action.yml. Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules.
|
||||
|
||||
Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder.
|
||||
|
||||
Run prepare
|
||||
|
||||
```bash
|
||||
npm run prepare
|
||||
```
|
||||
|
||||
Since the packaged index.js is run from the dist folder.
|
||||
|
||||
```bash
|
||||
git add dist
|
||||
```
|
||||
|
||||
## Create a release branch
|
||||
|
||||
Users shouldn't consume the action from master since that would be latest code and actions can break compatibility between major versions.
|
||||
|
||||
Checkin to the v1 release branch
|
||||
|
||||
```bash
|
||||
$ git checkout -b v1
|
||||
$ git commit -a -m "v1 release"
|
||||
```
|
||||
|
||||
```bash
|
||||
$ git push origin v1
|
||||
```
|
||||
|
||||
Your action is now published! :rocket:
|
||||
|
||||
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
|
||||
For example workflow runs, check out the
|
||||
[Actions tab](https://github.com/actions/javascript-action/actions)! :rocket:
|
||||
|
||||
## Usage
|
||||
|
||||
You can now consume the action by referencing the v1 branch
|
||||
After testing, you can create version tag(s) that developers can use to
|
||||
reference different stable versions of your action. For more information, see
|
||||
[Versioning](https://github.com/actions/toolkit/blob/main/docs/action-versioning.md)
|
||||
in the GitHub Actions toolkit.
|
||||
|
||||
To include the action in a workflow in another repository, you can use the
|
||||
`uses` syntax with the `@` symbol to reference a specific branch, tag, or commit
|
||||
hash.
|
||||
|
||||
```yaml
|
||||
uses: actions/javascript-action@v1
|
||||
with:
|
||||
milliseconds: 1000
|
||||
```
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:
|
||||
- name: Run my Action
|
||||
id: run-action
|
||||
uses: actions/javascript-action@v1 # Commit with the `v1` tag
|
||||
with:
|
||||
milliseconds: 1000
|
||||
|
||||
- name: Print Output
|
||||
id: output
|
||||
run: echo "${{ steps.run-action.outputs.time }}"
|
||||
```
|
||||
|
||||
12
__fixtures__/core.js
Normal file
12
__fixtures__/core.js
Normal file
@@ -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()
|
||||
3
__fixtures__/wait.js
Normal file
3
__fixtures__/wait.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { jest } from '@jest/globals'
|
||||
|
||||
export const wait = jest.fn()
|
||||
62
__tests__/main.test.js
Normal file
62
__tests__/main.test.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
import { jest } from '@jest/globals'
|
||||
import * as core from '../__fixtures__/core.js'
|
||||
import { wait } from '../__fixtures__/wait.js'
|
||||
|
||||
// Mocks should be declared before the module being tested is imported.
|
||||
jest.unstable_mockModule('@actions/core', () => core)
|
||||
jest.unstable_mockModule('../src/wait.js', () => ({ wait }))
|
||||
|
||||
// The module being tested should be imported dynamically. This ensures that the
|
||||
// mocks are used in place of any actual dependencies.
|
||||
const { run } = await import('../src/main.js')
|
||||
|
||||
describe('main.js', () => {
|
||||
beforeEach(() => {
|
||||
// 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!'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks()
|
||||
})
|
||||
|
||||
it('Sets the time output', async () => {
|
||||
await run()
|
||||
|
||||
// Verify the time output was set.
|
||||
expect(core.setOutput).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'time',
|
||||
// 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 () => {
|
||||
// Clear the getInput mock and return an invalid value.
|
||||
core.getInput.mockClear().mockReturnValueOnce('this is not a number')
|
||||
|
||||
// Clear the wait mock and return a rejected promise.
|
||||
wait
|
||||
.mockClear()
|
||||
.mockRejectedValueOnce(new Error('milliseconds is not a number'))
|
||||
|
||||
await run()
|
||||
|
||||
// Verify that the action was marked as failed.
|
||||
expect(core.setFailed).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'milliseconds is not a number'
|
||||
)
|
||||
})
|
||||
})
|
||||
24
__tests__/wait.test.js
Normal file
24
__tests__/wait.test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Unit tests for src/wait.js
|
||||
*/
|
||||
import { wait } from '../src/wait.js'
|
||||
|
||||
describe('wait.js', () => {
|
||||
it('Throws an invalid number', async () => {
|
||||
const input = parseInt('foo', 10)
|
||||
|
||||
expect(isNaN(input)).toBe(true)
|
||||
|
||||
await expect(wait(input)).rejects.toThrow('milliseconds is not a number')
|
||||
})
|
||||
|
||||
it('Waits with a valid number', async () => {
|
||||
const start = new Date()
|
||||
await wait(500)
|
||||
const end = new Date()
|
||||
|
||||
const delta = Math.abs(end.getTime() - start.getTime())
|
||||
|
||||
expect(delta).toBeGreaterThan(450)
|
||||
})
|
||||
})
|
||||
27
action.yml
27
action.yml
@@ -1,13 +1,24 @@
|
||||
name: 'Wait'
|
||||
description: 'Wait a designated number of milliseconds'
|
||||
name: The name of your action here
|
||||
description: Provide a description 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.
|
||||
inputs:
|
||||
milliseconds: # id of input
|
||||
description: 'number of milliseconds to wait'
|
||||
milliseconds:
|
||||
description: Your input description here
|
||||
required: true
|
||||
default: '1000'
|
||||
|
||||
# Define your outputs here.
|
||||
outputs:
|
||||
time: # output will be available to future steps
|
||||
description: 'The message to output'
|
||||
time:
|
||||
description: Your output description here
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
using: node20
|
||||
main: dist/index.js
|
||||
|
||||
1
badges/coverage.svg
Normal file
1
badges/coverage.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="106" height="20" role="img" aria-label="Coverage: 100%"><title>Coverage: 100%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="106" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="43" height="20" fill="#4c1"/><rect width="106" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="835" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">100%</text><text x="835" y="140" transform="scale(.1)" fill="#fff" textLength="330">100%</text></g></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
27638
dist/index.js
generated
vendored
27638
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
209
dist/licenses.txt
generated
vendored
Normal file
209
dist/licenses.txt
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
Name: @actions/core
|
||||
Version: 1.11.1
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: Actions core lib
|
||||
Repository: git+https://github.com/actions/toolkit.git
|
||||
Homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Name: @actions/http-client
|
||||
Version: 2.2.3
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: Actions Http Client
|
||||
Repository: git+https://github.com/actions/toolkit.git
|
||||
Homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Name: tunnel
|
||||
Version: 0.0.6
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: Node HTTP/HTTPS Agents for tunneling proxies
|
||||
Repository: https://github.com/koichik/node-tunnel.git
|
||||
Homepage: https://github.com/koichik/node-tunnel/
|
||||
Author: Koichi Kobayashi <koichik@improvement.jp>
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Name: undici
|
||||
Version: 5.28.5
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: An HTTP/1.1 client, written from scratch for Node.js
|
||||
Repository: git+https://github.com/nodejs/undici.git
|
||||
Homepage: https://undici.nodejs.org
|
||||
Contributors:
|
||||
Daniele Belardi (https://github.com/dnlup)
|
||||
Ethan Arrowood (https://github.com/ethan-arrowood)
|
||||
Matteo Collina (https://github.com/mcollina)
|
||||
Matthew Aitken (https://github.com/KhafraDev)
|
||||
Robert Nagy (https://github.com/ronag)
|
||||
Szymon Marczak (https://github.com/szmarczak)
|
||||
Tomas Della Vedova (https://github.com/delvedor)
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Name: @fastify/busboy
|
||||
Version: 2.1.1
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: A streaming parser for HTML form data for node.js
|
||||
Repository: git+https://github.com/fastify/busboy.git
|
||||
Author: Brian White <mscdex@mscdex.net>
|
||||
Contributors:
|
||||
Igor Savin <kibertoad@gmail.com> (https://github.com/kibertoad)
|
||||
Aras Abbasi <aras.abbasi@gmail.com> (https://github.com/uzlopak)
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
Copyright Brian White. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Name: @actions/exec
|
||||
Version: 1.1.1
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: Actions exec lib
|
||||
Repository: git+https://github.com/actions/toolkit.git
|
||||
Homepage: https://github.com/actions/toolkit/tree/main/packages/exec
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Name: @actions/io
|
||||
Version: 1.1.3
|
||||
License: MIT
|
||||
Private: false
|
||||
Description: Actions io lib
|
||||
Repository: git+https://github.com/actions/toolkit.git
|
||||
Homepage: https://github.com/actions/toolkit/tree/main/packages/io
|
||||
License Copyright:
|
||||
===
|
||||
|
||||
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.
|
||||
3912
dist/sourcemap-register.js
generated
vendored
3912
dist/sourcemap-register.js
generated
vendored
File diff suppressed because it is too large
Load Diff
61
eslint.config.mjs
Normal file
61
eslint.config.mjs
Normal file
@@ -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'
|
||||
}
|
||||
}
|
||||
]
|
||||
22
index.js
22
index.js
@@ -1,22 +0,0 @@
|
||||
const core = require('@actions/core');
|
||||
const wait = require('./wait');
|
||||
|
||||
|
||||
// most @actions toolkit packages have async methods
|
||||
async function run() {
|
||||
try {
|
||||
const ms = core.getInput('milliseconds');
|
||||
core.info(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
core.debug((new Date()).toTimeString()) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
||||
await wait(parseInt(ms));
|
||||
core.info((new Date()).toTimeString())
|
||||
|
||||
core.setOutput('time', new Date().toTimeString());
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
@@ -1,23 +0,0 @@
|
||||
const wait = require('./wait');
|
||||
const process = require('process');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
test('throws invalid number', async() => {
|
||||
await expect(wait('foo')).rejects.toThrow('milleseconds not a number');
|
||||
});
|
||||
|
||||
test('wait 500 ms', async() => {
|
||||
const start = new Date();
|
||||
await wait(500);
|
||||
const end = new Date();
|
||||
var delta = Math.abs(end - start);
|
||||
expect(delta).toBeGreaterThan(450);
|
||||
});
|
||||
|
||||
// shows how the runner will run a javascript action with env / stdout protocol
|
||||
test('test runs', () => {
|
||||
process.env['INPUT_MILLISECONDS'] = 500;
|
||||
const ip = path.join(__dirname, 'index.js');
|
||||
console.log(cp.execSync(`node ${ip}`, { env: process.env }).toString());
|
||||
})
|
||||
30
jest.config.js
Normal file
30
jest.config.js
Normal file
@@ -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
|
||||
13818
package-lock.json
generated
13818
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
70
package.json
70
package.json
@@ -1,35 +1,63 @@
|
||||
{
|
||||
"name": "javascript-action",
|
||||
"version": "1.0.0",
|
||||
"description": "JavaScript Action Template",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint index.js",
|
||||
"prepare": "ncc build index.js -o dist --source-map",
|
||||
"test": "jest",
|
||||
"all": "npm run lint && npm run prepare && npm run test"
|
||||
},
|
||||
"description": "GitHub Actions JavaScript Template",
|
||||
"version": "0.0.0",
|
||||
"author": "",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"homepage": "https://github.com/actions/javascript-action#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/javascript-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"GitHub",
|
||||
"Actions",
|
||||
"JavaScript"
|
||||
],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/javascript-action/issues"
|
||||
},
|
||||
"homepage": "https://github.com/actions/javascript-action#readme",
|
||||
"keywords": [
|
||||
"actions"
|
||||
],
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"bundle": "npm run format:write && npm run package",
|
||||
"ci-test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest",
|
||||
"coverage": "npx make-coverage-badge --output-path ./badges/coverage.svg",
|
||||
"format:write": "npx prettier --write .",
|
||||
"format:check": "npx prettier --check .",
|
||||
"lint": "npx eslint .",
|
||||
"local-action": "npx local-action . src/main.js .env",
|
||||
"package": "npx rollup --config rollup.config.js",
|
||||
"package:watch": "npm run package -- --watch",
|
||||
"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"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.1.1"
|
||||
"@actions/core": "^1.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.4.0",
|
||||
"jest": "^26.1.0"
|
||||
"@eslint/compat": "^1.2.6",
|
||||
"@github/local-action": "^2.6.1",
|
||||
"@jest/globals": "^29.7.0",
|
||||
"@rollup/plugin-commonjs": "^28.0.2",
|
||||
"@rollup/plugin-node-resolve": "^16.0.0",
|
||||
"eslint": "^9.20.1",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-prettier": "^5.2.3",
|
||||
"jest": "^29.7.0",
|
||||
"make-coverage-badge": "^1.2.0",
|
||||
"prettier": "^3.5.0",
|
||||
"prettier-eslint": "^16.3.0",
|
||||
"rollup": "^4.34.6",
|
||||
"rollup-plugin-license": "^3.5.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "*"
|
||||
}
|
||||
}
|
||||
|
||||
27
rollup.config.js
Normal file
27
rollup.config.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// See: https://rollupjs.org/introduction/
|
||||
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||
import license from 'rollup-plugin-license'
|
||||
|
||||
const config = {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
esModule: true,
|
||||
file: 'dist/index.js',
|
||||
format: 'es',
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: [
|
||||
commonjs(),
|
||||
nodeResolve({ preferBuiltins: true }),
|
||||
license({
|
||||
sourcemap: true,
|
||||
thirdParty: {
|
||||
output: 'dist/licenses.txt'
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
export default config
|
||||
8
src/index.js
Normal file
8
src/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* The entrypoint for the action. This file simply imports and runs the action's
|
||||
* main logic.
|
||||
*/
|
||||
import { run } from './main.js'
|
||||
|
||||
/* istanbul ignore next */
|
||||
run()
|
||||
27
src/main.js
Normal file
27
src/main.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as core from '@actions/core'
|
||||
import { wait } from './wait.js'
|
||||
|
||||
/**
|
||||
* The main function for the action.
|
||||
*
|
||||
* @returns {Promise<void>} Resolves when the action is complete.
|
||||
*/
|
||||
export async function run() {
|
||||
try {
|
||||
const ms = core.getInput('milliseconds')
|
||||
|
||||
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
|
||||
core.debug(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
// Log the current timestamp, wait, then log the new timestamp
|
||||
core.debug(new Date().toTimeString())
|
||||
await wait(parseInt(ms, 10))
|
||||
core.debug(new Date().toTimeString())
|
||||
|
||||
// Set outputs for other workflow steps to use
|
||||
core.setOutput('time', new Date().toTimeString())
|
||||
} catch (error) {
|
||||
// Fail the workflow run if an error occurs
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
13
src/wait.js
Normal file
13
src/wait.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Waits for a number of milliseconds.
|
||||
*
|
||||
* @param {number} milliseconds The number of milliseconds to wait.
|
||||
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
|
||||
*/
|
||||
export async function wait(milliseconds) {
|
||||
return new Promise((resolve) => {
|
||||
if (isNaN(milliseconds)) throw new Error('milliseconds is not a number')
|
||||
|
||||
setTimeout(() => resolve('done!'), milliseconds)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user