Skip to content

Commit 23583d6

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

File tree

3 files changed

+226
-2
lines changed

3 files changed

+226
-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: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
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: ⏬ Install dependencies
90+
run: |
91+
stack build --only-dependencies
92+
93+
- name: 🔗 Bundle ICU4C DLLs (on macOS)
94+
if: runner.os == 'macOS'
95+
run: | # Bundle icu4c DLLs
96+
97+
# see if icu4c has been installed
98+
if [ "$(brew list | grep icu4c)" = "" ]
99+
then
100+
echo "installing icu4c"
101+
brew install icu4c
102+
fi
103+
104+
# get the directory of the DDLs we want (icuuc, icui18n, icudata)
105+
dylib_dir=$(dirname "$(brew list icu4c | grep icuuc.dylib)")
106+
107+
# find the path of "als"
108+
executable=$(find "$(stack path --local-install-root)"/bin -name "als")
109+
110+
# remove the old dylib, and make a new one
111+
rm -rf dylib
112+
mkdir dylib
113+
114+
################################################################################
115+
# icuuc
116+
################################################################################
117+
118+
icuuc_id=$(otool -L "$executable" | grep icuuc | awk '{print $1}')
119+
icuuc_id_basename=$(basename "$icuuc_id")
120+
121+
icuuc_path=$dylib_dir/$icuuc_id_basename
122+
icuuc_path_new=dylib/$icuuc_id_basename
123+
icuuc_id_new=@loader_path/dylib/$icuuc_id_basename
124+
125+
# copy icuuc to the new directory
126+
cp "$icuuc_path" "$icuuc_path_new"
127+
128+
# change icuuc's ID referenced by ALS
129+
install_name_tool -change "$icuuc_id" "$icuuc_id_new" "$executable"
130+
131+
echo "icuuc referenced by ALS"
132+
echo " old ID : $icuuc_id"
133+
echo " new ID : $icuuc_id_new"
134+
echo " old path: $icuuc_path"
135+
echo " new path: $icuuc_path_new"
136+
137+
################################################################################
138+
# icui18n
139+
################################################################################
140+
141+
icui18n_id=$(otool -L "$executable" | grep icui18n | awk '{print $1}')
142+
icui18n_id_basename=$(basename "$icui18n_id")
143+
144+
icui18n_path=$dylib_dir/$icui18n_id_basename
145+
icui18n_path_new=dylib/$icui18n_id_basename
146+
icui18n_id_new=@loader_path/dylib/$icui18n_id_basename
147+
148+
# copy icui18n to the new directory
149+
cp "$icui18n_path" "$icui18n_path_new"
150+
151+
# change icui18n's ID referenced by ALS
152+
install_name_tool -change "$icui18n_id" "$icui18n_id_new" "$executable"
153+
154+
echo "icui18n referenced by ALS"
155+
echo " old ID : $icui18n_id"
156+
echo " new ID : $icui18n_id_new"
157+
echo " old path: $icui18n_path"
158+
echo " new path: $icui18n_path_new"
159+
160+
################################################################################
161+
# icudata
162+
################################################################################
163+
164+
# otool -L "$icui18n_id" | grep icudata | awk '{print $1}'
165+
icudata_id=$(otool -L "$icuuc_path" | grep icudata | awk '{print $1}')
166+
icudata_id_basename=$(basename "$icudata_id")
167+
168+
icudata_path=$dylib_dir/$icudata_id_basename
169+
icudata_path_new=dylib/$icudata_id_basename
170+
171+
# copy icudata to the new directory
172+
cp "$icudata_path" "$icudata_path_new"
173+
174+
# no need of changing the ID because supposely it's already of "@loader_path"
175+
176+
echo "icudata referenced by icuuc"
177+
echo " old ID : $icudata_id"
178+
echo " old path : $icudata_path"
179+
echo " new path : $icudata_path_new"
180+
181+
182+
- name: 📦 Compress files
183+
id: zip
184+
run: |
185+
# locate the data-dir
186+
datadir=$(find "$(stack path --snapshot-install-root)/share" -type d -name "Agda-*")
187+
188+
# locate the executable
189+
executable=$(find "$(stack path --local-install-root)/bin" -name "als")
190+
191+
# make a temporary directory for compresssing
192+
mkdir zip
193+
cp -r "$datadir" zip/data
194+
if [[ ${{ runner.os }} == "macOS" ]]; then
195+
cp -r dylib zip/dylib
196+
fi
197+
cp "$executable" zip/
198+
199+
# compress
200+
if [[ ${{ runner.os }} == "Linux" ]]; then
201+
cd zip
202+
zip -r als-ubuntu.zip ./*
203+
cd ..
204+
mv zip/als-ubuntu.zip .
205+
fi
206+
if [[ ${{ runner.os }} == "macOS" ]]; then
207+
cd zip
208+
zip -r als-macos.zip ./*
209+
cd ..
210+
mv zip/als-macos.zip .
211+
fi
212+
213+
- name: 🔨 Build and run tests
214+
run: |
215+
stack test --ta --als-path=zip/als
216+
217+
# release (optional)
218+
- name: 🚢 Release Artifacts
219+
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts
220+
env:
221+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
run: |
223+
gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber

0 commit comments

Comments
 (0)