tests.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
  2. # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
  3. name: Node.js CI
  4. on:
  5. push:
  6. branches: ['*']
  7. pull_request:
  8. branches: [master]
  9. jobs:
  10. tests:
  11. name: Node.js ${{matrix.node-version}} on ${{matrix.os}}
  12. runs-on: ${{matrix.os}}
  13. strategy:
  14. matrix:
  15. os: [ubuntu-latest, windows-latest, macOS-latest]
  16. node-version: [14, 16, 18]
  17. steps:
  18. - uses: actions/checkout@v2
  19. with:
  20. submodules: true
  21. - name: Setup Node.js ${{matrix.node-version}}
  22. uses: actions/setup-node@v1
  23. with:
  24. node-version: ${{matrix.node-version}}
  25. - name: Get NPM cache directory
  26. id: npm-cache
  27. run: echo "::set-output name=dir::$(npm config get cache)"
  28. - name: Cache node modules
  29. uses: actions/cache@v2
  30. with:
  31. path: ${{steps.npm-cache.outputs.dir}}
  32. key: ${{runner.os}}-node-${{hashFiles('**/package-lock.json')}}
  33. restore-keys: |
  34. ${{runner.os}}-node-
  35. ${{runner.os}}-
  36. - name: Install the package and run tests
  37. run: |
  38. npm ci
  39. npm run build --if-present
  40. npm test