Ubuntu runner does not expand double star

25 Views Asked by At

I have the following test command in package.json:

    "test": "node --test --enable-source-maps --loader ts-node/esm lib/**/*.test.ts && node --test index.test.js"

It runs locally, but on CI it fails:

yarn run v1.22.21
$ node --test --enable-source-maps --loader ts-node/esm lib/**/*.test.ts && node --test index.test.js
Could not find '/home/runner/work/assert-raisins/assert-raisins/lib/**/*.test.ts'

It looks like ** isn't being expanded. I tried to insert shopt -s globstar just about anywhere, but to no avail.

Full workflow YAML:

name: Node.js CI

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

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Setup node
      uses: actions/setup-node@v3
      with:
        cache: 'npm'
    - run: yarn
    - name: Run tests
      run: yarn test
1

There are 1 best solutions below

0
DudeOfAwesome On BEST ANSWER

NPM scripts use sh from your PATH by default. On some systems (like macOS), this "sh" is actually just bash in disguise, but that does not appear to be the case in the Github Action Runner.

sh does not support globstar, unlike bash, so you'll need to change which shell NPM wants to use. This can be done by adding a .npmrc file to your project, and setting the script-shell option to bash.