Skip to content
This repository has been archived by the owner on Jan 30, 2022. It is now read-only.

github actions/checks failing when building from PR #31

Closed
cvarjao opened this issue Dec 16, 2020 · 3 comments · Fixed by #61
Closed

github actions/checks failing when building from PR #31

cvarjao opened this issue Dec 16, 2020 · 3 comments · Fixed by #61
Assignees
Labels
bug Something isn't working

Comments

@cvarjao
Copy link
Member

cvarjao commented Dec 16, 2020

By default pull request checkouts will checkout the merge ref (no the head ref) which means it creates a detached branch that may be conflicting with the test cases.

Examples:
From push event:

Checking out the ref
  /usr/bin/git checkout --progress --force -B ONETEAM-737-0 refs/remotes/origin/ONETEAM-737-0
  Switched to a new branch 'ONETEAM-737-0'
  Branch 'ONETEAM-737-0' set up to track remote branch 'ONETEAM-737-0' from 'origin'.
/usr/bin/git log -1 --format='%H'
'2e618b250ff81f2b011efb953a11457656df5836'

from pull_request event:

Checking out the ref
  /usr/bin/git checkout --progress --force refs/remotes/pull/28/merge
  Note: switching to 'refs/remotes/pull/28/merge'.
  
  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by switching back to a branch.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -c with the switch command. Example:
  
    git switch -c <new-branch-name>
  
  Or undo this operation with:
  
    git switch -
  
  Turn off this advice by setting config variable advice.detachedHead to false
  
  HEAD is now at 1439e2e Merge 2e618b250ff81f2b011efb953a11457656df5836 into 3aa9fb8db516d5924b96c13907a4d77b6506f205
/usr/bin/git log -1 --format='%H'
'1439e2e1cc69838e608523ab91cc10b9d270073c'
cghobson added a commit that referenced this issue Dec 17, 2020
Maybe actions/checkout#124 will change the behaviour?
@cghobson cghobson self-assigned this Dec 17, 2020
@DerekRoberts DerekRoberts reopened this Feb 17, 2021
@DerekRoberts
Copy link
Member

DerekRoberts commented Feb 17, 2021

GitHub Actions from outside forks are still failing. Issue reopened.

@DerekRoberts DerekRoberts added the bug Something isn't working label Feb 17, 2021
@DerekRoberts DerekRoberts linked a pull request Feb 22, 2021 that will close this issue
@DerekRoberts DerekRoberts added waiting Waiting or blocked and removed waiting Waiting or blocked labels Feb 22, 2021
@DerekRoberts
Copy link
Member

DerekRoberts commented Feb 23, 2021

npm run test passes, but excludes all *.test.ts. Including those we have the following.

Failing on detached head only:

  • commands/build.test.ts (doesn't return)

Failing on branch and detached head:

  • jenkins/on-jira-event.test.ts
  • util/jira-rfd.test.ts
  • util/rfd-helper.e2e.test.ts

Passing:

for i in `find test/ -type f -iname *.js -o -iname *.ts ! -name build.* ! -name on-jira-event.* ! -name jira-rfd.* ! -name rfd-helper.*`; do npm run mocha -- $i; done

@DerekRoberts
Copy link
Member

DerekRoberts commented Feb 23, 2021

build.test.js testing command:

nrdk build --config-script test/commands/build.config.js --build-script test/commands/build.build.js

Detached head:

Starting @bcgov/nrdk/0.1.0-rc.91 linux-x64 node-v14.15.4
info: Applying default value for git.url {"category":"OnJiraIssue","timestamp":"2021-02-23T20:27:07.135Z"}
info: Applying default value for git.remote.url {"category":"OnJiraIssue","timestamp":"2021-02-23T20:27:07.192Z"}
info: Applying default value for git.branch.name {"category":"OnJiraIssue","timestamp":"2021-02-23T20:27:07.193Z"}
info: Applying default value for git.branch.merge {"category":"OnJiraIssue","timestamp":"2021-02-23T20:27:07.195Z"}
info: Applying default value for git.change.target {"category":"OnJiraIssue","timestamp":"2021-02-23T20:27:07.196Z"}

Branch:

Starting @bcgov/nrdk/0.1.0-rc.91 linux-x64 node-v14.15.4
info: Applying default value for git.url {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.289Z"}
info: Applying default value for git.remote.url {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.339Z"}
info: Applying default value for git.branch.name {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.341Z"}
info: Applying default value for git.branch.merge {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.343Z"}
info: Applying default value for git.change.target {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.344Z"}
info: Applying default value for build-script {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.351Z"}
info: Applying default value for deploy-script {"category":"OnJiraIssue","timestamp":"2021-02-23T20:30:30.352Z"}
--config-script=test/commands/build.config.js --build-script=test/commands/build.build.js --git.remote.name=origin --dev-mode=false --rfc-validation=true [email protected]:bcdevops/nrdk.git [email protected]:bcdevops/nrdk.git --git.branch.name=master --git.branch.merge=master --git.change.target=master --deploy-script=.pipeline/lib/deploy
Build started
Build finished

The missing output, triggering the failure, looks to be in test/commands/build.build.js:

const MyBuilder = class {
  build() {
    console.log('Build started')
    console.log('Build finished')
  }
}
module.exports = async settings => {
  await new MyBuilder(settings).build()
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants