CodexBloom - Programming Q&A Platform

GitHub Actions workflow scenarios to run due to unexpected 'No such file or directory' scenarios when using multiple jobs

👀 Views: 44 💬 Answers: 1 📅 Created: 2025-07-24
github-actions ci workflow yaml

I recently switched to I'm writing unit tests and I have a GitHub Actions workflow defined in my repository that is supposed to run multiple jobs in parallel. However, I'm working with an scenario where one of the jobs fails with a 'No such file or directory' behavior, even though the file exists in the repository. My workflow file looks like this: ```yaml name: CI on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Install dependencies run: npm install - name: Build project run: npm run build test: runs-on: ubuntu-latest needs: build steps: - name: Checkout code uses: actions/checkout@v2 - name: Run tests run: npm test ``` The behavior message I receive is: ``` behavior: /home/runner/work/my-repo/my-repo/dist/my-file.js: No such file or directory ``` This behavior occurs in the `test` job, which depends on the `build` job. I double-checked that the `build` job successfully creates `dist/my-file.js`, and it does. I’ve also ensured that the `npm run build` command completes successfully without any errors. One thing I noticed is that the `dist` directory is generated in the `build` job, but I wonder if it’s not being persisted or if there’s a scope scenario when moving to the `test` job. I tried adding an `artifacts` step to save the `dist` directory, but I’m not sure if that’s the right approach. Here’s what I tried: ```yaml build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Install dependencies run: npm install - name: Build project run: npm run build - name: Upload distribution files uses: actions/upload-artifact@v2 with: name: dist path: dist/ ``` And in the `test` job, I added: ```yaml - name: Download distribution files uses: actions/download-artifact@v2 with: name: dist ``` But the behavior continues. Am I missing something in how artifacts work between jobs, or is there a different way I should be structuring this? Any guidance would be greatly appreciated! I'm working in a Windows 10 environment. Is there a simpler solution I'm overlooking? This is my first time working with Yaml latest. Any advice would be much appreciated.