chromatic-cli icon indicating copy to clipboard operation
chromatic-cli copied to clipboard

Github Action onlyStoryFiles not respected

Open strewhella opened this issue 1 year ago • 4 comments

Bug report

I'm attempting to use the onlyStoryFiles option for the Github Action to limit snapshots and tests to only files of the form **/*.chromatic.tsx instead of the **/*.stories.tsx so I can incrementally add stories, but the setting doesn't appear to be respected. In this build I have 1 story matching the **/*.chromatic.tsx glob, but all stories except that one are picked up instead. Am I doing something wrong here, or is this a bug?

image

strewhella avatar Feb 27 '23 00:02 strewhella

Hi @strewhella. That is definitely an unexpected behavior. I just tested this out using a parameter like onlyStoryFiles: '**/*utton.stories.jsx' and it worked as expected. Can you share your GitHub Action workflow?

andrewortwein avatar Mar 02 '23 23:03 andrewortwein

Hi @andrewortwein, thanks for checking. The parts of the workflow that seem relevant are something like (sorry, it's hard to share the full details):

jobs:
  storybook:
    runs-on: ubuntu-latest
...
    steps:
      - uses: actions/checkout@v3
        with:
          # https://www.chromatic.com/docs/github-actions#support-for-codeactionscheckoutv2code-and-above
          fetch-depth: 0

      - uses: actions/setup-node@v3
        with:
          node-version: "18.13"

...

      - name: "Storybook: publish to Chromatic"
        uses: chromaui/action@v1
        env:
          NODE_OPTIONS: --max-old-space-size=16384
          DISABLE_CHROMATIC_SNAPSHOTS: ${{ env.DISABLE_CHROMATIC_SNAPSHOTS == 'true' }}
        with:
           projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
           workingDir: client/web
           exitOnceUploaded: true
           onlyStoryFiles: "**/*.chromatic.tsx"

And the one story file is something like client/web/src/app/foo/bar.chromatic.tsx.

Versions at the time of that build:

  • Chromatic: 6.17.0
  • chromaui/action: https://github.com/chromaui/action/commit/36a91e1b3efa5d09c6612886a0e2afee9fa710a6

(I work with Simon.)

huonw avatar Mar 13 '23 21:03 huonw

Hmm, I don't believe my test included the workingDir parameter, so maybe that's part of the problem. I'm away from my computer, so I'm only speculating here, but does that parameter need to be in quotes? We show it being in quotes in the docs, but I don't know if that is mandatory.

andrewortwein avatar Mar 17 '23 01:03 andrewortwein

I don't think so. For instance, loading the following YAML in a couple of different YAML loaders gives the same value for both workingDirs, e.g. http://nodeca.github.io/js-yaml/#yaml=cXVvdGVkOgogIHdvcmtpbmdEaXI6ICJjbGllbnQvd2ViIgp1bnF1b3RlZDoKICB3b3JraW5nRGlyOiBjbGllbnQvd2ViCg==

quoted:
  workingDir: "client/web"
unquoted:
  workingDir: client/web

huonw avatar Mar 17 '23 05:03 huonw