|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 11 | + steps: |
| 12 | + |
| 13 | + with: |
| 14 | + node-version: 12 |
| 15 | + |
| 16 | + - name: Install esy |
| 17 | + run: npm install -g esy |
| 18 | + |
| 19 | + - name: Try to restore install cache |
| 20 | + uses: actions/cache@v2 |
| 21 | + with: |
| 22 | + path: ~/.esy/source |
| 23 | + key: source-${{ hashFiles('**/index.json') }} |
| 24 | + |
| 25 | + - name: Install |
| 26 | + run: esy install |
| 27 | + |
| 28 | + - name: Print esy cache |
| 29 | + uses: actions/github-script@v2 |
| 30 | + id: print_esy_cache |
| 31 | + with: |
| 32 | + script: | |
| 33 | + const path = require('path') |
| 34 | + const scriptPath = path.resolve('.github/workflows/print_esy_cache.js') |
| 35 | + require(scriptPath)(core) |
| 36 | +
|
| 37 | + - name: Try to restore build cache |
| 38 | + id: deps-cache |
| 39 | + uses: actions/cache@v2 |
| 40 | + with: |
| 41 | + path: ${{ steps.print_esy_cache.outputs.esy_cache }} |
| 42 | + key: build-${{ matrix.os }}-${{ hashFiles('**/index.json') }} |
| 43 | + restore-keys: build-${{ matrix.os }}- |
| 44 | + |
| 45 | + # Here we use a low-level. In real situation you don't have to |
| 46 | + # but it is useful in CI as it split the log in GitHub UI. |
| 47 | + # You can see at a glance if it is your projet or your deps that break. |
| 48 | + # |
| 49 | + # We also use --release flag to build less. |
| 50 | + # This allow us to spo syntax/type error more quickly. |
| 51 | + - name: Build release dependencies |
| 52 | + if: steps.deps-cache.outputs.cache-hit != 'true' |
| 53 | + run: esy build-dependencies --release |
| 54 | + |
| 55 | + - name: Build project in release |
| 56 | + run: esy build --release |
| 57 | + |
| 58 | + # Now that our core project build let builds others deps |
| 59 | + - name: Build dependencies |
| 60 | + if: steps.deps-cache.outputs.cache-hit != 'true' |
| 61 | + run: esy build-dependencies |
| 62 | + |
| 63 | + - name: Build project |
| 64 | + run: esy build |
| 65 | + |
| 66 | + # Here we cleanup if we have a cache fail because we use restore-keys. |
| 67 | + # restore-keys take the old store even on cache fail. |
| 68 | + # So, we have deps we don't care anymore. We prune them. |
| 69 | + - name: Clean global store |
| 70 | + if: steps.deps-cache.outputs.cache-hit != 'true' |
| 71 | + run: esy cleanup . |
| 72 | + |
| 73 | + - name: Test |
| 74 | + run: esy test |
| 75 | + |
| 76 | + - name: Build docs |
| 77 | + run: esy doc |
0 commit comments