Git Product home page Git Product logo

nrwl-nx-action's People

Contributors

cyrus-za avatar jeremylvln avatar megajin avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nrwl-nx-action's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: node

usage with github actions

Bug Report

Current behavior

Getting the next error.

2022-07-17T14:52:15.3296818Z added 109 packages, and audited 110 packages in 3s
2022-07-17T14:52:15.3297245Z 
2022-07-17T14:52:15.3297593Z 18 packages are looking for funding
2022-07-17T14:52:15.3298014Z   run `npm fund` for details
2022-07-17T14:52:15.3307014Z 
2022-07-17T14:52:15.3307270Z found 0 vulnerabilities
2022-07-17T14:52:15.3443968Z ##[group]Run mansagroup/nrwl-nx-action@v2
2022-07-17T14:52:15.3444233Z with:
2022-07-17T14:52:15.3444415Z   projects: mobile
2022-07-17T14:52:15.3444619Z   targets: init
2022-07-17T14:52:15.3444815Z   all: false
2022-07-17T14:52:15.3444996Z   affected: true
2022-07-17T14:52:15.3445212Z   parallel: false
2022-07-17T14:52:15.3445424Z   maxParallel: 3
2022-07-17T14:52:15.3445612Z   nxCloud: false
2022-07-17T14:52:15.3445811Z env:
2022-07-17T14:52:15.3446043Z   FLUTTER_ROOT: /opt/hostedtoolcache/flutter
2022-07-17T14:52:15.3446331Z   PUB_CACHE: /opt/hostedtoolcache/flutter/.pub-cache
2022-07-17T14:52:15.3446587Z ##[endgroup]
2022-07-17T14:52:15.4046704Z ##[group]๐Ÿ” Ensuring Nx is available
2022-07-17T14:52:15.4068649Z Found package.json file
2022-07-17T14:52:15.4069674Z ##[endgroup]
2022-07-17T14:52:15.4097289Z ##[error]Error: Failed to locate the 'nx' script in package.json, did you setup your project with Nx's CLI?
2022-07-17T14:52:15.4186118Z Post job cleanup.
2022-07-17T14:52:15.4220878Z Post job cleanup.

Expected behavior

Should run the command

Possible Solution

provide possibility to run with npx


Others:

Not a valid commit name

Bug Report

Current behavior

I'm trying to detect affected projects between 2 branches "dev,tst"

image

I got an error message Not a valid commit name

image

and It's working locally well

image

I'm not sure what is wrong I've made

Does not identify git boundaries correctly with rebase merge or push directly to branch

Bug Report

I believe the git boundaries are not being defined correctly when not using a merge or squash commit to a branch that runs your workflow.

Current behavior

If you choose rebase merge in your PR to add directly onto the target branch even if that PR contained 10 commits the base ref would be set to HEAD~1. I believe the same would happen if you pushed multiple commits directly to master/main without using a PR.

Expected behavior

When pushing to master the base ref should be reported as the target HEAD before the PR was merged.

Possible Solution

  1. use github.events to get the values - https://stackoverflow.com/a/61861763/2770668
  2. allow configuration to send baseRef and override the git boundaries logic
  3. Call out in the documentation this limitation, until fixed.

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

Feature Request

My current flow for running the CI is the following :

  • Create a feature branch
  • Push the feature branch
  • Create a pull request with the base branch master

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

Use of scan flag for NxCloud is deprecated

Bug Report

When using Nx Cloud, the --scan param is added. However, it has been deprecated and now results in errors:

Current behavior

https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490

Run mansagroup/[email protected]
  with:
    targets: e[2](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:2)e
    affected: true
    parallel: 1
    nxCloud: true
    all: false
  env:
    NX_RUN_GROUP: [3](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:3)30392379[4](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:4)
    NX_CLOUD_AUTH_TOKEN: ***
    NX_BASE: 990f3da1988d2719eb4eb2d[5](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:5)a[6](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:6)c1580e252b1b99
    NX_HEAD: b3a913818ee698ce[7](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:7)e5994df6e2a6d94e2[8](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:8)270d5
