diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e6d223..457aa00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,3 +43,5 @@ jobs: - name: Test id: npm-ci-test run: npm run ci-test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/__tests__/kit-release.test.ts b/__tests__/kit-release.test.ts index f689862..d9fb8c2 100644 --- a/__tests__/kit-release.test.ts +++ b/__tests__/kit-release.test.ts @@ -1,4 +1,5 @@ import { findMatchingRelease, getReleases } from '../src/releases/kit-release' +import { getToken } from './test-utils' describe('getReleases', () => { beforeEach(() => { @@ -25,14 +26,3 @@ describe('getReleases', () => { }) }) -function getToken(): string { - const token = process.env['GITHUB_TOKEN'] || '' - if (!token) { - /* eslint-disable-next-line no-console */ - console.warn( - 'Skipping GitHub tests. Set $GITHUB_TOKEN to run GitHub tests.' - ) - } - - return token -} diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 20e3d40..6fd1660 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -8,6 +8,7 @@ import * as core from '@actions/core' import * as main from '../src/main' +import { getToken } from './test-utils' // Mock the action's main function const runMock = jest.spyOn(main, 'run') @@ -26,7 +27,7 @@ describe('action', () => { getInputMock.mockImplementation(name => { switch (name) { case 'token': - return process.env['GITHUB_TOKEN'] || '' + return getToken() case 'version': return 'latest' default: diff --git a/__tests__/test-utils.ts b/__tests__/test-utils.ts new file mode 100644 index 0000000..c4eb088 --- /dev/null +++ b/__tests__/test-utils.ts @@ -0,0 +1,12 @@ + +export function getToken(): string { + const token = process.env['GITHUB_TOKEN'] || '' + if (!token) { + /* eslint-disable-next-line no-console */ + console.warn( + 'Skipping GitHub tests. Set $GITHUB_TOKEN to run GitHub tests.' + ) + } + + return token + } \ No newline at end of file