2020-12-07 23:12:15 +08:00
|
|
|
/* eslint-disable import/first */
|
2019-11-19 23:06:27 +08:00
|
|
|
// Initial env variable setup for tests.
|
2020-03-05 21:19:45 +08:00
|
|
|
process.env['INPUT_FOLDER'] = 'build'
|
|
|
|
process.env['GITHUB_SHA'] = '123'
|
2019-11-19 23:06:27 +08:00
|
|
|
|
2020-04-30 20:29:24 +08:00
|
|
|
import {mkdirP, rmRF} from '@actions/io'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
import {action, Status, TestFlag} from '../src/constants'
|
2020-03-05 21:19:45 +08:00
|
|
|
import {execute} from '../src/execute'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
import {deploy, init} from '../src/git'
|
2020-07-27 22:29:27 +08:00
|
|
|
import fs from 'fs'
|
2019-11-19 23:06:27 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
const originalAction = JSON.stringify(action)
|
2019-11-19 23:06:27 +08:00
|
|
|
|
2020-12-15 23:58:52 +08:00
|
|
|
jest.mock('fs', () => ({
|
|
|
|
existsSync: jest.fn()
|
|
|
|
}))
|
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
jest.mock('@actions/core', () => ({
|
2020-01-20 04:33:14 +08:00
|
|
|
setFailed: jest.fn(),
|
2020-03-28 22:35:26 +08:00
|
|
|
getInput: jest.fn(),
|
|
|
|
isDebug: jest.fn(),
|
|
|
|
info: jest.fn()
|
2020-03-05 21:19:45 +08:00
|
|
|
}))
|
2020-01-20 04:33:14 +08:00
|
|
|
|
2020-04-12 01:57:56 +08:00
|
|
|
jest.mock('@actions/io', () => ({
|
2020-04-30 20:29:24 +08:00
|
|
|
rmRF: jest.fn(),
|
|
|
|
mkdirP: jest.fn()
|
2020-04-12 01:57:56 +08:00
|
|
|
}))
|
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
jest.mock('../src/execute', () => ({
|
2020-12-07 23:12:15 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
2020-10-17 23:47:44 +08:00
|
|
|
__esModule: true,
|
2020-10-17 23:48:06 +08:00
|
|
|
execute: jest.fn()
|
2020-03-05 21:19:45 +08:00
|
|
|
}))
|
2019-11-19 23:06:27 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
describe('git', () => {
|
2019-11-19 23:06:27 +08:00
|
|
|
afterEach(() => {
|
2020-03-05 21:19:45 +08:00
|
|
|
Object.assign(action, JSON.parse(originalAction))
|
|
|
|
})
|
2019-11-19 23:06:27 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
describe('init', () => {
|
2020-10-17 23:47:44 +08:00
|
|
|
it('should catch when a function throws an error', async () => {
|
2020-10-17 23:48:06 +08:00
|
|
|
;(execute as jest.Mock).mockImplementationOnce(() => {
|
|
|
|
throw new Error('Mocked throw')
|
|
|
|
})
|
2020-10-17 23:47:44 +08:00
|
|
|
|
|
|
|
Object.assign(action, {
|
|
|
|
silent: false,
|
|
|
|
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
2020-10-17 23:47:44 +08:00
|
|
|
branch: 'branch',
|
|
|
|
folder: '.',
|
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
},
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-10-17 23:47:44 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
try {
|
|
|
|
await init(action)
|
|
|
|
} catch (error) {
|
2020-10-17 23:48:06 +08:00
|
|
|
expect(error.message).toBe(
|
|
|
|
'There was an error initializing the repository: Mocked throw ❌'
|
|
|
|
)
|
2020-10-17 23:47:44 +08:00
|
|
|
}
|
|
|
|
})
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2019-11-19 23:06:27 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
describe('deploy', () => {
|
|
|
|
it('should execute commands', async () => {
|
2020-01-20 04:33:14 +08:00
|
|
|
Object.assign(action, {
|
2020-06-26 20:18:23 +08:00
|
|
|
silent: false,
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
folder: 'assets',
|
2020-03-05 21:19:45 +08:00
|
|
|
branch: 'branch',
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
token: '123',
|
2020-01-20 04:33:14 +08:00
|
|
|
pusher: {
|
2020-03-05 21:19:45 +08:00
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
},
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-01-20 04:33:14 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
const response = await deploy(action)
|
2020-10-17 23:47:44 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(11)
|
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
|
|
|
expect(response).toBe(Status.SUCCESS)
|
|
|
|
})
|
2020-10-17 23:47:44 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
it('should not push when asked to dryRun', async () => {
|
2020-10-17 23:47:44 +08:00
|
|
|
Object.assign(action, {
|
|
|
|
silent: false,
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
dryRun: true,
|
|
|
|
folder: 'assets',
|
2020-10-17 23:47:44 +08:00
|
|
|
branch: 'branch',
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
token: '123',
|
2020-10-17 23:47:44 +08:00
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
},
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-10-17 23:47:44 +08:00
|
|
|
})
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
const response = await deploy(action)
|
|
|
|
|
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(10)
|
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
|
|
|
expect(response).toBe(Status.SUCCESS)
|
2020-10-17 23:47:44 +08:00
|
|
|
})
|
2019-12-22 05:51:39 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
it('should execute commands with single commit toggled', async () => {
|
2019-11-19 23:06:27 +08:00
|
|
|
Object.assign(action, {
|
2020-06-26 20:18:23 +08:00
|
|
|
silent: false,
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
folder: 'other',
|
|
|
|
folderPath: 'other',
|
2020-03-05 21:19:45 +08:00
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
singleCommit: true,
|
2020-07-14 00:52:45 +08:00
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
},
|
|
|
|
clean: true,
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-07-14 00:52:45 +08:00
|
|
|
})
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
await deploy(action)
|
2020-07-27 22:29:27 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
// Includes the call to generateWorktree
|
2020-12-07 23:11:58 +08:00
|
|
|
expect(execute).toBeCalledTimes(10)
|
2020-12-08 23:14:59 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
|
|
|
})
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
it('should execute commands with single commit toggled and existing branch', async () => {
|
2020-12-08 23:14:59 +08:00
|
|
|
Object.assign(action, {
|
|
|
|
silent: false,
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
folder: 'other',
|
|
|
|
folderPath: 'other',
|
2020-12-08 23:14:59 +08:00
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
singleCommit: true,
|
2020-12-08 23:14:59 +08:00
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
},
|
|
|
|
clean: true,
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES | TestFlag.HAS_REMOTE_BRANCH
|
2020-12-08 23:14:59 +08:00
|
|
|
})
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
await deploy(action)
|
2020-12-08 23:14:59 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(9)
|
2020-07-14 00:52:45 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
|
|
|
})
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
it('should execute commands with single commit and dryRun toggled', async () => {
|
2020-03-31 08:44:09 +08:00
|
|
|
Object.assign(action, {
|
2020-06-26 20:18:23 +08:00
|
|
|
silent: false,
|
2020-10-18 00:23:52 +08:00
|
|
|
folder: 'other',
|
|
|
|
folderPath: 'other',
|
2020-03-31 08:44:09 +08:00
|
|
|
branch: 'branch',
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
gitHubToken: '123',
|
2020-03-31 08:44:09 +08:00
|
|
|
singleCommit: true,
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
dryRun: true,
|
2020-03-31 08:44:09 +08:00
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
2020-10-18 00:23:52 +08:00
|
|
|
},
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
clean: true,
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-03-31 08:44:09 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
await deploy(action)
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(9)
|
2020-04-12 01:57:56 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
2020-03-31 08:44:09 +08:00
|
|
|
})
|
|
|
|
|
2020-10-18 00:23:52 +08:00
|
|
|
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
2020-12-15 23:58:52 +08:00
|
|
|
;(fs.existsSync as jest.Mock)
|
|
|
|
.mockImplementationOnce(() => {
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
.mockImplementationOnce(() => {
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
2020-10-18 00:23:52 +08:00
|
|
|
Object.assign(action, {
|
|
|
|
silent: false,
|
|
|
|
folder: 'assets',
|
|
|
|
folderPath: 'assets',
|
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
2020-10-18 00:23:52 +08:00
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
|
|
|
},
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
clean: true,
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-10-18 00:23:52 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
const response = await deploy(action)
|
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(11)
|
2020-10-18 00:23:52 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
2020-12-15 23:58:52 +08:00
|
|
|
expect(fs.existsSync).toBeCalledTimes(2)
|
2020-10-18 00:23:52 +08:00
|
|
|
expect(response).toBe(Status.SUCCESS)
|
|
|
|
})
|
|
|
|
|
2020-12-15 23:58:52 +08:00
|
|
|
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 = ''
|
|
|
|
Object.assign(action, {
|
|
|
|
silent: false,
|
|
|
|
folder: 'other',
|
|
|
|
folderPath: 'other',
|
|
|
|
branch: 'branch',
|
|
|
|
token: '123',
|
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
|
|
|
},
|
|
|
|
clean: true,
|
|
|
|
cleanExclude: '["cat", "montezuma"]',
|
|
|
|
workspace: 'other',
|
|
|
|
isTest: TestFlag.NONE
|
|
|
|
})
|
|
|
|
|
|
|
|
await deploy(action)
|
|
|
|
|
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(8)
|
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
|
|
|
})
|
2020-03-02 20:52:38 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
it('should execute commands with clean options stored as an array instead', async () => {
|
2020-03-02 20:52:38 +08:00
|
|
|
Object.assign(action, {
|
2020-06-26 20:18:23 +08:00
|
|
|
silent: false,
|
2020-06-06 22:55:49 +08:00
|
|
|
folder: 'assets',
|
2020-10-18 00:23:52 +08:00
|
|
|
folderPath: 'assets',
|
2020-03-05 21:19:45 +08:00
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
2020-03-02 20:52:38 +08:00
|
|
|
pusher: {
|
2020-03-05 21:19:45 +08:00
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
2020-03-02 20:52:38 +08:00
|
|
|
},
|
|
|
|
clean: true,
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
cleanExclude: ['cat', 'montezuma'],
|
|
|
|
isTest: TestFlag.NONE
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-03-02 20:52:38 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
await deploy(action)
|
2020-01-20 04:33:14 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
// Includes the call to generateWorktree
|
|
|
|
expect(execute).toBeCalledTimes(8)
|
2020-04-12 01:57:56 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-01-20 04:33:14 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
it('should gracefully handle incorrectly formatted clean exclude items', async () => {
|
2020-01-20 04:33:14 +08:00
|
|
|
Object.assign(action, {
|
2020-06-26 20:18:23 +08:00
|
|
|
silent: false,
|
2020-03-05 21:19:45 +08:00
|
|
|
folder: '.',
|
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
2020-01-20 05:16:28 +08:00
|
|
|
pusher: {},
|
2020-01-20 04:33:14 +08:00
|
|
|
clean: true,
|
2020-03-05 21:19:45 +08:00
|
|
|
targetFolder: 'new_folder',
|
|
|
|
commitMessage: 'Hello!',
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
isTest: TestFlag.NONE,
|
2020-01-20 04:33:14 +08:00
|
|
|
cleanExclude: '["cat, "montezuma"]' // There is a syntax errror in the string.
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-01-20 04:33:14 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
await deploy(action)
|
2020-01-20 04:33:14 +08:00
|
|
|
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
expect(execute).toBeCalledTimes(8)
|
2020-04-12 01:57:56 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
2020-04-30 20:29:24 +08:00
|
|
|
expect(mkdirP).toBeCalledTimes(1)
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-01-20 04:33:14 +08:00
|
|
|
|
2020-03-05 21:19:45 +08:00
|
|
|
it('should stop early if there is nothing to commit', async () => {
|
2020-01-20 04:33:14 +08:00
|
|
|
Object.assign(action, {
|
2020-06-26 20:18:23 +08:00
|
|
|
silent: false,
|
2020-06-06 22:55:49 +08:00
|
|
|
folder: 'assets',
|
2020-03-05 21:19:45 +08:00
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
2020-01-20 04:33:14 +08:00
|
|
|
pusher: {
|
2020-03-05 21:19:45 +08:00
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
2020-01-20 04:33:14 +08:00
|
|
|
},
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
isTest: TestFlag.NONE // Setting this flag to None means there will never be anything to commit and the action will exit early.
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-01-20 04:33:14 +08:00
|
|
|
|
2020-05-15 05:56:56 +08:00
|
|
|
const response = await deploy(action)
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
expect(execute).toBeCalledTimes(8)
|
2020-04-12 01:57:56 +08:00
|
|
|
expect(rmRF).toBeCalledTimes(1)
|
2020-05-15 05:56:56 +08:00
|
|
|
expect(response).toBe(Status.SKIPPED)
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
2020-10-17 23:47:44 +08:00
|
|
|
|
|
|
|
it('should catch when a function throws an error', async () => {
|
2020-10-17 23:48:06 +08:00
|
|
|
;(execute as jest.Mock).mockImplementationOnce(() => {
|
|
|
|
throw new Error('Mocked throw')
|
|
|
|
})
|
2020-10-17 23:47:44 +08:00
|
|
|
|
|
|
|
Object.assign(action, {
|
|
|
|
silent: false,
|
|
|
|
folder: 'assets',
|
|
|
|
branch: 'branch',
|
2020-12-11 00:49:37 +08:00
|
|
|
token: '123',
|
2020-10-17 23:47:44 +08:00
|
|
|
pusher: {
|
|
|
|
name: 'asd',
|
|
|
|
email: 'as@cat'
|
Test current code base as an integration test for PRs and pushes (#505)
* Add a build step to create lib and node_modules artifact
* Run integration test with built dist and current SHA as base
For pull requests, the github.sha is the sha of the merge to the
target branch, not the head of the PR. Special case that.
* Use v2 checkout, and DRY_RUN for the integration test.
I also made the branches more generic, as there are now more of them.
* Fix #536, don't push at all on dryRun
Also add tests for dryRun and singleCommit and generateBranch
code flows.
* Try to fix dryRun on new remote branches, refactor fetch
* Try to fix dryRun, only fetch if origin branch exists
* Refactor worktree setup to include branch generation and setup for singleCommit
This is a continuation of the no-checkout work, and sadly suggested pretty
intensive changes.
* Set up git config to fix tests, also make debugging easier
* Add matrix for existing and non-existing branch
* Add matrix for singleCommit and not
* Drop GITHUB_TOKEN, add DRY_RUN to action.yml
* When deploying existing branch, add a modifcation and deploy again
* Force branch checkout to work in redeployment scenarios
* Make singleCommit easier to see in job descriptions
* Review comments
* Add a test-only property to action to test code paths with remote branch.
* Introduce TestFlag enum to signal different test scenarios to unit tests
* Fix util.test.ts
2020-12-15 01:30:22 +08:00
|
|
|
},
|
|
|
|
isTest: TestFlag.HAS_CHANGED_FILES
|
2020-10-17 23:47:44 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
try {
|
|
|
|
await deploy(action)
|
|
|
|
} catch (error) {
|
2020-10-17 23:48:06 +08:00
|
|
|
expect(error.message).toBe(
|
|
|
|
'The deploy step encountered an error: Mocked throw ❌'
|
|
|
|
)
|
2020-10-17 23:47:44 +08:00
|
|
|
}
|
|
|
|
})
|
2020-03-05 21:19:45 +08:00
|
|
|
})
|
|
|
|
})
|