Skip to content

Commit 183c69b

Browse files
committed
git remote add hello https://github.com/esy-ocaml/hello-reason; git fetch hello; git checkout hello/master -- .github
1 parent 71793fe commit 183c69b

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.github/workflows/build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
- uses: actions/[email protected]
13+
with:
14+
node-version: 12
15+
- uses: actions/[email protected]
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

.github/workflows/print_esy_cache.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require("fs");
2+
const os = require("os");
3+
const path = require("path");
4+
5+
const ESY_FOLDER = process.env.ESY__PREFIX
6+
? process.env.ESY__PREFIX
7+
: path.join(os.homedir(), ".esy");
8+
const esy3 = fs
9+
.readdirSync(ESY_FOLDER)
10+
.filter(name => name.length > 0 && name[0] === "3")
11+
.sort()
12+
.pop();
13+
module.exports = exports = core =>
14+
core.setOutput('esy_cache', path.join(ESY_FOLDER, esy3, "i"));

0 commit comments

Comments
 (0)