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

Not working on master with pull requests "No projects with ... were run - Successfully ran target ... for 0 projects" #83

Closed
mklueh opened this issue Dec 12, 2022 · 6 comments · Fixed by #92

Comments

@mklueh
Copy link

mklueh commented Dec 12, 2022

Hello,

I'm facing a second issue with this plugin and I'm not able to get it working on master (on develop and feature branches it works except for the other issue I've created #82)

Currently, when create a pull request to merge develop into master including squashing, it will always result in

Run nx affected 

 >  NX   No explicit --head argument provided, but found environment variable NX_HEAD so using its value as the affected head: 7e78f982b[23](https://github.com/.../actions/runs/.../jobs/...#step:10:24)1ed3b5ceee2f465df873[24](https://github.com/.../actions/runs/.../jobs/...#step:10:25)7cdb643

 >  NX   No projects with "build-and-deploy" were run

 >  NX   Successfully ran target build-and-deploy for 0 projects

this is my configuration

on:
  pull_request:
    branches:
      - "master"
      - "main"
    types: [ closed ]

concurrency: production

jobs:
  build:
    runs-on: ubuntu-latest
    environment: production
    timeout-minutes: 15
    permissions:
      contents: 'read'
      actions: 'read'

    if: ${{ github.event.action == 'closed' && github.event.pull_request.merged == true }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Use Node.js 18
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'yarn'

      - run: npm install -g yarn

      - name: Derive appropriate SHAs for base and head for `nx affected` commands
        uses: nrwl/nx-set-shas@v3
        id: setSHAs
        with:
          main-branch-name: 'master'

      - name: Show head and base
        run: |
          echo "BASE: ${{ env.NX_BASE }}"
          echo "HEAD: ${{ env.NX_HEAD }}"

      - name: Install dependencies
        run: yarn install --immutable

      - name: Deploying changed apps
        run: |
            nx affected \
            --nx-bail \
            --parallel=3 \
            --base=${{ env.NX_BASE }} \
            --target=build-and-deploy \
            --verbose

Head and base SHA's are always equal on master and point to the current pull request commit

This is also the same configuration like in the official Nx demo project https://github.com/nrwl/board-game-hoard/blob/master/.github/workflows/release.yml

However, this is using push events and not pull_request events

on:
  push:
    branches:
      - 'main'

What am I doing wrong?

@mklueh
Copy link
Author

mklueh commented Dec 17, 2022

I've tested it now by pushing directly to the master, which works.

Would appreciate any help to get pull requests working. Thanks

@MartinFiskaly
Copy link
Contributor

Hello, I have a similar setup and the same issue.
It works fine on pushed and on PR creations or updates. But when squash merging the PR to main branch, it always sets both SHAs to the squashed commit.

I tried setting different last-successful-event values and even failing some runs on purpose but its always the same result: head and base SHA are the same (squashed commit SHA)

@MartinFiskaly
Copy link
Contributor

Hey @mklueh did you find a fix for this?

@sc-mavirdol
Copy link

I'm experiencing the same issue. When squashing and merging the PR to the main branch, both SHAs are set to the same squashed commit.

@MartinFiskaly @mklueh have you found any solution?

@MartinFiskaly
Copy link
Contributor

I'm experiencing the same issue. When squashing and merging the PR to the main branch, both SHAs are set to the same squashed commit.

@MartinFiskaly @mklueh have you found any solution?

@sc-mavirdol
Actually there's a fix I pushed on the latest version:
#92

To solve it at the time I just changed the on: configuration from pull_request to push since I had the possibility of doing that.

@mklueh
Copy link
Author

mklueh commented Jan 4, 2024

@sc-mavirdol I'm not having this issue anymore but I cannot tell you what I did to solve it.

Changed my setup and workflow a bit a while ago

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.

3 participants