Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent branch to ciBranch causing issues for --dry-run --no-ci in Github Actions #1596

Closed
dcneiner opened this issue Jul 9, 2020 · 6 comments

Comments

@dcneiner
Copy link

dcneiner commented Jul 9, 2020

Current behavior

Even when running semantic-release with --no-ci and --dry-run flags, it is now switching the meaning of branch to prBranch as of version 17.1.1.

My use case is using the semantic-release-github-pr adapter/plugin to post a preview of the release version and notes that will be generated if a pull request is merged. This plugin runs semantic-release with --no-ci and --dry-run

With version 17.1.1 it outputs this message:

This test run was triggered on the branch refs/pull/5/merge, while semantic-release is configured to only publish from main, therefore a new version won’t be published.

Expected behavior

When the --no-ci flag is provided, it feels like it should not switch branch to use prBranch as that is CI specific. I was thinking it might be a simple a change as this to fix (And I am happy to submit a PR, but wanted to check before opening one)

index.js line in question

- const ciBranch = isPr ? prBranch : branch;
+ const ciBranch = isPr && !options.noCi ? prBranch : branch;

Version 17.1.0 works fine with the plugin/adapter.

Environment

  • semantic-release version: 17.1.1
  • CI environment: Github Actions
  • Plugins used:
    • @semantic-release/commit-analyzer
    • @semantic-release/release-notes-generator
    • semantic-release-github-pr - this is both runs semantic-release with --no-ci and --dry-run and acts like a plugin
  • semantic-release configuration:

Note: --branches main is provided at run time

