MansaGroup / nrwl-nx-action

A GitHub Action to wrap Nrwl Nx commands in your workflows.
MIT License
224 stars 19 forks source link

How to target base=master ? Issue with Command failed: git merge-base --fork-point #306

Open gamegee opened 2 years ago

gamegee commented 2 years ago

Feature Request

My current flow for running the CI is the following :

I am wondering how I can run affected running a comparison between the last commit of master --base=master and the last commit of the current branch.

Here is an example of my .github-action configuration:

  test:
    name: Test
    runs-on: ubuntu-latest
    needs: install-deps # other job installing the deps => npm i
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v2
        with:
          node-version: "14"
      - name: Cache node modules
        id: cache
        uses: actions/cache@v2
        with:
          path: node_modules
          key: cache-node-modules-${{ hashFiles('package-lock.json') }}
      - uses: mansagroup/nrwl-nx-action@v2
        with:
          args: --verbose=false
          targets: test

Is your feature request related to a problem? Please describe.

When running the CI I have the following error :

nx "affected" "--target=test" "--base=bb2066fa076f1afc2cf0ced20096b56f2ad51c80" "--head=78f6e6aabdc9541d462fdba1ce770342068f2db2" "--verbose=false"

fatal: Not a valid commit name bb2066fa076f1afc2cf0ced20096b56f2ad51c80
fatal: No such ref: 'bb2066fa076f1afc2cf0ced20096b56f2ad51c80'

...

Error: Command failed: git merge-base --fork-point "bb2066fa076f1afc2cf0ced20096b56f2ad51c80" "78f6e6aabdc9541d462fdba1ce770342068f2db2"
fatal: No such ref: 'bb2066fa076f1afc2cf0ced20096b56f2ad51c80'

Describe the solution you'd like

I am not sure if I should be able to fix my issue, I want to be able to define my base being master. Did I miss something or nrwl-nx-action should provide an API to resolve my issue ?

Teachability, Documentation, Adoption, Migration Strategy

-

jeremylvln commented 2 years ago

Hi @gamegee, if you open a pull request the action should automatically infer the Git boundaries, taking the base as the branch your PR is opened against. So if your PR targets the master branch, this action will use the latest commit of the master branch as base.

Nx has progressed a lot since the last release of the action. Would you be able to test with the latest v3 release of the action just to confirm the issue is still present? Hopefully it will not!

abbudao commented 2 years ago

Although I really love the simplicity of not having to specify any base on Pull requests, I would love to also use this action on my deployments using semver. As semver uses tags to mark where the last release happened in each environment, I can't make this action play nice with it. I believe #314 is just what I need to make my use case possible.