|
| 1 | +# Github actions workflow name |
| 2 | +name: Nodejs Test |
| 3 | + |
| 4 | +# Triggers the workflow on push or pull request events |
| 5 | +on: [push, pull_request] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + name: 'Tests on ${{matrix.os}} with node${{matrix.node}}' |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + # Test all mainstream operating system |
| 13 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 14 | + # Latest four Nodejs LTS version |
| 15 | + node: [10, 12, 14, 16] |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + steps: |
| 18 | + # Pull repo to test machine |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + # Configures the node version used on GitHub-hosted runners |
| 21 | + - uses: actions/setup-node@v2 |
| 22 | + with: |
| 23 | + # The Node.js version to configure |
| 24 | + node-version: ${{ matrix.node }} |
| 25 | + |
| 26 | + # Caching dependencies to speed up workflows |
| 27 | + - name: Get npm cache directory |
| 28 | + id: npm-cache-dir |
| 29 | + run: | |
| 30 | + echo "::set-output name=dir::$(npm config get cache)" |
| 31 | + - uses: actions/cache@v2 |
| 32 | + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' |
| 33 | + with: |
| 34 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 35 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-node- |
| 38 | +
|
| 39 | + - name: Install npm dependencies |
| 40 | + run: npm install |
| 41 | + |
| 42 | + - name: Print put node & npm version |
| 43 | + # Output useful info for debugging. |
| 44 | + run: node --version && npm --version |
| 45 | + |
| 46 | + - name: Run unit test |
| 47 | + run: cd packages/less && npm test |
0 commit comments