Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move configuration file location #112

Merged
merged 26 commits into from Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1791775
temp commit
febuiles Jun 13, 2022
01fa67b
adding dist
febuiles Jun 14, 2022
24d7ef3
Use an empty config options type.
febuiles Jun 14, 2022
efecf6f
Remove the variables from env so they don't default to empty strings.
febuiles Jun 14, 2022
ef97470
Don't set the defaults in the test :/
febuiles Jun 14, 2022
cc31018
Updating dist.
febuiles Jun 14, 2022
e56fe29
Remove old config file.
febuiles Jun 14, 2022
b5b4910
Adding the config definition to action.yml
febuiles Jun 14, 2022
7278093
Clarify some of the error messages.
febuiles Jun 14, 2022
3eff3f5
let => const
febuiles Jun 14, 2022
76ad376
Adding more tests for the config file.
febuiles Jun 14, 2022
3355ec4
adding dist
febuiles Jun 14, 2022
c973154
Dashes instead of underscores.
febuiles Jun 14, 2022
b0e1f38
Linting YAML
febuiles Jun 14, 2022
f83a407
Use the correct name for allowlists.
febuiles Jun 14, 2022
fd6e756
Updating readConfig() to be more readable, get rid of typecasts.
febuiles Jun 14, 2022
2860b57
Update README.md
febuiles Jun 14, 2022
00be2ce
Typos.
febuiles Jun 14, 2022
0b87f02
Document how we test inputs
febuiles Jun 14, 2022
42e2bc1
Handle unknown licenses.
febuiles Jun 14, 2022
c6587b6
Updating README with instructions for unknown licenses.
febuiles Jun 14, 2022
54764c9
Update README.md
courtneycl Jun 14, 2022
871f406
adding doc for protected branches
courtneycl Jun 15, 2022
dfd5196
Update schemas.ts
courtneycl Jun 15, 2022
faa63c3
adding dist
febuiles Jun 15, 2022
f3f3519
Merge branch 'main' into move-config-file
febuiles Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 26 additions & 18 deletions __tests__/config.test.ts
@@ -1,31 +1,39 @@
import {expect, test} from '@jest/globals'
import {readConfigFile} from '../src/config'
import * as core from '@actions/core'
import {expect, test, jest, beforeEach} from '@jest/globals'
import {readConfig} from '../src/config'

test('reads the config file', async () => {
let options = readConfigFile('./__tests__/fixtures/config-allow-sample.yml')
expect(options.fail_on_severity).toEqual('critical')
expect(options.allow_licenses).toEqual(['BSD', 'GPL 2'])
})

test('the default config path handles .yml and .yaml', async () => {
expect(true).toEqual(true)
beforeEach(() => {
/* reset to our defaults after every test run */
delete process.env['INPUT_FAIL-ON-SEVERITY']
delete process.env['INPUT_ALLOWED-LICENSES']
delete process.env['INPUT_DENY-LICENSES']
})

test('returns a default config when the config file was not found', async () => {
let options = readConfigFile('fixtures/i-dont-exist')
test('it defaults to low severity', async () => {
let options = readConfig()
expect(options.fail_on_severity).toEqual('low')
expect(options.allow_licenses).toEqual(undefined)
})

test('it reads config files with empty options', async () => {
let options = readConfigFile('./__tests__/fixtures/no-licenses-config.yml')
test('it reads custom configs', async () => {
process.env['INPUT_FAIL-ON-SEVERITY'] = 'critical'
process.env['INPUT_ALLOWED-LICENSES'] = ' BSD, GPL 2 '

let options = readConfig()
expect(options.fail_on_severity).toEqual('critical')
expect(options.allow_licenses).toEqual(['BSD', 'GPL 2'])
})

test('it defaults to empty allow/deny lists ', async () => {
let options = readConfig()

expect(options.allow_licenses).toEqual(undefined)
expect(options.deny_licenses).toEqual(undefined)
})

test('it raises an error if both an allow and denylist are specified', async () => {
expect(() =>
readConfigFile('./__tests__/fixtures/conflictive-config.yml')
).toThrow()
process.env['INPUT_ALLOWED-LICENSES'] = 'MIT'
process.env['INPUT_DENY-LICENSES'] = 'BSD'
expect(() => readConfig()).toThrow()
})

test('it raises an error when given an unknown severity', async () => {})