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 { ActionInterface , TestFlag } from '../src/constants'
2020-03-02 20:52:38 +08:00
import {
isNullOrUndefined ,
generateTokenType ,
generateRepositoryPath ,
2020-10-07 21:34:20 +08:00
generateFolderPath ,
2020-10-15 22:20:15 +08:00
suppressSensitiveInformation ,
checkParameters
2020-03-05 21:19:45 +08:00
} from '../src/util'
2019-11-19 23:06:27 +08:00
2020-03-05 21:19:45 +08:00
describe ( 'util' , ( ) = > {
describe ( 'isNullOrUndefined' , ( ) = > {
it ( 'should return true if the value is null' , async ( ) = > {
const value = null
expect ( isNullOrUndefined ( value ) ) . toBeTruthy ( )
} )
2020-01-12 09:26:08 +08:00
2020-03-05 21:19:45 +08:00
it ( 'should return true if the value is undefined' , async ( ) = > {
const value = undefined
expect ( isNullOrUndefined ( value ) ) . toBeTruthy ( )
} )
2020-01-12 09:26:08 +08:00
2020-03-05 21:19:45 +08:00
it ( 'should return false if the value is defined' , async ( ) = > {
const value = 'montezuma'
expect ( isNullOrUndefined ( value ) ) . toBeFalsy ( )
} )
2020-10-15 22:20:15 +08:00
it ( 'should return false if the value is empty string' , async ( ) = > {
const value = ''
expect ( isNullOrUndefined ( value ) ) . toBeTruthy ( )
} )
2020-03-05 21:19:45 +08:00
} )
2020-03-02 20:52:38 +08:00
2020-03-05 21:19:45 +08:00
describe ( 'generateTokenType' , ( ) = > {
it ( 'should return ssh if ssh is provided' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-06-27 02:16:54 +08:00
ssh : 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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
expect ( generateTokenType ( action ) ) . toEqual ( 'SSH Deploy Key' )
} )
2020-03-02 20:52:38 +08:00
2020-12-11 00:49:37 +08:00
it ( 'should return deploy token if token is provided' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : '123' ,
2020-06-27 02:16:54 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
2020-12-11 00:49:37 +08:00
expect ( generateTokenType ( action ) ) . toEqual ( 'Deploy Token' )
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 return ... if no token is provided' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-06-27 02:16:54 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
2020-05-11 01:34:14 +08:00
expect ( generateTokenType ( action ) ) . toEqual ( '…' )
2020-03-05 21:19:45 +08:00
} )
} )
2020-03-02 20:52:38 +08:00
2020-03-05 21:19:45 +08:00
describe ( 'generateRepositoryPath' , ( ) = > {
it ( 'should return ssh if ssh is provided' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
repositoryName : 'JamesIves/github-pages-deploy-action' ,
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-06-27 02:16:54 +08:00
ssh : 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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
2020-03-02 20:52:38 +08:00
expect ( generateRepositoryPath ( action ) ) . toEqual (
2020-03-05 21:19:45 +08:00
'git@github.com:JamesIves/github-pages-deploy-action'
)
} )
2020-03-02 20:52:38 +08:00
2020-12-11 00:49:37 +08:00
it ( 'should return https with x-access-token if deploy token is provided' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
repositoryName : 'JamesIves/github-pages-deploy-action' ,
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : '123' ,
2020-06-27 02:16:54 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
2020-03-02 20:52:38 +08:00
expect ( generateRepositoryPath ( action ) ) . toEqual (
2020-03-05 21:19:45 +08:00
'https://x-access-token:123@github.com/JamesIves/github-pages-deploy-action.git'
)
} )
2020-03-02 20:52:38 +08:00
2020-03-05 21:19:45 +08:00
describe ( 'suppressSensitiveInformation' , ( ) = > {
it ( 'should replace any sensitive information with ***' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
repositoryName : 'JamesIves/github-pages-deploy-action' ,
2020-03-02 20:52:38 +08:00
repositoryPath :
2020-03-05 21:19:45 +08:00
'https://x-access-token:supersecret999%%%@github.com/anothersecret123333' ,
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : 'anothersecret123333' ,
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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
2020-03-02 20:52:38 +08:00
2020-12-11 00:49:37 +08:00
const string = ` This is an error message! It contains ${ action . token } and ${ action . repositoryPath } and ${ action . token } again! `
2020-03-02 20:52:38 +08:00
expect ( suppressSensitiveInformation ( string , action ) ) . toBe (
2020-12-11 00:49:37 +08:00
'This is an error message! It contains *** and *** and *** again!'
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 not suppress information when in debug mode' , async ( ) = > {
2020-03-02 20:52:38 +08:00
const action = {
2020-03-05 21:19:45 +08:00
repositoryName : 'JamesIves/github-pages-deploy-action' ,
2020-03-02 20:52:38 +08:00
repositoryPath :
2020-03-05 21:19:45 +08:00
'https://x-access-token:supersecret999%%%@github.com/anothersecret123333' ,
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : 'anothersecret123333' ,
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
silent : false ,
isTest : TestFlag.NONE
2020-03-05 21:19:45 +08:00
}
2020-03-02 20:52:38 +08:00
2020-03-28 22:35:26 +08:00
process . env [ 'RUNNER_DEBUG' ] = '1'
2020-03-02 20:52:38 +08:00
2020-12-11 00:49:37 +08:00
const string = ` This is an error message! It contains ${ action . token } and ${ action . repositoryPath } `
2020-03-02 20:52:38 +08:00
expect ( suppressSensitiveInformation ( string , action ) ) . toBe (
2020-12-11 00:49:37 +08:00
'This is an error message! It contains anothersecret123333 and https://x-access-token:supersecret999%%%@github.com/anothersecret123333'
2020-03-05 21:19:45 +08:00
)
} )
} )
} )
2020-10-07 21:34:20 +08:00
describe ( 'generateFolderPath' , ( ) = > {
it ( 'should return absolute path if folder name is provided' , ( ) = > {
const action = {
branch : '123' ,
workspace : 'src/' ,
folder : 'build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-10-07 21:34:20 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-10-07 21:34:20 +08:00
}
2020-10-15 22:20:15 +08:00
expect ( generateFolderPath ( action ) ) . toEqual ( 'src/build' )
2020-10-07 21:34:20 +08:00
} )
it ( 'should return original path if folder name begins with /' , ( ) = > {
const action = {
branch : '123' ,
workspace : 'src/' ,
folder : '/home/user/repo/build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-10-07 21:34:20 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-10-07 21:34:20 +08:00
}
2020-10-15 22:20:15 +08:00
expect ( generateFolderPath ( action ) ) . toEqual ( '/home/user/repo/build' )
2020-10-07 21:34:20 +08:00
} )
it ( 'should process as relative path if folder name begins with ./' , ( ) = > {
const action = {
branch : '123' ,
workspace : 'src/' ,
folder : './build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-10-07 21:34:20 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-10-07 21:34:20 +08:00
}
2020-10-15 22:20:15 +08:00
expect ( generateFolderPath ( action ) ) . toEqual ( 'src/build' )
2020-10-07 21:34:20 +08:00
} )
it ( 'should return absolute path if folder name begins with ~' , ( ) = > {
const action = {
branch : '123' ,
workspace : 'src/' ,
folder : '~/repo/build' ,
2020-12-11 00:49:37 +08:00
token : null ,
2020-10-07 21:34:20 +08:00
ssh : null ,
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
silent : false ,
isTest : TestFlag.NONE
2020-10-07 21:34:20 +08:00
}
process . env . HOME = '/home/user'
2020-10-15 22:20:15 +08:00
expect ( generateFolderPath ( action ) ) . toEqual ( '/home/user/repo/build' )
} )
} )
describe ( 'hasRequiredParameters' , ( ) = > {
it ( 'should fail if there is no provided GitHub Token, Access Token or SSH bool' , ( ) = > {
const action = {
silent : false ,
repositoryPath : undefined ,
branch : 'branch' ,
folder : 'build' ,
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
workspace : 'src/' ,
isTest : TestFlag.NONE
2020-10-15 22:20:15 +08:00
}
try {
checkParameters ( action )
} catch ( e ) {
expect ( e . message ) . toMatch (
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
)
}
} )
2020-12-11 00:49:37 +08:00
it ( 'should fail if token is defined but it is an empty string' , ( ) = > {
2020-10-15 22:20:15 +08:00
const action = {
silent : false ,
repositoryPath : undefined ,
2020-12-11 00:49:37 +08:00
token : '' ,
2020-10-15 22:20:15 +08:00
branch : 'branch' ,
folder : 'build' ,
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
workspace : 'src/' ,
isTest : TestFlag.NONE
2020-10-15 22:20:15 +08:00
}
try {
checkParameters ( action )
} catch ( e ) {
expect ( e . message ) . toMatch (
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
)
}
} )
it ( 'should fail if there is no branch' , ( ) = > {
const action = {
silent : false ,
repositoryPath : undefined ,
2020-12-11 00:49:37 +08:00
token : '123' ,
2020-10-15 22:20:15 +08:00
branch : '' ,
folder : 'build' ,
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
workspace : 'src/' ,
isTest : TestFlag.NONE
2020-10-15 22:20:15 +08:00
}
try {
checkParameters ( action )
} catch ( e ) {
expect ( e . message ) . toMatch ( 'Branch is required.' )
}
} )
it ( 'should fail if there is no folder' , ( ) = > {
const action = {
silent : false ,
repositoryPath : undefined ,
2020-12-11 00:49:37 +08:00
token : '123' ,
2020-10-15 22:20:15 +08:00
branch : 'branch' ,
folder : '' ,
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
workspace : 'src/' ,
isTest : TestFlag.NONE
2020-10-15 22:20:15 +08:00
}
try {
checkParameters ( action )
} catch ( e ) {
expect ( e . message ) . toMatch (
'You must provide the action with a folder to deploy.'
)
}
} )
it ( 'should fail if the folder does not exist in the tree' , ( ) = > {
const action : ActionInterface = {
silent : false ,
repositoryPath : undefined ,
2020-12-11 00:49:37 +08:00
token : '123' ,
2020-10-15 22:20:15 +08:00
branch : 'branch' ,
folder : 'notARealFolder' ,
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
workspace : '.' ,
isTest : TestFlag.NONE
2020-10-15 22:20:15 +08:00
}
try {
action . folderPath = generateFolderPath ( action )
checkParameters ( action )
} catch ( e ) {
expect ( e . message ) . toMatch (
2020-10-17 23:47:44 +08:00
` The directory you're trying to deploy named notARealFolder doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗ `
2020-10-15 22:20:15 +08:00
)
}
2020-10-07 21:34:20 +08:00
} )
} )
2020-03-05 21:19:45 +08:00
} )