actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.51k stars 1.2k forks source link

Wildcard ** pattern hashFiles only finds root files #1125

Closed zomars closed 1 year ago

zomars commented 1 year ago

We have this hashing function that in theory should hash all .js, .ts, .jsx and .tsx files: ${{ hashFiles('**.[jt]s', '**.[jt]sx') }} (got this snippet from Next.js docs) but when debugging we only get the root .ts and .js files:

This is the resulting logs with debug enabled:

##[debug]Evaluating: hashFiles('**.[jt]s', '**.[jt]sx')
##[debug]Evaluating hashFiles:
##[debug]..Evaluating String:
##[debug]..=> '**.[jt]s'
##[debug]..Evaluating String:
##[debug]..=> '**.[jt]sx'
##[debug]Search root directory: '/home/runner/work/cal.com/cal.com'
##[debug]Search pattern: '**.[jt]s, **.[jt]sx'
##[debug]Starting process:
##[debug]  File name: '/home/runner/runners/2.301.1/externals/node16/bin/node'
##[debug]  Arguments: '"/home/runner/runners/2.301.1/bin/hashFiles"'
##[debug]  Working directory: '/home/runner/work/cal.com/cal.com'
##[debug]  Require exit code zero: 'False'
##[debug]  Encoding web name:  ; code page: ''
##[debug]  Force kill process on cancellation: 'False'
##[debug]  Redirected STDIN: 'False'
##[debug]  Persist current code page: 'False'
##[debug]  Keep redirected STDIN open: 'False'
##[debug]  High priority process: 'False'
##[debug]Updated oom_score_adj to 500 for PID: 2409.
##[debug]Process started with process id 2409, waiting for process exit.
##[debug]Match Pattern: **.[jt]s
##[debug]**.[jt]sx
##[debug]::debug::followSymbolicLinks 'false'
##[debug]::debug::followSymbolicLinks 'false'
##[debug]::debug::implicitDescendants 'true'
##[debug]::debug::omitBrokenSymbolicLinks 'true'
##[debug]::debug::Search path '/home/runner/work/cal.com/cal.com'
##[debug]/home/runner/work/cal.com/cal.com/.eslintrc.js
##[debug]/home/runner/work/cal.com/cal.com/.prettierrc.js
##[debug]/home/runner/work/cal.com/cal.com/jest.config.ts
##[debug]/home/runner/work/cal.com/cal.com/playwright.config.ts
##[debug]Found 4 files to hash.
##[debug]Hash result: '1f02768e1a6ba97fa81ffb362bbd7cf64028bace3e0f4290358d7be95977ecb9'
##[debug]undefined
##[debug]STDOUT/STDERR stream read finished.
##[debug]STDOUT/STDERR stream read finished.
##[debug]Finished process 2409 with exit code 0, and elapsed time 00:00:00.085702

Here's a test run:

https://github.com/zomars/cal.com/actions/runs/4289686040/jobs/7473010660

kotewar commented 1 year ago

Hi @zomars ,

I tried forking your repo and trying the same but looks like I was missing something.

Anyways, I suspect your pattern doesn't checks for all the repos nested and only root repo, that's why you must be facing the issue.

Can you please try including all folder? Something like this?

${{ hashFiles('**/**.[jt]s', '**/**.[jt]sx') }}
zomars commented 1 year ago

Your suggestion worked although it is inconsistent with the GitHub docs

image

kotewar commented 1 year ago

I think wildcards are handled by actions/glob package. Maybe you can try opening an issue there and ask them if the docs are incorrect or if there's any bug that they might need to fix as a follow up to this.

Closing this as resolved from our end.