preactjs / compressed-size-action

GitHub Action that adds compressed size changes to your PRs.
https://github.com/marketplace/actions/compressed-size-action
MIT License
602 stars 84 forks source link

Directory support for monorepo #38

Closed azu closed 3 years ago

azu commented 4 years ago

Unfortunately, GitHub Actions does nose support the combination of working-directory and uses & with. So, we can not use this action for subdirectory package like monorepo .

name: builder size
on: [pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: setup Node
        uses: actions/setup-node@v1
      - name: size check
        uses: preactjs/compressed-size-action@v2
        working-directory: ./packages/foo # This is invalid syntax
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'
          pattern: './build-output/**/*.js'
          build-script: 'build'

Probably, directory option or shell-script option will resolve this issue.

Currently, build-script specify npm run-script. If this action provide shell-script, it allow us to write shell-script: cd packages/foo && npm run build.

developit commented 4 years ago

Hiya @azu! Would it be sufficient to provide a cwd option that just does process.cwd() before running the action's commands? Something like:

name: builder size
on: [pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: setup Node
        uses: actions/setup-node@v1
      - name: size check
        uses: preactjs/compressed-size-action@v2
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'
          pattern: './build-output/**/*.js'
          cwd: './packages/foo'
          build-script: 'build'
azu commented 4 years ago

@developit Yes! cwd option will resolve this issue.

abenhamdine commented 4 years ago

hmm I think process.cwd() is not enough, you have to pass subdirectory path to exec options.

See my fork (made for this very problem) here https://github.com/Arhia/action-check-compressed-size/blob/d077730df108613372127cee5ffc03849499ea18/src/main.ts#L42

bartvanvliet commented 4 years ago

Any update on this?

developit commented 3 years ago

@abenhamdine prorcess.chdir() changes the current process working directory, which applies to all child processes including those spawned via exec()/spawn()/etc.