"release": {
  "baseBranch": "main",
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator"
  ]
}
CI logs
2020-07-08T20:28:50.2756714Z [8:28:50 PM] [semantic-release] › ℹ  Running semantic-release version 17.1.1
2020-07-08T20:28:50.2865799Z 2020-07-08T20:28:50.286Z semantic-release:config load config from: /home/runner/work/example-repo/example-repo/package.json
2020-07-08T20:28:50.4547028Z 2020-07-08T20:28:50.447Z semantic-release:config options values: {
2020-07-08T20:28:50.4547545Z   branches: [ 'main', 'main' ],
2020-07-08T20:28:50.4548056Z   repositoryUrl: 'git+https://github.com/.../example-repo.git',
2020-07-08T20:28:50.4548539Z   tagFormat: 'v${version}',
2020-07-08T20:28:50.4548859Z   plugins: [
2020-07-08T20:28:50.4549231Z     '@semantic-release/commit-analyzer',
2020-07-08T20:28:50.4549880Z     '@semantic-release/release-notes-generator'
2020-07-08T20:28:50.4550078Z   ],
2020-07-08T20:28:50.4550467Z   verifyConditions: '@semantic-release/github',
2020-07-08T20:28:50.4550682Z   analyzeCommits: [
2020-07-08T20:28:50.4550969Z     [AsyncFunction],
2020-07-08T20:28:50.4551187Z     [AsyncFunction],
2020-07-08T20:28:50.4551366Z     [AsyncFunction],
2020-07-08T20:28:50.4551565Z     [AsyncFunction],
2020-07-08T20:28:50.4551732Z     [AsyncFunction],
2020-07-08T20:28:50.4551912Z     [AsyncFunction],
2020-07-08T20:28:50.4552085Z     [AsyncFunction],
2020-07-08T20:28:50.4552240Z     [AsyncFunction],
2020-07-08T20:28:50.4552393Z     [AsyncFunction],
2020-07-08T20:28:50.4552545Z     [AsyncFunction]
2020-07-08T20:28:50.4552683Z   ],
2020-07-08T20:28:50.4552833Z   generateNotes: [
2020-07-08T20:28:50.4552984Z     [AsyncFunction],
2020-07-08T20:28:50.4553139Z     [AsyncFunction],
2020-07-08T20:28:50.4553290Z     [AsyncFunction],
2020-07-08T20:28:50.4553445Z     [AsyncFunction],
2020-07-08T20:28:50.4553593Z     [AsyncFunction],
2020-07-08T20:28:50.4553741Z     [AsyncFunction],
2020-07-08T20:28:50.4553891Z     [AsyncFunction],
2020-07-08T20:28:50.4554025Z     [AsyncFunction],
2020-07-08T20:28:50.4554174Z     [AsyncFunction],
2020-07-08T20:28:50.4554321Z     [AsyncFunction]
2020-07-08T20:28:50.4554457Z   ],
2020-07-08T20:28:50.4554745Z   baseBranch: 'main',
2020-07-08T20:28:50.4554893Z   _: [],
2020-07-08T20:28:50.4555177Z   b: [ 'main', 'main' ],
2020-07-08T20:28:50.4555332Z   debug: true,
2020-07-08T20:28:50.4555475Z   ci: false,
2020-07-08T20:28:50.4555746Z   'dry-run': true,
2020-07-08T20:28:50.4555892Z   d: true,
2020-07-08T20:28:50.4556037Z   dryRun: true,
2020-07-08T20:28:50.4556176Z   e: [
2020-07-08T20:28:50.4556609Z     '/home/runner/work/example-repo/example-repo/node_modules/semantic-release-github-pr/src/index.js'
2020-07-08T20:28:50.4556774Z   ],
2020-07-08T20:28:50.4557106Z   '$0': 'node_modules/.bin/semantic-release',
2020-07-08T20:28:50.4557268Z   noCi: true
2020-07-08T20:28:50.4557486Z }
2020-07-08T20:28:50.6159743Z 2020-07-08T20:28:50.615Z semantic-release:plugins options for @semantic-release/github/verifyConditions: {}
2020-07-08T20:28:50.6165794Z [8:28:50 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github" in shareable config "/home/runner/work/example-repo/example-repo/node_modules/semantic-release-github-pr/src/index.js"
2020-07-08T20:28:50.6167041Z 2020-07-08T20:28:50.616Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6194448Z 2020-07-08T20:28:50.616Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6195741Z 2020-07-08T20:28:50.617Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6196690Z 2020-07-08T20:28:50.617Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6204740Z 2020-07-08T20:28:50.617Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6230174Z 2020-07-08T20:28:50.617Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6231376Z 2020-07-08T20:28:50.617Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6232269Z 2020-07-08T20:28:50.617Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6233082Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6233853Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/analyzeCommits: {}
2020-07-08T20:28:50.6234622Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6235412Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6236103Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6237010Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6237672Z 2020-07-08T20:28:50.618Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6238324Z 2020-07-08T20:28:50.619Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6238997Z 2020-07-08T20:28:50.619Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6239721Z 2020-07-08T20:28:50.619Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6240397Z 2020-07-08T20:28:50.619Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:50.6241086Z 2020-07-08T20:28:50.619Z semantic-release:plugins options for [Function: ]/generateNotes: {}
2020-07-08T20:28:51.4937123Z 2020-07-08T20:28:51.493Z semantic-release:get-tags found tags for branch main: []
2020-07-08T20:28:51.4992952Z [8:28:51 PM] [semantic-release] › ℹ  This test run was triggered on the branch refs/pull/5/merge, while semantic-release is configured to only publish from main, therefore a new version won’t be published.
@travi
Copy link
Member

travi commented Jul 9, 2020

hi there, @dcneiner 👋. thanks for reaching out and for the thorough investigation.

it does sound like the change included in the last release would impact this behavior. i've never seen the plugin that you mention before, but i can certainly see it being useful.

i do know that we've been a little bit careful about supporting unofficial behaviors, especially around these particular flags. so, i would want to get feedback from one of our other maintainers before telling you with confidence that this would be an appropriate change. this seems reasonable though, so i think starting a PR with that change is a reasonable step and we can discuss in more detail there.

@dcneiner
Copy link
Author

dcneiner commented Jul 9, 2020

Hey @travi! Thanks for the response (and nice bumping into you here!) I was concerned about about the unofficial aspect of this request – so no worries if it isn't a good fit. I'll work on a PR with test and we can discuss there. Thank you!

@gr2m
Copy link
Member

gr2m commented Jul 9, 2020

Yeah if you could start a PR, we can discuss details there. At first sight, I don't mind the change, it seems reasonable

@dcneiner
Copy link
Author

Thanks @gr2m and @travi for taking a look at this. I feel bad I wasted your time now that I understand the pipeline better and don't think this fix is needed. I commented on my PR #1599 before I closed it, but I think the bug I am seeing is a combination of an issue in env-ci and possibly a yarn.lock that had me one point release behind on the semantic-release-github-pr package. So one was using prBranch and the other was using branch (This of course came to me as I tried to go to bed tonight 😭 )

@gr2m
Copy link
Member

gr2m commented Jul 10, 2020

No worries, and thank you for the update :)

Is there anything we should fix in https://github.com/pvdlg/env-ci/?

@julieReitter
Copy link

@dcneiner Were you ever able to get semantic-release-github-pr running in Github Actions? I ran into a similar problem and I'm running the latest versions, so was just curious if you came to a solution. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants