-
Notifications
You must be signed in to change notification settings - Fork 17
154 lines (127 loc) · 5.06 KB
/
test-windows.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# modified from https://github.com/simonmichael/hledger/blob/master/.github/workflows/windows.yml
name: CI (Windows)
on:
push:
branches: [master, ci-*]
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [master]
defaults:
run:
shell: bash
jobs:
build:
runs-on: windows-latest
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
- name: 🏗 Install yq
uses: frenck/action-setup-yq@v1
- name: Determine stack root and resolver
## 2023-11-21 https://github.com/commercialhaskell/stack/issues/6340
## Asking stack for the stack root unfortunately does not work
## if stack is not fully operational (meaning e.g. that GHC is installed)
## so we hardcode its location instead.
run: |
STACK_ROOT="C:/Users/runneradmin/AppData/Local/Programs/stack/x86_64-windows"
STACK_RESOLVER=$(yq .resolver stack.yaml)
echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}"
# run: |
# STACK_ROOT="$(stack --system-ghc --no-install-ghc path --stack-root || echo "C:/Users/runneradmin/AppData/Local/Programs/stack/x86_64-windows")"
# echo "STACK_ROOT = ${STACK_ROOT}"
# echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
# What about C:/Users/runneradmin/AppData/Roaming/stack ?
# things to be restored:
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers.
- name: 💾 Restore cached stack global package db
id: stack-global
uses: actions/cache/restore@v3
with:
path: ${{ env.STACK_ROOT }}
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global
- name: 💾 Restore cached .stack-work
id: stack-work
uses: actions/cache/restore@v3
with:
path: .stack-work
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work
# actions
- name: ⏬ Install stack
## Stack is preinstalled on GHA runners.
#
#if: steps.stack-programs-dir.outputs.cache-hit != 'true'
# this step is needed to get stack.exe into PATH, for now
# curl -sL https://get.haskellstack.org/stable/windows-x86_64.zip -o stack.zip
# 7z x stack.zip stack.exe
run: |
which stack
stack --version
- name: ⏬ Install GHC
# if: steps.stack-programs-dir.outputs.cache-hit != 'true'
# set PATH=C:\Users\runneradmin\AppData\Local\Programs\stack\local\bin;%PATH%
run: |
stack --no-terminal setup --install-ghc
- name: Install the icu library
run: |
stack exec -- pacman -S --noconfirm mingw-w64-x86_64-icu mingw-w64-x86_64-pkgconf
- name: 📸 Build Snapshot
run: |
stack build --no-terminal --only-snapshot -j1
- name: 🧰 Build Dependencies
run: |
stack build --no-terminal --only-dependencies
- name: 🔨 Build and run tests
run: |
stack test
# things to be cached
- name: 💾 Cache stack global package db
if: always() && steps.stack-global.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ${{ env.STACK_ROOT }}
key: ${{ steps.stack-global.outputs.cache-primary-key }}
- name: 💾 Cache .stack-work
if: always() && steps.stack-work.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: .stack-work
key: ${{ steps.stack-work.outputs.cache-primary-key }}
# release (optional)
# artifacts:
- name: 📦 Compress executable and data files
shell: pwsh
run: |
# locate the data-dir
$snapshot = (stack path --snapshot-install-root)
$datadir = (ls $snapshot\share *Agda-* -Recurse -Directory).FullName
# locate the executable
$local = (stack path --local-install-root)
$executable = (ls $local\bin *als.exe* -Recurse -File).FullName
# make a temporary directory for compresssing
mkdir zip
cp -r $datadir zip/data
cp $executable zip/
# include text-icu DLLs
$mingw64bin = (stack path --extra-library-dirs).split(", ") -match "\\bin"
ls $mingw64bin
cp (ls $mingw64bin *libicudt*) zip/
cp (ls $mingw64bin *libicuin*) zip/
cp (ls $mingw64bin *libicuuc*) zip/
ls zip
# compress
cd zip
Compress-Archive * als-windows.zip
cd ..
mv zip/als-windows.zip .
- name: 🚢 Release Artifacts
if: startsWith(github.ref, 'refs/tags/v') # so that only commits with a git tag would upload artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} als-windows.zip --clobber