测试初始化

This commit is contained in:
ilovintit
2025-06-04 22:11:44 +08:00
commit 0507fb9ced
25 changed files with 40177 additions and 0 deletions
+8
View 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
View File
@@ -0,0 +1,27 @@
import * as core from '@actions/core'
import { wait } from './wait.js'
/**
* The main function for the action.
*
* @returns Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {
const ms: string = 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
View File
@@ -0,0 +1,13 @@
/**
* Waits for a number of milliseconds.
*
* @param milliseconds The number of milliseconds to wait.
* @returns Resolves with 'done!' after the wait is over.
*/
export async function wait(milliseconds: number): Promise<string> {
return new Promise((resolve) => {
if (isNaN(milliseconds)) throw new Error('milliseconds is not a number')
setTimeout(() => resolve('done!'), milliseconds)
})
}