Skip to content

Commit 496bc04

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

File tree

3 files changed

+228
-2
lines changed

3 files changed

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

0 commit comments

Comments
 (0)