Skip to content

Commit 537af69

Browse files
authored
Take over some Github actions improvements from hello-reason (#56)
1 parent 14fd5a3 commit 537af69

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,47 @@ jobs:
1818
os: [ubuntu-latest, macOS-latest, windows-latest]
1919

2020
steps:
21-
- uses: actions/checkout@v1
2221
- name: Use Node.js ${{ matrix.node-version }}
2322
uses: actions/setup-node@v1
2423
with:
2524
node-version: ${{ matrix.node-version }}
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
2628
- name: Install esy
2729
run: npm i -g esy@0.6.4
28-
- name: Get esy store path
29-
id: esy_cache_path
30-
shell: bash
31-
run: |
32-
# COMPUTE THE ESY INSTALL CACHE LOCATION AHEAD OF TIME
33-
if [ "${{ matrix.os }}" == "windows-latest" ]; then
34-
THE_ESY__CACHE_INSTALL_PATH=$HOME/.esy/3_/i
35-
THE_ESY__CACHE_INSTALL_PATH=$( cygpath --mixed --absolute "$THE_ESY__CACHE_INSTALL_PATH")
36-
else
37-
DESIRED_LEN="86"
38-
HOME_ESY3="$HOME/.esy/3"
39-
HOME_ESY3_LEN=${#HOME_ESY3}
40-
NUM_UNDERS=$(echo "$(($DESIRED_LEN-$HOME_ESY3_LEN))")
41-
UNDERS=$(printf "%-${NUM_UNDERS}s" "_")
42-
UNDERS="${UNDERS// /_}"
43-
THE_ESY__CACHE_INSTALL_PATH=${HOME_ESY3}${UNDERS}/i
44-
fi
45-
echo "THE_ESY__CACHE_INSTALL_PATH: $THE_ESY__CACHE_INSTALL_PATH"
46-
echo "##[set-output name=path;]$THE_ESY__CACHE_INSTALL_PATH"
47-
- name: Restore esy cache
30+
31+
- name: Restore esy install cache
4832
uses: actions/cache@v1
4933
with:
50-
path: ${{ steps.esy_cache_path.outputs.path }}
51-
key: v1-esy-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
52-
restore-keys: |
53-
v1-esy-${{ matrix.os }}-
34+
path: ~/.esy/source
35+
key: source-${{ hashFiles('**/index.json') }}
36+
5437
- name: esy install
5538
run: esy install
39+
40+
- name: Get esy cache folder
41+
id: print_esy_cache
42+
run: node .github/workflows/print_esy_cache.js
43+
44+
- name: Restore esy build cache
45+
uses: actions/cache@v1
46+
with:
47+
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
48+
key: build-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
49+
restore-keys: build-${{ matrix.os }}-
50+
5651
- name: Build
57-
run: esy build
52+
run: |
53+
esy build
54+
# Cleanup build cache in case dependencies have changed
55+
esy cleanup .
56+
5857
- name: Test
5958
run: esy test
60-
- name: Get esy binary path
61-
id: esy_binary_path
59+
60+
- name: Get binary path
61+
id: print_binary_path
6262
shell: bash
6363
run: |
6464
# from https://stackoverflow.com/a/24848739/617787
@@ -68,9 +68,10 @@ jobs:
6868
ESY__BINARY_PATH=${b}${d#$s/}/Extract.exe
6969
echo "ESY__BINARY_PATH: $ESY__BINARY_PATH"
7070
echo "##[set-output name=path;]$ESY__BINARY_PATH"
71+
7172
- name: (only on release) Upload artifacts ${{ matrix.os }}
7273
if: github.event_name != 'pull_request'
73-
uses: actions/upload-artifact@master
74+
uses: actions/upload-artifact@v2
7475
with:
7576
name: ${{ matrix.os }}
76-
path: ${{ steps.esy_binary_path.outputs.path }}
77+
path: ${{ steps.print_binary_path.outputs.path }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
9+
const esy3 = fs
10+
.readdirSync(ESY_FOLDER)
11+
.filter((name) => name.length > 0 && name[0] === "3")
12+
.sort()
13+
.pop();
14+
15+
const esyCachePath = path.join(ESY_FOLDER, esy3, "i");
16+
17+
// For logging
18+
console.log(`esy cache path is ${esyCachePath}`);
19+
20+
// For passing output to subsequent GitHub actions
21+
console.log(`::set-output name=esy_cache::${esyCachePath}`);

lib/dune

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
(library
22
(name lib)
3-
(public_name bs-react-intl-extractor)
43
(libraries reason yojson unix)
54
)

0 commit comments

Comments
 (0)