Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: actions/typescript-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: dsanders11/typescript-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: tweaks
Choose a head ref
  • 9 commits
  • 23 files changed
  • 1 contributor

Commits on Aug 23, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    1d68510 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    5804007 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    8035549 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    7338e36 View commit details
  5. chore: remove CODEOWNERS

    dsanders11 committed Aug 23, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    575abe3 View commit details
  6. ci: pin actions by SHA

    dsanders11 committed Aug 23, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    a12ff73 View commit details
  7. ci: do semantic releases

    dsanders11 committed Aug 23, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    da68a95 View commit details
  8. chore: enforce semicolons

    dsanders11 committed Aug 23, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    d7b581f View commit details
  9. test: switch to vitest

    dsanders11 committed Aug 23, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    dsanders11 David Sanders
    Copy the full SHA
    a1f82ef View commit details
26 changes: 0 additions & 26 deletions .github/dependabot.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
env:
node: true
es6: true
jest: true

globals:
Atomics: readonly
@@ -24,15 +23,15 @@ parserOptions:
- './tsconfig.json'

plugins:
- jest
- vitest
- '@typescript-eslint'

extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- plugin:jest/recommended
- plugin:vitest/legacy-recommended

rules:
{
@@ -76,7 +75,7 @@ rules:
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/semi': 'error',
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
6 changes: 3 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -28,11 +28,11 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm
@@ -66,7 +66,7 @@ jobs:
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: dist
path: dist/
21 changes: 18 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -19,11 +19,11 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm
@@ -51,7 +51,7 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Test Local Action
id: test-action
@@ -62,3 +62,18 @@ jobs:
- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"

release:
name: release
runs-on: ubuntu-latest
needs: test-typescript
if: github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -30,19 +30,19 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Initialize CodeQL
id: initialize
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@f0f3afee809481da311ca3a6ff1ff51d81dbeb24 # v3.26.4
with:
languages: ${{ matrix.language }}
source-root: src

- name: Autobuild
id: autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@f0f3afee809481da311ca3a6ff1ff51d81dbeb24 # v3.26.4

- name: Perform CodeQL Analysis
id: analyze
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@f0f3afee809481da311ca3a6ff1ff51d81dbeb24 # v3.26.4
6 changes: 3 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -21,13 +21,13 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version-file: .node-version
cache: npm
@@ -38,7 +38,7 @@ jobs:

- name: Lint Codebase
id: super-linter
uses: super-linter/super-linter/slim@v7
uses: super-linter/super-linter/slim@02a1172d274f021e4c70f66e23f1085eadd1064b # v7.0.0
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
26 changes: 26 additions & 0 deletions .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Check Semantic Commit'

on:
pull_request:
types:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
main:
permissions:
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- name: semantic-pull-request
uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 # v5.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: false
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npm run package
git add -A dist

2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
8 changes: 8 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
],
"branches": ["main"]
}
3 changes: 0 additions & 3 deletions CODEOWNERS

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg)
[![Check dist/](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml)
[![CodeQL](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml)
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)

Use this template to bootstrap the creation of a TypeScript action. :rocket:

@@ -93,14 +92,14 @@ There are a few things to keep in mind when writing your action code:
In `main.ts`, you will see that the action is run in an `async` function.

```javascript
import * as core from '@actions/core'
import * as core from '@actions/core';
//...

async function run() {
try {
//...
} catch (error) {
core.setFailed(error.message)
core.setFailed(error.message);
}
}
```
15 changes: 8 additions & 7 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -2,16 +2,17 @@
* Unit tests for the action's entrypoint, src/index.ts
*/

import * as main from '../src/main'
import { describe, expect, it, vi } from 'vitest';

import * as main from '../src/main';

// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()
const runMock = vi.spyOn(main, 'run').mockReset();

describe('index', () => {
it('calls run when imported', async () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../src/index')
await import('../src/index');

expect(runMock).toHaveBeenCalled()
})
})
expect(runMock).toHaveBeenCalled();
});
});
73 changes: 36 additions & 37 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -6,84 +6,83 @@
* variables following the pattern `INPUT_<INPUT_NAME>`.
*/

import * as core from '@actions/core'
import * as main from '../src/main'
import { beforeEach, describe, expect, it, vi } from 'vitest';

import * as core from '@actions/core';
import * as main from '../src/main';

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')
const runMock = vi.spyOn(main, 'run');

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/
const timeRegex = /^\d{2}:\d{2}:\d{2}/;

// Mock the GitHub Actions core library
let debugMock: jest.SpiedFunction<typeof core.debug>
let errorMock: jest.SpiedFunction<typeof core.error>
let getInputMock: jest.SpiedFunction<typeof core.getInput>
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
const debugMock = vi.spyOn(core, 'debug');
const errorMock = vi.spyOn(core, 'error');
const getInputMock = vi.spyOn(core, 'getInput');
const setFailedMock = vi.spyOn(core, 'setFailed');
const setOutputMock = vi.spyOn(core, 'setOutput');

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

debugMock = jest.spyOn(core, 'debug').mockImplementation()
errorMock = jest.spyOn(core, 'error').mockImplementation()
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})
vi.clearAllMocks();
});

it('sets the time output', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return '500'
return '500';
default:
return ''
return '';
}
})
});

await main.run()
expect(runMock).toHaveReturned()
await main.run();
expect(runMock).toHaveReturned();

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
expect(debugMock).toHaveBeenNthCalledWith(
1,
'Waiting 500 milliseconds ...'
);
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
)
);
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
)
);
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
)
expect(errorMock).not.toHaveBeenCalled()
})
);
expect(errorMock).not.toHaveBeenCalled();
});

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
return 'this is not a number';
default:
return ''
return '';
}
})
});

await main.run()
expect(runMock).toHaveReturned()
await main.run();
expect(runMock).toHaveReturned();

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
)
expect(errorMock).not.toHaveBeenCalled()
})
})
);
expect(errorMock).not.toHaveBeenCalled();
});
});
Loading