Skip to content

Commit

Permalink
feat: upgrade repolinter version
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypicalpro committed Sep 4, 2020
1 parent abebda9 commit 31e15f9
Show file tree
Hide file tree
Showing 15 changed files with 439 additions and 32,478 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"extends": ["plugin:github/typescript", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
Expand All @@ -11,7 11,9 @@
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-undef": "off",
"no-shadow": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
Expand All @@ -34,6 36,7 @@
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
Expand Down
20 changes: 14 additions & 6 deletions __tests__/getConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 11,32 @@ describe('getConfig', () => {

test('getConfig returns a config from a JSON file', async () => {
const filepath = path.resolve(__dirname, 'testconfig.json')
const expected = JSON.parse(await fs.promises.readFile(filepath, 'utf8'))
const expected = JSON.parse(
await fs.promises.readFile(filepath, 'utf8')
) as Record<string, unknown>
const res = await getConfig({configFile: filepath})

expect(res).toMatchObject(expected)
})

test('getConfig returns a config from a YAML', async () => {
const filepath = path.resolve(__dirname, 'testconfig.yaml')
const expected = yaml.safeLoad(await fs.promises.readFile(filepath, 'utf8'))
const expected = yaml.safeLoad(
await fs.promises.readFile(filepath, 'utf8')
) as Record<string, unknown>
const res = await getConfig({configFile: filepath})

expect(res).toMatchObject(expected as object)
expect(res).toMatchObject(expected)
})

test('getConfig returns a JSON config from a URL', async () => {
// TODO: change this to point to the new relic repo when it goes public
const url =
'https://raw.githubusercontent.com/aperture-science-incorporated/.github/master/repolinter.json'
const filepath = path.resolve(__dirname, 'testconfig.json')
const expected = JSON.parse(await fs.promises.readFile(filepath, 'utf8'))
const expected = JSON.parse(
await fs.promises.readFile(filepath, 'utf8')
) as Record<string, unknown>
const scope = nock('https://raw.githubusercontent.com')
.get('/aperture-science-incorporated/.github/master/repolinter.json')
.replyWithFile(200, filepath)
Expand All @@ -47,14 53,16 @@ describe('getConfig', () => {
const url =
'https://raw.githubusercontent.com/aperture-science-incorporated/.github/master/repolinter.yaml'
const filepath = path.resolve(__dirname, 'testconfig.yaml')
const expected = yaml.safeLoad(await fs.promises.readFile(filepath, 'utf8'))
const expected = yaml.safeLoad(
await fs.promises.readFile(filepath, 'utf8')
) as Record<string, unknown>
const scope = nock('https://raw.githubusercontent.com')
.get('/aperture-science-incorporated/.github/master/repolinter.yaml')
.replyWithFile(200, filepath)

const res = await getConfig({configUrl: url})

expect(res).toMatchObject(expected as object)
expect(res).toMatchObject(expected)

scope.done()
})
Expand Down
20 changes: 10 additions & 10 deletions __tests__/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
import * as cp from 'child_process'
import * as path from 'path'
import * as process from 'process'
import {Inputs} from '../src/inputs'
import {ActionInputs} from '../src/inputs'

async function execAsync(
command: string,
Expand Down Expand Up @@ -33,12 33,12 @@ function getInputName(input: string): string {

function getBaseEnv(): NodeJS.ProcessEnv {
const ret: NodeJS.ProcessEnv = {}
ret[getInputName(Inputs.REPO)] = 'newrelic/repolinter-action'
ret[getInputName(Inputs.OUTPUT_TYPE)] = 'exit-code'
ret[getInputName(Inputs.OUTPUT_NAME)] = 'Open Source Policy Issues'
ret[getInputName(Inputs.LABEL_NAME)] = 'repolinter'
ret[getInputName(Inputs.LABEL_COLOR)] = 'fbca04'
ret[getInputName(Inputs.USERNAME)] = 'github-actions'
ret[getInputName(ActionInputs.REPO)] = 'newrelic/repolinter-action'
ret[getInputName(ActionInputs.OUTPUT_TYPE)] = 'exit-code'
ret[getInputName(ActionInputs.OUTPUT_NAME)] = 'Open Source Policy Issues'
ret[getInputName(ActionInputs.LABEL_NAME)] = 'repolinter'
ret[getInputName(ActionInputs.LABEL_COLOR)] = 'fbca04'
ret[getInputName(ActionInputs.USERNAME)] = 'github-actions'
ret['GITHUB_ACTION'] = 'true'
return ret
}
Expand All @@ -48,7 48,7 @@ describe('integration', () => {

test('runs a failing test config', async () => {
const baseEnv = getBaseEnv()
baseEnv[getInputName(Inputs.CONFIG_FILE)] = path.resolve(
baseEnv[getInputName(ActionInputs.CONFIG_FILE)] = path.resolve(
__dirname,
'testconfig.json'
)
Expand All @@ -63,7 63,7 @@ describe('integration', () => {

test('runs a URL config', async () => {
const baseEnv = getBaseEnv()
baseEnv[getInputName(Inputs.CONFIG_URL)] =
baseEnv[getInputName(ActionInputs.CONFIG_URL)] =
'https://raw.githubusercontent.com/aperture-science-incorporated/.github/master/repolinter.json'

const {out, code} = await runAction(Object.assign({}, process.env, baseEnv))
Expand All @@ -86,7 86,7 @@ describe('integration', () => {

test('runs a passing config', async () => {
const baseEnv = getBaseEnv()
baseEnv[getInputName(Inputs.CONFIG_FILE)] = path.resolve(
baseEnv[getInputName(ActionInputs.CONFIG_FILE)] = path.resolve(
__dirname,
'passingtestconfig.json'
)
Expand Down
Loading

0 comments on commit 31e15f9

Please sign in to comment.