Dependency
Description
What it does: Runs npm ci and npm test automatically for pushes to main and for pull requests.
Step-by-step
-
Create file at .github/workflows/ci-tests.yml with the content above.
-
Commit & push:
git add .github/workflows/ci-tests.yml
git commit -m "ci: add Node.js test workflow"
git push
name: CI - Node.js Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
-
Open the Actions tab in GitHub to see the workflow run.
-
Expand the Run tests step to view logs and failures.
-
Customize: change node-version, branch name, or the test command (e.g., npm run test:ci).
Absolutely, Finding! Here's a clear and structured Spec section for your GitHub Actions CI workflow issue:
✅ Spec: CI Workflow for Node.js Tests
🧾 What It Does
This GitHub Actions workflow ensures automated testing for a Node.js project by:
- Installing dependencies using
npm ci
- Running tests using
npm test
- Triggering on:
- Pushes to the
main branch
- Pull requests targeting the
main branch
🎯 Acceptance Criteria
The implementation will be considered complete and successful when:
✅ Workflow Setup
✅ Trigger Conditions
✅ Execution & Visibility
✅ Customization Support
✅ Validation
Copilot Prompts
🛠️ Setup & Configuration Prompts
- “Can you help me write a GitHub Actions workflow that runs tests on Node.js 18?”
- “What does
npm ci do differently from npm install in CI workflows?”
- “How do I trigger this workflow only on changes to the
src/ folder?”
- “Can you modify this workflow to run on Node.js 16 and 18 in parallel?”
- “Add caching to this workflow to speed up npm installs.”
🧪 Debugging & Troubleshooting Prompts
- “Why is my
npm test step failing in GitHub Actions?”
- “How do I view detailed logs from the ‘Run tests’ step?”
- “My workflow isn’t triggering on pull requests—can you check the
on: block?”
- “What does the error ‘Cannot find module’ mean in the test logs?”
- “How do I make the workflow fail if tests are skipped?”
🔧 Customization Prompts
- “Change the workflow to run
npm run test:ci instead of npm test.”
- “Update the workflow to run only on pushes to
develop instead of main.”
- “Add a step to run
eslint before tests.”
- “Can you include a matrix to test on multiple operating systems?”
- “Make the workflow send a Slack notification if tests fail.”
✅ Validation & Best Practices Prompts
- “Is this workflow optimized for speed and reliability?”
- “What are best practices for Node.js CI workflows on GitHub Actions?”
- “Can you validate this YAML syntax?”
- “How do I ensure this workflow doesn’t run on draft pull requests?”
- “Can you add a badge to the README showing workflow status?”
Target Date: 📆 Sep 23, 2025
Dependency
Description
What it does: Runs npm ci and npm test automatically for pushes to main and for pull requests.
Step-by-step
Create file at .github/workflows/ci-tests.yml with the content above.
Commit & push:
Open the Actions tab in GitHub to see the workflow run.
Expand the Run tests step to view logs and failures.
Customize: change node-version, branch name, or the test command (e.g., npm run test:ci).
Absolutely, Finding! Here's a clear and structured Spec section for your GitHub Actions CI workflow issue:
✅ Spec: CI Workflow for Node.js Tests
🧾 What It Does
This GitHub Actions workflow ensures automated testing for a Node.js project by:
npm cinpm testmainbranchmainbranch🎯 Acceptance Criteria
The implementation will be considered complete and successful when:
✅ Workflow Setup
.github/workflows/ci-tests.ymlexists in the repositoryCI - Node.js Testsubuntu-latestenvironment18viaactions/setup-node@v4npm cinpm test✅ Trigger Conditions
mainbranchmainbranch✅ Execution & Visibility
✅ Customization Support
npm run test:ci)✅ Validation
Copilot Prompts
🛠️ Setup & Configuration Prompts
npm cido differently fromnpm installin CI workflows?”src/folder?”🧪 Debugging & Troubleshooting Prompts
npm teststep failing in GitHub Actions?”on:block?”🔧 Customization Prompts
npm run test:ciinstead ofnpm test.”developinstead ofmain.”eslintbefore tests.”✅ Validation & Best Practices Prompts
Target Date: 📆 Sep 23, 2025