Skip to content

Commit

Permalink
Add environment variable for GitHub token
Browse files Browse the repository at this point in the history
  • Loading branch information
gorkem committed Mar 30, 2024
1 parent c44ba8a commit cde2fb3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ jobs:
- name: Test
id: npm-ci-test
run: npm run ci-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 1 addition & 11 deletions __tests__/kit-release.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { findMatchingRelease, getReleases } from '../src/releases/kit-release'
import { getToken } from './test-utils'

describe('getReleases', () => {
beforeEach(() => {
Expand All @@ -25,14 +26,3 @@ describe('getReleases', () => {
})
})

Check failure on line 28 in __tests__/kit-release.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `⏎`
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
}
3 changes: 2 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions __tests__/test-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Check failure on line 1 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `⏎`
export function getToken(): string {
const token = process.env['GITHUB_TOKEN'] || ''

Check failure on line 3 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`
if (!token) {

Check failure on line 4 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`
/* eslint-disable-next-line no-console */

Check failure on line 5 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Replace `······` with `····`
console.warn(

Check failure on line 6 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`
'Skipping GitHub tests. Set $GITHUB_TOKEN to run GitHub tests.'

Check failure on line 7 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`
)

Check failure on line 8 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`
}

Check failure on line 9 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Replace `····` with `··`

Check failure on line 10 in __tests__/test-utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`
return token
}

0 comments on commit cde2fb3

Please sign in to comment.