Skip to content

Commit d72e770

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

File tree

1 file changed

+220
-0
lines changed

1 file changed

+220
-0
lines changed

.github/workflows/test-unix.yaml

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/linux.yml
2+
3+
name: CI (Linux)
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 (macOS only)
55+
if: runner.os == 'macos-latest'
56+
run: |
57+
echo PKG_CONFIG_PATH="$(brew --prefix)/opt/icu4c/lib/pkgconfig" >> "${GITHUB_ENV}"
58+
59+
60+
- name: ⏬ Setup Haskell
61+
uses: haskell-actions/setup@v2
62+
id: setup-haskell
63+
with:
64+
ghc-version: ${{ env.GHC_VERSION }}
65+
enable-stack: true
66+
stack-version: 'latest'
67+
68+
- name: ⏬ Install dependencies
69+
run: |
70+
stack build --only-dependencies
71+
72+
73+
# things to be cached
74+
75+
- name: 💾 Cache stack global package db
76+
if: always() && steps.stack-global.outputs.cache-hit != 'true'
77+
uses: actions/cache/save@v3
78+
with:
79+
path: ~/.stack
80+
key: ${{ steps.stack-global.outputs.cache-primary-key }}
81+
82+
- name: 💾 Cache .stack-work
83+
if: always() && steps.stack-work.outputs.cache-hit != 'true'
84+
uses: actions/cache/save@v3
85+
with:
86+
path: .stack-work
87+
key: ${{ steps.stack-work.outputs.cache-primary-key }}
88+
89+
90+
- name: 🔗 Bundle ICU4C DLLs (on macOS)
91+
if: runner.os == 'macos-latest'
92+
run: | # Bundle icu4c DLLs
93+
94+
# see if icu4c has been installed
95+
if [ "$(brew list | grep icu4c)" = "" ]
96+
then
97+
echo "installing icu4c"
98+
brew install icu4c
99+
fi
100+
101+
# get the directory of the DDLs we want (icuuc, icui18n, icudata)
102+
dylib_dir=$(dirname "$(brew list icu4c | grep icuuc.dylib)")
103+
104+
# find the path of "als"
105+
executable=$(find "$(stack path --local-install-root)"/bin -name "als")
106+
107+
# remove the old dylib, and make a new one
108+
rm -rf dylib
109+
mkdir dylib
110+
111+
################################################################################
112+
# icuuc
113+
################################################################################
114+
115+
icuuc_id=$(otool -L "$executable" | grep icuuc | awk '{print $1}')
116+
icuuc_id_basename=$(basename "$icuuc_id")
117+
118+
icuuc_path=$dylib_dir/$icuuc_id_basename
119+
icuuc_path_new=dylib/$icuuc_id_basename
120+
icuuc_id_new=@loader_path/dylib/$icuuc_id_basename
121+
122+
# copy icuuc to the new directory
123+
cp "$icuuc_path" "$icuuc_path_new"
124+
125+
# change icuuc's ID referenced by ALS
126+
install_name_tool -change "$icuuc_id" "$icuuc_id_new" "$executable"
127+
128+
echo "icuuc referenced by ALS"
129+
echo " old ID : $icuuc_id"
130+
echo " new ID : $icuuc_id_new"
131+
echo " old path: $icuuc_path"
132+
echo " new path: $icuuc_path_new"
133+
134+
################################################################################
135+
# icui18n
136+
################################################################################
137+
138+
icui18n_id=$(otool -L "$executable" | grep icui18n | awk '{print $1}')
139+
icui18n_id_basename=$(basename "$icui18n_id")
140+
141+
icui18n_path=$dylib_dir/$icui18n_id_basename
142+
icui18n_path_new=dylib/$icui18n_id_basename
143+
icui18n_id_new=@loader_path/dylib/$icui18n_id_basename
144+
145+
# copy icui18n to the new directory
146+
cp "$icui18n_path" "$icui18n_path_new"
147+
148+
# change icui18n's ID referenced by ALS
149+
install_name_tool -change "$icui18n_id" "$icui18n_id_new" "$executable"
150+
151+
echo "icui18n referenced by ALS"
152+
echo " old ID : $icui18n_id"
153+
echo " new ID : $icui18n_id_new"
154+
echo " old path: $icui18n_path"
155+
echo " new path: $icui18n_path_new"
156+
157+
################################################################################
158+
# icudata
159+
################################################################################
160+
161+
# otool -L "$icui18n_id" | grep icudata | awk '{print $1}'
162+
icudata_id=$(otool -L "$icuuc_path" | grep icudata | awk '{print $1}')
163+
icudata_id_basename=$(basename "$icudata_id")
164+
165+
icudata_path=$dylib_dir/$icudata_id_basename
166+
icudata_path_new=dylib/$icudata_id_basename
167+
168+
# copy icudata to the new directory
169+
cp "$icudata_path" "$icudata_path_new"
170+
171+
# no need of changing the ID because supposely it's already of "@loader_path"
172+
173+
echo "icudata referenced by icuuc"
174+
echo " old ID : $icudata_id"
175+
echo " old path : $icudata_path"
176+
echo " new path : $icudata_path_new"
177+
178+
179+
- name: 📦 Compress files
180+
id: zip
181+
run: |
182+
# locate the data-dir
183+
datadir=$(find "$(stack path --snapshot-install-root)/share" -type d -name "Agda-*")
184+
185+
# locate the executable
186+
executable=$(find "$(stack path --local-install-root)/bin" -name "als")
187+
188+
# make a temporary directory for compresssing
189+
mkdir zip
190+
cp -r "$datadir" zip/data
191+
if [[ ${{ runner.os }} == "macOS" ]]; then
192+
cp -r dylib zip/dylib
193+
fi
194+
cp "$executable" zip/
195+
196+
# compress
197+
if [[ ${{ runner.os }} == "Linux" ]]; then
198+
cd zip
199+
zip -r als-ubuntu.zip ./*
200+
cd ..
201+
mv zip/als-ubuntu.zip .
202+
fi
203+
if [[ ${{ runner.os }} == "macOS" ]]; then
204+
cd zip
205+
zip -r als-macos.zip ./*
206+
cd ..
207+
mv zip/als-macos.zip .
208+
fi
209+
210+
- name: 🔨 Build and run tests
211+
run: |
212+
stack test
213+
214+
# release (optional)
215+
- name: 🚢 Release Artifacts
216+
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts
217+
env:
218+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
219+
run: |
220+
gh release upload ${{ github.ref_name }} als-ubuntu.zip --clobber

0 commit comments

Comments
 (0)