-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: setup prettier eslint and vscode settings properly
- Loading branch information
1 parent
d357c2a
commit b474104
Showing
8 changed files
with
134 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
*.js.map | ||
*.d.ts | ||
*.md | ||
*.min.* | ||
dist/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,94 @@ | ||
import * as github from '@actions/github' | ||
import * as core from '@actions/core' | ||
import * as exec from '@actions/exec' | ||
import * as io from '@actions/io' | ||
import * as path from 'path' | ||
import run from '../index' | ||
import * as github from '@actions/github'; | ||
import * as core from '@actions/core'; | ||
import * as exec from '@actions/exec'; | ||
import * as io from '@actions/io'; | ||
import * as path from 'path'; | ||
import run from '../index'; | ||
|
||
const originalContext = {...github.context} | ||
const originalGitHubWorkspace = process.env['GITHUB_WORKSPACE'] | ||
const gitHubWorkspace = path.resolve('/checkout-tests/workspace') | ||
const originalContext = { ...github.context }; | ||
const originalGitHubWorkspace = process.env['GITHUB_WORKSPACE']; | ||
const gitHubWorkspace = path.resolve('/checkout-tests/workspace'); | ||
|
||
type InputsMock = { | ||
[name: string]: string | ||
} | ||
[name: string]: string; | ||
}; | ||
|
||
let inputs: InputsMock = {} | ||
let execSpy: jest.SpyInstance | ||
let inputs: InputsMock = {}; | ||
let execSpy: jest.SpyInstance; | ||
|
||
beforeAll(() => { | ||
execSpy = jest.spyOn(exec, 'exec').mockImplementation(jest.fn()) | ||
jest.spyOn(io, 'cp').mockImplementation(jest.fn()) | ||
execSpy = jest.spyOn(exec, 'exec').mockImplementation(jest.fn()); | ||
jest.spyOn(io, 'cp').mockImplementation(jest.fn()); | ||
|
||
jest.spyOn(core, 'getInput').mockImplementation((name: string) => { | ||
return inputs[name] | ||
}) | ||
return inputs[name]; | ||
}); | ||
|
||
jest.spyOn(github.context, 'repo', 'get').mockImplementation(() => { | ||
return { | ||
owner: 'enriikke', | ||
repo: 'enriikke.github.io', | ||
} | ||
}) | ||
}; | ||
}); | ||
|
||
github.context.ref = 'refs/heads/some-ref' | ||
github.context.sha = '1234567890123456789012345678901234567890' | ||
github.context.ref = 'refs/heads/some-ref'; | ||
github.context.sha = '1234567890123456789012345678901234567890'; | ||
|
||
process.env['GITHUB_WORKSPACE'] = gitHubWorkspace | ||
}) | ||
process.env['GITHUB_WORKSPACE'] = gitHubWorkspace; | ||
}); | ||
|
||
afterAll(() => { | ||
delete process.env['GITHUB_WORKSPACE'] | ||
delete process.env['GITHUB_WORKSPACE']; | ||
if (originalGitHubWorkspace) { | ||
process.env['GITHUB_WORKSPACE'] = originalGitHubWorkspace | ||
process.env['GITHUB_WORKSPACE'] = originalGitHubWorkspace; | ||
} | ||
|
||
github.context.ref = originalContext.ref | ||
github.context.sha = originalContext.sha | ||
github.context.ref = originalContext.ref; | ||
github.context.sha = originalContext.sha; | ||
|
||
jest.restoreAllMocks() | ||
}) | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
jest.resetModules(); | ||
inputs = { | ||
'access-token': 'SECRET', | ||
'skip-publish': 'true', | ||
} | ||
}) | ||
}; | ||
}); | ||
|
||
describe('scully Publish action', () => { | ||
it('returns an error when no access token is given', async () => { | ||
inputs['access-token'] = '' | ||
const setFailedSpy = jest.spyOn(core, 'setFailed') | ||
inputs['access-token'] = ''; | ||
const setFailedSpy = jest.spyOn(core, 'setFailed'); | ||
|
||
await run() | ||
await run(); | ||
|
||
expect(setFailedSpy).toBeCalledWith( | ||
'No personal access token found. Please provide one by setting the `access-token` input for this action.', | ||
) | ||
}) | ||
); | ||
}); | ||
|
||
it('skips if deploy branch is the same as the current git head', async () => { | ||
inputs['deploy-branch'] = 'some-ref' | ||
github.context.ref = 'refs/heads/some-ref' | ||
inputs['deploy-branch'] = 'some-ref'; | ||
github.context.ref = 'refs/heads/some-ref'; | ||
|
||
await expect(run()).resolves.not.toThrowError() | ||
}) | ||
await expect(run()).resolves.not.toThrowError(); | ||
}); | ||
|
||
it('calls scully build without args', async () => { | ||
inputs['scully-args'] = '' | ||
inputs['scully-args'] = ''; | ||
|
||
await run() | ||
await run(); | ||
|
||
expect(execSpy).toBeCalledWith('yarn run build', []) | ||
}) | ||
expect(execSpy).toBeCalledWith('yarn run build', []); | ||
}); | ||
|
||
it('calls scully build with args', async () => { | ||
inputs['scully-args'] = '--prefix-paths --no-uglify' | ||
inputs['scully-args'] = '--prefix-paths --no-uglify'; | ||
|
||
await run() | ||
await run(); | ||
|
||
expect(execSpy).toBeCalledWith('yarn run build', ['--', '--prefix-paths', '--no-uglify']) | ||
}) | ||
}) | ||
expect(execSpy).toBeCalledWith('yarn run build', ['--', '--prefix-paths', '--no-uglify']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.