๐Ÿท Retrieving Git boundaries (affected command)
/opt/hostedtoolcache/node/16.17.1/x64/bin/npx nx affected --target=e2e --base=[9](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:9)90f3da1988d2719eb4eb2d5a6c1580e252b1b99 --head=bc2a795eb3d51caef0f5dee40d73e649[18](https://github.com/nx-squeezer/squeezer/actions/runs/3303923794/jobs/5452427490#step:6:20)f0ee04 --scan --parallel=1

 >  NX   Running target e2e for 1 project(s):

    - workspace-e2e
   
   With additional flags:
     --scan=true

 

> nx run workspace-e2e:e2e --scan=true


 >  NX   'scan' is not found in schema

Expected behavior

scan argument is no longer used

Possible Solution

Just remove it


Others:

Reference:

https://github.com/nrwl/nx/blob/840f4625638080f4ffea9b7665c407552145f165/packages/nx/src/utils/command-line-utils.ts#L69

Failed to locate the 'nx' script in package.json

Bug Report

I've faced the error Failed to locate the 'nx' script in package.json so I found the function assertHasNxPackageScript in this code base. this function checks package.json for nx commands. but I don't have the "nx" command even I started a project with nx-cli.

async function assertHasNxPackageScript(): Promise<void> {
  const packageJson = await loadPackageJson().catch(() => {
    throw new Error(
      "Failed to load the 'package.json' file, did you setup your project correctly?",
    );
  });

  core.info('Found package.json file');

  if (typeof packageJson.scripts?.nx !== 'string') // this line
    throw new Error(
      "Failed to locate the 'nx' script in package.json, did you setup your project with Nx's CLI?",
    );

  core.info("Found 'nx' script inside package.json file");
}

I actually don't know if this function has a bug. but if you know any solution please guide me. thx :)

P.S. I'm using act for the test locally

"Error: Error: Failed to load the 'package.json' file, did you setup your project correctly?"

Bug Report

Current behavior

Running action in GitHub, get error that can't load package.json.

Expected behavior

Package.json is loaded

Others:
Action:

on:
  pull_request:
    branches: [develop]

jobs:
  lint_and_build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2

      - name: Directory change
        run: |
          cd <nx_directory>

      - name: Nrwl Nx
        uses: MansaGroup/[email protected]
        with:
          targets: lint, build

Output:

Run MansaGroup/[email protected]
๐Ÿ” Ensuring Nx is available
Error: Error: Failed to load the 'package.json' file, did you setup your project correctly?

I put a pwd and ls in the Directory Change step to ensure I was in the right place, the output included the proper package.json file.

can not find target 'deploy' in XXXX project. Valid targets are: buiuld, serve, lint, test

Feature Request

Need ability to use custom targets with MansaGroup/[email protected].

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

I'm using @flowaccount/nx-serverless to facilitate deploying serverless projects in NX to AWS lambda. @flowaccount/nx-serverless modifies NX project with additional targets like deploy, offline, and sls. It seems MansaGroup/[email protected] does not support targets other than build, serve, lint, and test.

I'm trying to chain together @flowaccount/nx-serverless with MansaGroup/[email protected] to create a GitHUb workflow for deploying affected projects to AWS when a pull requests is closed. However, I'm getting this error:

image

Here is my GitHUb Workflow YML file:

name: pull-request

env:
  AWS_REGION_NAME: "us-east-2"

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

jobs:
  deploy:
    name: deploy app
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12.x]
    steps:

    - name: checkout code
      uses: actions/checkout@v2
      with:
        ref: main
        fetch-depth: 0

    - name: use node.js ${{ matrix.node-version }}
      uses: actions/setup-node@master
      with:
        always-auth: true
        node-version: ${{ matrix.node-version }}

    - name: install Nrwl Nx
      run: npm i nx

    - name: Fetch other branches
      run: git fetch --no-tags --prune --depth=5 origin $GITHUB_BASE_REF

    - name: install dependencies
      run: npm ci

    - name: Nrwl Nx
      uses: MansaGroup/[email protected]
      with:
        targets: build, deploy
        projects: occupations-api
        args: --base=origin/main --stage=dev --configuration=dev

