mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Fix a few nits in tests and automation. Don't try to wordcount ls-rem… (#546)
* Fix a few nits in tests and automation. Don't try to wordcount ls-remote. Nits in tests are around undoing changes made to the environment, and to not modify the checkout. * Describe suite with empty SHA
This commit is contained in:
parent
570f002e7e
commit
2a503ef9b5
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -6,7 +6,7 @@ on:
|
|||||||
- 'releases/v*'
|
- 'releases/v*'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- 'dev*'
|
||||||
tags-ignore:
|
tags-ignore:
|
||||||
- '*.*'
|
- '*.*'
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -11,6 +11,10 @@ import fs from 'fs'
|
|||||||
|
|
||||||
const originalAction = JSON.stringify(action)
|
const originalAction = JSON.stringify(action)
|
||||||
|
|
||||||
|
jest.mock('fs', () => ({
|
||||||
|
existsSync: jest.fn()
|
||||||
|
}))
|
||||||
|
|
||||||
jest.mock('@actions/core', () => ({
|
jest.mock('@actions/core', () => ({
|
||||||
setFailed: jest.fn(),
|
setFailed: jest.fn(),
|
||||||
getInput: jest.fn(),
|
getInput: jest.fn(),
|
||||||
@ -178,6 +182,14 @@ describe('git', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
||||||
|
;(fs.existsSync as jest.Mock)
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
folder: 'assets',
|
folder: 'assets',
|
||||||
@ -192,18 +204,21 @@ describe('git', () => {
|
|||||||
isTest: TestFlag.HAS_CHANGED_FILES
|
isTest: TestFlag.HAS_CHANGED_FILES
|
||||||
})
|
})
|
||||||
|
|
||||||
fs.createWriteStream('assets/.nojekyll')
|
|
||||||
fs.createWriteStream('assets/CNAME')
|
|
||||||
|
|
||||||
const response = await deploy(action)
|
const response = await deploy(action)
|
||||||
|
|
||||||
// Includes the call to generateWorktree
|
// Includes the call to generateWorktree
|
||||||
expect(execute).toBeCalledTimes(11)
|
expect(execute).toBeCalledTimes(11)
|
||||||
expect(rmRF).toBeCalledTimes(1)
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
|
expect(fs.existsSync).toBeCalledTimes(2)
|
||||||
expect(response).toBe(Status.SUCCESS)
|
expect(response).toBe(Status.SUCCESS)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute commands with clean options, commits sha commit message', async () => {
|
describe('with empty GITHUB_SHA', () => {
|
||||||
|
const oldSha = process.env.GITHUB_SHA
|
||||||
|
afterAll(() => {
|
||||||
|
process.env.GITHUB_SHA = oldSha
|
||||||
|
})
|
||||||
|
it('should execute commands with clean options', async () => {
|
||||||
process.env.GITHUB_SHA = ''
|
process.env.GITHUB_SHA = ''
|
||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
@ -227,6 +242,7 @@ describe('git', () => {
|
|||||||
expect(execute).toBeCalledTimes(8)
|
expect(execute).toBeCalledTimes(8)
|
||||||
expect(rmRF).toBeCalledTimes(1)
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('should execute commands with clean options stored as an array instead', async () => {
|
it('should execute commands with clean options stored as an array instead', async () => {
|
||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
|
@ -55,7 +55,7 @@ export async function deploy(action: ActionInterface): Promise<Status> {
|
|||||||
const branchExists =
|
const branchExists =
|
||||||
action.isTest & TestFlag.HAS_REMOTE_BRANCH ||
|
action.isTest & TestFlag.HAS_REMOTE_BRANCH ||
|
||||||
(await execute(
|
(await execute(
|
||||||
`git ls-remote --heads ${action.repositoryPath} ${action.branch} | wc -l`,
|
`git ls-remote --heads ${action.repositoryPath} ${action.branch}`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
action.silent
|
action.silent
|
||||||
))
|
))
|
||||||
|
Loading…
Reference in New Issue
Block a user