unit-test.yml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. name: Unit Tests
  2. on: [pull_request, push]
  3. jobs:
  4. prepare_matrix:
  5. runs-on: ubuntu-latest
  6. outputs:
  7. versions: ${{ steps.generate-matrix.outputs.versions }}
  8. steps:
  9. - name: Generate Node.js versions matrix
  10. id: generate-matrix
  11. run: |
  12. sudo apt-get install -y lynx
  13. lynx -dump https://endoflife.date/nodejs | grep -E -o '[0-9]+[( a-zA-Z]+LTS\)' | grep -E -o '([0-9]+)' > eol.list
  14. cat eol.list
  15. lts1=$(cat eol.list | head -1)
  16. lts2=$(cat eol.list | head -2 | tail -1)
  17. lts3=$(cat eol.list | head -3 | tail -1)
  18. VERSIONS="[$lts1, $lts2, $lts3]"
  19. echo "versions=${VERSIONS}" >> "$GITHUB_OUTPUT"
  20. test:
  21. needs:
  22. - prepare_matrix
  23. strategy:
  24. matrix:
  25. node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
  26. runs-on: macos-latest
  27. steps:
  28. - uses: actions/checkout@v3
  29. - uses: actions/setup-node@v3
  30. with:
  31. node-version: ${{ matrix.node-version }}
  32. - run: npm i -g npm
  33. name: Update NPM
  34. - run: npm install --no-package-lock
  35. name: Install dev dependencies
  36. - run: npm run lint
  37. name: Run linter
  38. - run: npm run test
  39. name: Run unit tests