Describe the solution you'd like

I'd like to be able to utilize custom targets with MansaGroup/[email protected]. In addition to the targets from @flowaccount/nx-serverless, perhaps ability to run my own custom targets. I can create custom targets with NX using @nrwl/workspace:run-commands builder.

What is the motivation/use case for changing the behavior?

Adding this capability will aid in making flexible GitHub Actions workfflows.

How to handle argument placement?

Following this comment from @ValeriyMaslenikov. I'm questioning myself how to place the arguments in the Nx command:

  • Placing them by default after a -- will cause them to be ignored by Nx
  • So one cannot add Nx-specific arguments to the command (like --configuration=prod to handle production builds)
  • However, removing this -- will require anybody to add them on their own for their arguments to be handled correctly by the executor (and not by Nx directly)

Two solutions:

  1. We add another input called nxArgs (or something like that) to the action for specific arguments to add before the --
  2. We expect anybody to add the -- manually, which could lead to hard debugging

nx affected is not correct

Bug Report

Current behavior

Completely ignore the nx-set-shas action, advised by the documentation: https://nx.dev/recipes/ci/monorepo-ci-github-actions

The base is not correct in this action, even if nx-set-shas set it before.

Screenshot 2023-06-28 at 17 03 20

Expected behavior

Don't override NX_BASE if it is set in the environment variables

Possible Solution

It should use the NX_BASE environment variable by default, to leverage nx-set-shas action


Others:

Latest version 3.2.2

Ability to pass configuration options to targets

Feature Request

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

For builds you may want to build targeting production within your CI or other environments.

Describe the solution you'd like

Add an input for flags passed to the commands. The main drawback here is that the flags would be the same for each target passed, and it may require splitting the targets out into different steps of the GHA workflow.

The process '/opt/hostedtoolcache/node/16.17.1/x64/bin/npm' failed with exit code 127

Bug Report

Current behavior

Whenever I am running the CI/CD, getting the following error:

Run mansagroup/nrwl-nx-action@v2
๐Ÿƒ Working in custom directory: ./
๐Ÿ” Ensuring Nx is available
/opt/hostedtoolcache/node/16.17.1/x64/bin/npm run nx -- run-many --target=lint --all
 [email protected] nx
 nx
/tmp/nx-d1766103.sh: 1: nx: not found
Error: Error: The process '/opt/hostedtoolcache/node/16.17.1/x64/bin/npm' failed with exit code 127

Code:

name: Nx CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v1
      with:
        node-version: 16
    - uses: mansagroup/nrwl-nx-action@v2
      with:
        targets: lint,build
        all: 'true'
        workingDirectory: ./

This error is occurring every time.

The "projects" paramater is ignored and nx runs all projects

Bug Report

Current behavior

Hello!
I'm trying to run the action with "projects" parameters, and instead of running only the project I defined, the action runs all the projects.


main.yml:

- name: Nrwl Nx uses: MansaGroup/[email protected] with: targets: e2e args: --verbose --mainArgs="--port=5000" affected: false projects: solar-dashboard-e2e all: false

The result:

`/usr/local/bin/npx nx run-many --target=e2e --all --verbose --mainArgs=--port=5000 --parallel=3

NX Running target e2e for 4 project(s):

  • solar-dashboard-e2e
  • solar-dashboard
  • image-analysis
  • main

With flags:
--verbose=true
--mainArgs=--port=5000`

I tried it also without "all"- same results.

Not possible to send an arg with a space in the value

Bug Report

Current behavior

When specifying args that contain a space in the value part of the arg, like so:

args: --alias=test --message="test test test"

