Skip to content

Commit 40c7871

Browse files
committed
[ ci ] Trying to merge test-linux.yaml with test-mac.yaml
1 parent 3266f71 commit 40c7871

File tree

3 files changed

+222
-2
lines changed

3 files changed

+222
-2
lines changed

.github/workflows/test-linux.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ name: CI (Linux)
44

55
on:
66
push:
7-
branches: [master, ci-*, ci]
7+
branches: [master]
8+
# branches: [master, ci-*, ci]
89
tags:
910
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
1011
pull_request:

.github/workflows/test-mac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: CI (macOS)
44

55
on:
66
push:
7-
branches: [master, ci-*, ci]
7+
branches: [master]
88
tags:
99
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
1010
pull_request:

.github/workflows/test-unix.yaml

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/linux.yml
2+
3+
name: CI (Unix)
4+
5+
on:
6+
push:
7+
branches: [master, ci-*, ci]
8+
tags:
9+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
10+
pull_request:
11+
branches: [master]
12+
13+
jobs:
14+
build-and-test:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
fail-fast: false
20+
steps:
21+
22+
- name: 📥 Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: 🔍 Determine stack resolver & GHC
26+
run: |
27+
STACK_RESOLVER=$(yq .resolver stack.yaml)
28+
GHC_VERSION=$(echo $(yq .compiler stack.yaml) | cut -c 5-)
29+
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}"
30+
echo GHC_VERSION="${GHC_VERSION}" >> "${GITHUB_ENV}"
31+
32+
# things to be restored:
33+
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers.
34+
35+
- name: 💾 Restore cached stack global package db
36+
id: stack-global
37+
uses: actions/cache/restore@v4
38+
with:
39+
path: ~/.stack
40+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global
43+
44+
- name: 💾 Restore cached .stack-work
45+
id: stack-work
46+
uses: actions/cache/restore@v4
47+
with:
48+
path: .stack-work
49+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }}
50+
restore-keys: |
51+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work
52+
53+
# actions:
54+
- name: Set PKG_CONFIG_PATH for the ICU library (on macOS)
55+
if: runner.os == 'macOS'
56+
run: |
57+
echo PKG_CONFIG_PATH="$(brew --prefix)/opt/icu4c/lib/pkgconfig" >> "${GITHUB_ENV}"
58+
59+
- name: ⏬ Setup Haskell
60+
uses: haskell-actions/setup@v2
61+
id: setup-haskell
62+
with:
63+
ghc-version: ${{ env.GHC_VERSION }}
64+
enable-stack: true
65+
stack-version: 'latest'
66+
67+
- name: ⏬ Install dependencies
68+
run: |
69+
stack build --only-dependencies
70+
71+
72+
# things to be cached
73+
74+
- name: 💾 Cache stack global package db
75+
if: always() && steps.stack-global.outputs.cache-hit != 'true'
76+
uses: actions/cache/save@v3
77+
with:
78+
path: ~/.stack
79+
key: ${{ steps.stack-global.outputs.cache-primary-key }}
80+
81+
- name: 💾 Cache .stack-work
82+
if: always() && steps.stack-work.outputs.cache-hit != 'true'
83+
uses: actions/cache/save@v3
84+
with:
85+
path: .stack-work
86+
key: ${{ steps.stack-work.outputs.cache-primary-key }}
87+
88+
89+
- name: 🔗 Bundle ICU4C DLLs (on macOS)
90+
if: runner.os == 'macOS'
91+
run: | # Bundle icu4c DLLs
92+
93+
# see if icu4c has been installed
94+
if [ "$(brew list | grep icu4c)" = "" ]
95+
then
96+
echo "installing icu4c"
97+
brew install icu4c
98+
fi
99+
100+
# get the directory of the DDLs we want (icuuc, icui18n, icudata)
101+
dylib_dir=$(dirname "$(brew list icu4c | grep icuuc.dylib)")
102+
103+
# find the path of "als"
104+
executable=$(find "$(stack path --local-install-root)"/bin -name "als")
105+
106+
# remove the old dylib, and make a new one
107+
rm -rf dylib
108+
mkdir dylib
109+
110+
################################################################################
111+
# icuuc
112+
################################################################################
113+
114+
icuuc_id=$(otool -L "$executable" | grep icuuc | awk '{print $1}')
115+
icuuc_id_basename=$(basename "$icuuc_id")
116+
117+
icuuc_path=$dylib_dir/$icuuc_id_basename
118+
icuuc_path_new=dylib/$icuuc_id_basename
119+
icuuc_id_new=@loader_path/dylib/$icuuc_id_basename
120+
121+
# copy icuuc to the new directory
122+
cp "$icuuc_path" "$icuuc_path_new"
123+
124+
# change icuuc's ID referenced by ALS
125+
install_name_tool -change "$icuuc_id" "$icuuc_id_new" "$executable"
126+
127+
echo "icuuc referenced by ALS"
128+
echo " old ID : $icuuc_id"
129+
echo " new ID : $icuuc_id_new"
130+
echo " old path: $icuuc_path"
131+
echo " new path: $icuuc_path_new"
132+
133+
################################################################################
134+
# icui18n
135+
################################################################################
136+
137+
icui18n_id=$(otool -L "$executable" | grep icui18n | awk '{print $1}')
138+
icui18n_id_basename=$(basename "$icui18n_id")
139+
140+
icui18n_path=$dylib_dir/$icui18n_id_basename
141+
icui18n_path_new=dylib/$icui18n_id_basename
142+
icui18n_id_new=@loader_path/dylib/$icui18n_id_basename
143+
144+
# copy icui18n to the new directory
145+
cp "$icui18n_path" "$icui18n_path_new"
146+
147+
# change icui18n's ID referenced by ALS
148+
install_name_tool -change "$icui18n_id" "$icui18n_id_new" "$executable"
149+
150+
echo "icui18n referenced by ALS"
151+
echo " old ID : $icui18n_id"
152+
echo " new ID : $icui18n_id_new"
153+
echo " old path: $icui18n_path"
154+
echo " new path: $icui18n_path_new"
155+
156+
################################################################################
157+
# icudata
158+
################################################################################
159+
160+
# otool -L "$icui18n_id" | grep icudata | awk '{print $1}'
161+
icudata_id=$(otool -L "$icuuc_path" | grep icudata | awk '{print $1}')
162+
icudata_id_basename=$(basename "$icudata_id")
163+
164+
icudata_path=$dylib_dir/$icudata_id_basename
165+
icudata_path_new=dylib/$icudata_id_basename
166+
167+
# copy icudata to the new directory
168+
cp "$icudata_path" "$icudata_path_new"
169+
170+
# no need of changing the ID because supposely it's already of "@loader_path"
171+
172+
echo "icudata referenced by icuuc"
173+
echo " old ID : $icudata_id"
174+
echo " old path : $icudata_path"
175+
echo " new path : $icudata_path_new"
176+
177+
178+
- name: 📦 Compress files
179+
id: zip
180+
run: |
181+
# locate the data-dir
182+
datadir=$(find "$(stack path --snapshot-install-root)/share" -type d -name "Agda-*")
183+
184+
# locate the executable
185+
executable=$(find "$(stack path --local-install-root)/bin" -name "als")
186+
187+
# make a temporary directory for compresssing
188+
mkdir zip
189+
cp -r "$datadir" zip/data
190+
if [[ ${{ runner.os }} == "macOS" ]]; then
191+
cp -r dylib zip/dylib
192+
fi
193+
cp "$executable" zip/
194+
195+
# compress
196+
if [[ ${{ runner.os }} == "Linux" ]]; then
197+
cd zip
198+
zip -r als-ubuntu.zip ./*
199+
cd ..
200+
mv zip/als-ubuntu.zip .
201+
fi
202+
if [[ ${{ runner.os }} == "macOS" ]]; then
203+
cd zip
204+
zip -r als-macos.zip ./*
205+
cd ..
206+
mv zip/als-macos.zip .
207+
fi
208+
209+
- name: 🔨 Build and run tests
210+
run: |
211+
stack test
212+
213+
# release (optional)
214+
- name: 🚢 Release Artifacts
215+
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts
216+
env:
217+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
218+
run: |
219+
gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber

0 commit comments

Comments
 (0)