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

support for running on push in branches #154

Open
cainlevy opened this issue May 28, 2024 · 3 comments
Open

support for running on push in branches #154

cainlevy opened this issue May 28, 2024 · 3 comments
Labels
feature New feature or request

Comments

@cainlevy
Copy link

Setup

I want to run CI on every push to my feature branch.

on:
  push:
    branches-ignore:
      - 'main'

Am I the first person to try this? It's strange to me that it doesn't work.

Expected

I would expect nx-set-shas to execute the git merge-base strategy.

Actual

nx-set-shas chooses the "last successful workflow" strategy for setting a BASE. Then it fails to find one and defaults to HEAD~1, with inconsistent outcomes for the robustness of the work on my branch.

Ideas

  • Can nx-set-shas choose the git merge-base strategy whenever the current ref is not mainBranchName?
  • Can nx-set-shas allow me to configure the strategy I want it to use? I have a different action for releasing on pushes to main.
@cainlevy
Copy link
Author

Workaround

In my use case, it appears that nx-set-shas can be replaced with simply:

- name: set HEAD and BASE for nx affected
  run: |
    echo "NX_HEAD=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
    echo "NX_BASE=$(git merge-base origin/main HEAD)" >> "$GITHUB_ENV"

@mandarini mandarini added the feature New feature or request label Jun 11, 2024
@mandarini
Copy link
Member

Hi there @cainlevy ! Thank you for the feature request! We added the fallback SHA option in case a last successful workflow is not found. Would this address your issue? If not, do you want to submit a PR with the suggested implementation?

Thank you for your patience!

@cainlevy
Copy link
Author

Adding a fallback SHA does not address this need. My problem is that nx-set-shas chooses the wrong strategy for running tests on my branch. It chooses the strategy intended for the main branch (deploys) rather than the strategy intended for feature development (pull requests).

I believe the problem is that nx-set-shas depends entirely on eventName to pick its strategy. This approach fails for events like push that can happen in multiple contexts.

I don't currently feel comfortable submitting an implementation change because it seems like a very delicate thing to change. This appears to be a deep assumption in the package.

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

No branches or pull requests

2 participants