The command that will get executed (in this case it's nx affected but seems like it would happen to any command that supports the args property) will end up being something like this:

nx affected --target=build '--alias=test' '--message="test' test 'test"'

This ends up passing the message arg as "test'. I've tried a lot of different variations with quotes and such, but can't seem to get past the space causing an issue (other than sending no space at all).

This seems to be due to the way that this action is splitting the args property here: https://github.com/MansaGroup/nrwl-nx-action/blob/main/src/index.ts#L27

Expected behavior

I'd expect that the above YAML would run a command like so:

nx affected --target=build '--alias=test' '--message="test test test"'

Affected command does not work on tags

Bug Report

Current behavior

I want to build only the affected apps when I create a new tag. The problem is that on a tag the last commit is only zeros. Is it possible that this works? My workaround is to build everything. :/

Expected behavior

Build only the affected apps.

Output

$ nx affected --target=lint --base=0000000000000000000000000000000000000000 --head=6cb6624933ed92b53c116d2271b23af57916b70a
fatal: Not a valid commit name 0000000000000000000000000000000000000000
fatal: No such ref: '0000000000000000000000000000000000000000'

Add All Contributors

Feature Request

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

All Contributors could update the README.md file if needed, saving quite some time.

Describe the solution you'd like

Teachability, Documentation, Adoption, Migration Strategy

What is the motivation/use case for changing the behavior?

Failed to locate the 'nx' script in package.json, did you setup your project with Nx's CLI?

Bug Report

Hi everyone, I am trying to figure out why my workflow keeps crashing. When entering the NX step the following will be shown in the GitHub Actions console:

Run mansagroup/nrwl-nx-action@v2
๐Ÿ” Ensuring Nx is available
Error: Error: Failed to locate the 'nx' script in package.json, did you setup your project with Nx's CLI?

I have tried yarn as well as npm both with the same results. However in our project we are only using yarn as our package manager. Here ist the workflow.yaml:

name: Tests, Docs, Changelogs, Publish
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

  workflow_dispatch:

jobs:
  build_lint_test_docs_readme_publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "19.x"
          registry-url: https://registry.npmjs.org/
          cache: "yarn"
      - name: Install Repo deps
        run: yarn install
      - name: Configure CI Git User
        run: |
          git config --global user.email [email protected]
          git config --global user.name GitHub Actions
      - name: Run NX Tasks
        uses: mansagroup/nrwl-nx-action@v2
        with:
          targets: version
          projects: array-utils
        env:
          NODE_AUTH_TOKEN: ${{ secrets.DREAM_BIT_UTILS_NPM_TOKEN }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: ๐Ÿ“ Automated Docs and Readmes

Current behavior

Error will show up while checking in the task mansagroup/nrwl-nx-action@v2.

Expected behavior

It should run the wanted NX task for the choosen project.

Possible Solution

I don't know at the moment.


Others:

Error: '/usr/bin/git' ambiguous argument 'HEAD~1'

Bug Report

I'm running into a bug with version 2.1.0 and 2.0.3

OS: Ubuntu 18.04.5 LTS

Current behavior

Run mansagroup/[email protected]
  with:
    nxCloud: true
    targets: lint,test,build,deploy
    all: false
    affected: true
    parallel: false
    maxParallel: 3
  env:
    NX_BRANCH: 
    NX_HEAD: 
    NX_RUN_GROUP: 614141274
    TAG: 9f79beb6b5d95548db67ef9b1c63e1cc8e16c19c
๐Ÿ” Ensuring Nx is available
  Found package.json file
  Found 'nx' script inside package.json file
  Using npm as package manager
๐Ÿท Retrieving Git boundaries (affected command)
  /usr/bin/git rev-parse HEAD~1
  fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
  HEAD~1
Error: Error: The process '/usr/bin/git' failed with exit code 128

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(deps): update dependency @vercel/ncc to v0.30.0
  • chore(deps): update jest monorepo to v27.1.0 (jest, jest-circus)

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.