Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ actions can be run directly on your workstation.
The following table tracks the versions of the GitHub Actions Toolkit that are
currently implemented by this tool.

| Package | Version |
| ------------------- | -------- |
| `@actions/artifact` | `2.2.0` |
| `@actions/core` | `1.11.1` |
| Package | Version |
| ---------------------------------------------------------------------- | -------- |
| [`@actions/artifact`](https://www.npmjs.com/package/@actions/artifact) | `2.3.2` |
| [`@actions/core`](https://www.npmjs.com/package/@actions/core) | `1.11.1` |
| [`@actions/github`](https://www.npmjs.com/package/@actions/github) | `6.0.0` |

## Changelog

Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions __fixtures__/@actions/github.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as octokit from '../@octokit/rest.js'

export const getOctokit = () => octokit
9 changes: 9 additions & 0 deletions __fixtures__/@actions/http-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { jest } from '@jest/globals'

export const getAgent = jest.fn()
export const getAgentDispatcher = jest.fn()

export class HttpClient {
getAgent = getAgent
getAgentDispatcher = getAgentDispatcher
}
18 changes: 18 additions & 0 deletions __fixtures__/@octokit/rest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { jest } from '@jest/globals'
import { Endpoints } from '@octokit/types'

export const graphql = jest.fn()
export const paginate = jest.fn()
export const request = jest.fn()
export const rest = {
actions: {
deleteArtifact:
jest.fn<
() => Endpoints['DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}']['response']
>(),
listWorkflowRunArtifacts:
jest.fn<
() => Endpoints['GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts']['response']
>()
}
}
4 changes: 3 additions & 1 deletion __fixtures__/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const existsSync = jest.fn()
export const mkdirSync = jest.fn()
export const readFileSync = jest.fn()
export const rmSync = jest.fn()
export const statSync = jest.fn()

export default {
accessSync,
Expand All @@ -15,5 +16,6 @@ export default {
existsSync,
mkdirSync,
readFileSync,
rmSync
rmSync,
statSync
}
2 changes: 2 additions & 0 deletions __fixtures__/typescript/success-yaml/.env.fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ACTIONS_STEP_DEBUG=false
INPUT_MILLISECONDS=2400
16 changes: 16 additions & 0 deletions __fixtures__/typescript/success-yaml/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: TypeScript (Success)
description: This action returns without error

inputs:
myInput:
description: An input
required: true
default: value

outputs:
myOutput:
description: An output

runs:
using: node20
main: dist/index.js
Empty file.
104 changes: 104 additions & 0 deletions __fixtures__/typescript/success-yaml/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions __fixtures__/typescript/success-yaml/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "typescript-action",
"description": "GitHub Actions TypeScript template",
"version": "0.0.0",
"engines": {
"node": ">=20"
},
"dependencies": {
"@actions/core": "^1.10.1"
},
"devDependencies": {
"@types/node": "^22.2.0",
"typescript": "^5.5.4"
}
}
3 changes: 3 additions & 0 deletions __fixtures__/typescript/success-yaml/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { run } from './main'

run()
9 changes: 9 additions & 0 deletions __fixtures__/typescript/success-yaml/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getInput, info, setOutput } from '@actions/core'

export async function run(): Promise<void> {
const myInput: string = getInput('myInput')

setOutput('myOutput', myInput)

info('TypeScript Action Succeeded!')
}
20 changes: 20 additions & 0 deletions __fixtures__/typescript/success-yaml/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"rootDir": "./src",
"moduleResolution": "NodeNext",
"baseUrl": "./",
"sourceMap": true,
"outDir": "./dist",
"noImplicitAny": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"newLine": "lf"
},
"exclude": ["node_modules"],
"include": ["src"]
}
19 changes: 18 additions & 1 deletion __tests__/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('Commmand', () => {
})

afterEach(() => {
// Reset all spies
jest.resetAllMocks()
})

Expand Down Expand Up @@ -71,6 +70,24 @@ describe('Commmand', () => {
expect(action).toHaveBeenCalled()
})

it('Runs if all arguments are provided (action.yaml)', async () => {
await (
await makeProgram()
).parseAsync(
[
'./__fixtures__/typescript/success-yaml',
'src/main.ts',
'./__fixtures__/typescript/success-yaml/.env.fixture'
],
{
from: 'user'
}
)

expect(process_exitSpy).not.toHaveBeenCalled()
expect(action).toHaveBeenCalled()
})

it('Exits if no path argument is provided', async () => {
await (await makeProgram()).parseAsync([], { from: 'user' })

Expand Down
3 changes: 1 addition & 2 deletions __tests__/stubs/artifact/internal/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jest } from '@jest/globals'
import * as core from '../../../../__fixtures__/core.js'
import * as core from '../../../../__fixtures__/@actions/core.js'
import { ResetCoreMetadata } from '../../../../src/stubs/core/core.js'
import { EnvMeta, ResetEnvMetadata } from '../../../../src/stubs/env.js'

Expand Down Expand Up @@ -77,7 +77,6 @@ describe('DefaultArtifactClient', () => {
})

afterEach(() => {
// Reset all spies
jest.resetAllMocks()

// Unset environment variables
Expand Down
Loading
Loading