unit-tests.yml 934 B

1234567891011121314151617181920212223242526272829
  1. name: unit testing
  2. on: push
  3. jobs:
  4. build-and-test:
  5. runs-on: ubuntu-latest
  6. steps:
  7. # Checks out code from Github.
  8. - name: Checkout repo
  9. uses: actions/checkout@v2
  10. # Restore cache if available.
  11. - name: Restore cached dependencies
  12. id: dep-cache
  13. uses: actions/cache@v2
  14. env:
  15. cache-name: jstoxml-cache
  16. with:
  17. path: node_modules
  18. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
  19. restore-keys: |
  20. ${{ runner.os }}-build-${{ env.cache-name }}-
  21. ${{ runner.os }}-build-
  22. ${{ runner.os }}-
  23. # Fully install from scratch when no cache is available.
  24. - name: Install dependencies from scratch (cache miss only)
  25. if: steps.dep-cache.outputs.cache-hit != 'true'
  26. run: npm i
  27. - name: Unit tests
  28. run: npm test
  29. shell: bash