From 903f528740c6689a3213f167f2d22153e8b89cae Mon Sep 17 00:00:00 2001 From: Et7f3 Date: Sun, 14 Jun 2020 15:05:13 +0200 Subject: [PATCH] Split build steps (#70) * ci(deps): Use new shiny actions/github-script@v2 * uses: actions/setup-node@v1.4.2 * uses: actions/checkout@v2.2.0 * ci: Split the build step and comment it. * vmImage: macOS-10.14 * vmImage: macOS-10.14 --- .github/workflows/build.yml | 45 ++++++++++++++++++++++------ .github/workflows/print_esy_cache.js | 3 +- azure-pipelines.yml | 4 +-- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e17cbf3..1ff6fa29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,10 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v1.4.2 with: node-version: 12 - - uses: actions/checkout@v2 + - uses: actions/checkout@v2.2.0 - name: Install esy run: npm install -g esy @@ -26,22 +26,49 @@ jobs: run: esy install - name: Print esy cache + uses: actions/github-script@v2 id: print_esy_cache - run: node .github/workflows/print_esy_cache.js + with: + script: | + const path = require('path') + const scriptPath = path.resolve('.github/workflows/print_esy_cache.js') + require(scriptPath)(core) - name: Try to restore build cache - id: deps-cache-macos + id: deps-cache uses: actions/cache@v2 with: path: ${{ steps.print_esy_cache.outputs.esy_cache }} key: build-${{ matrix.os }}-${{ hashFiles('**/index.json') }} restore-keys: build-${{ matrix.os }}- - - name: Build - run: | - esy build - # Cleanup build cache in case dependencies have changed - esy cleanup . + # Here we use a low-level. In real situation you don't have to + # but it is useful in CI as it split the log in GitHub UI. + # You can see at a glance if it is your projet or your deps that break. + # + # We also use --release flag to build less. + # This allow us to spo syntax/type error more quickly. + - name: Build release dependencies + if: steps.deps-cache.outputs.cache-hit != 'true' + run: esy build-dependencies --release + + - name: Build project in release + run: esy build --release + + # Now that our core project build let builds others deps + - name: Build dependencies + if: steps.deps-cache.outputs.cache-hit != 'true' + run: esy build-dependencies + + - name: Build project + run: esy build + + # Here we cleanup if we have a cache fail because we use restore-keys. + # restore-keys take the old store even on cache fail. + # So, we have deps we don't care anymore. We prune them. + - name: Clean global store + if: steps.deps-cache.outputs.cache-hit != 'true' + run: esy cleanup . - name: Test run: esy test diff --git a/.github/workflows/print_esy_cache.js b/.github/workflows/print_esy_cache.js index 7b1901f5..a1498fe5 100644 --- a/.github/workflows/print_esy_cache.js +++ b/.github/workflows/print_esy_cache.js @@ -10,4 +10,5 @@ const esy3 = fs .filter(name => name.length > 0 && name[0] === "3") .sort() .pop(); -console.log(`::set-output name=esy_cache::${path.join(ESY_FOLDER, esy3, "i")}`); +module.exports = exports = core => + core.setOutput('esy_cache', path.join(ESY_FOLDER, esy3, "i")); diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 269bf2ae..65db12ce 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,7 +19,7 @@ jobs: - template: .ci/build-platform.yml parameters: platform: macOS - vmImage: macOS-10.13 + vmImage: macOS-10.14 # Need windows-2019 to do esy import/export-dependencies # which assumes you have bsdtar (tar.exe) in your system @@ -38,7 +38,7 @@ jobs: - macOS - Windows pool: - vmImage: macOS-10.13 + vmImage: macOS-10.14 demands: node.js steps: - template: .ci/cross-release.yml