githubnpmgithub-actionspull-requestnpm-run

How to write a pipeline for a pull request for lint and run tests


I never wrote pipelines in github actions, I was asked to create a pipeline for a pull request for repositories in github using the commands:

npm run lint;
npm run test;

Solution

  • GitHub's own setup-node Action has examples of how to do this. Based on the docs there, something like this placed in a YAML file in the .github/workflows directory should work:

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '16'
    - run: npm install
    - run: npm lint
    - run: npm test