Skip to content

Commit

Permalink
Split build steps (#70)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Et7f3 authored Jun 14, 2020
1 parent 2ed40d4 commit 903f528
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
45 changes: 36 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/print_esy_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 903f528

Please sign in to comment.