-
Notifications
You must be signed in to change notification settings - Fork 216
170 lines (165 loc) · 5.99 KB
/
main.yml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
env:
cache_generation: 2024-06-13
# NOTE: Please keep .mergify.yml in sync when adding or removing any jobs.
name: main
on: [pull_request]
jobs:
build:
strategy:
matrix:
os:
- runner: 'macOS-latest'
archive-command: 'tar --create --bzip2 --file'
file-extension: 'tar.bz2'
executable-extension: ''
- runner: 'macos-13'
archive-command: 'tar --create --bzip2 --file'
file-extension: 'tar.bz2'
executable-extension: ''
- runner: 'ubuntu-latest'
archive-command: 'tar --create --bzip2 --file'
file-extension: 'tar.bz2'
executable-extension: ''
- runner: 'windows-latest'
archive-command: '7z a -tzip'
file-extension: 'zip'
executable-extension: '.exe'
stack-yaml:
- "stack.yaml"
include:
- os:
runner: "ubuntu-latest"
stack-yaml: "stack.ghc-8.10.yaml"
- os:
runner: "ubuntu-latest"
stack-yaml: "stack.ghc-9.2.yaml"
- os:
runner: "ubuntu-latest"
stack-yaml: "stack.ghc-9.4.yaml"
fail-fast: false
name: ${{ matrix.os.runner }} - ${{ matrix.stack-yaml }}
runs-on: ${{ matrix.os.runner }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
submodules: true
- id: setup-haskell-cabal
name: "Setup Haskell environment"
uses: haskell-actions/[email protected]
with:
enable-stack: true
stack-version: "latest"
stack-no-global: true
- name: "Cache"
uses: actions/cache@v4
with:
key: ${{ matrix.os.runner }}-${{ runner.arch }}-${{ env.cache_generation }}-${{ hashFiles(matrix.stack-yaml) }}
restore-keys: |
${{ matrix.os.runner }}-${{ runner.arch }}-${{ env.cache_generation }}-
path: |
${{ steps.setup-haskell-cabal.outputs.stack-root }}
- name: "Install libsodium"
shell: bash
run: |
if [ '${{matrix.os.runner}}' == 'ubuntu-latest' ]; then
sudo apt-get install -y libsodium-dev
fi
echo "::debug::'pkg-config libsodium' output:"
pkg-config --print-errors --libs libsodium || true
- name: "Build"
shell: bash
run: |
packages=(
dhall
dhall-bash
dhall-csv
dhall-docs
dhall-json
dhall-lsp-server
dhall-nix
dhall-openapi
dhall-toml
dhall-yaml
)
for package in "${packages[@]}"; do
if [ '${{matrix.os.runner}}' == 'windows-latest' ] && [ "${package}" == 'dhall-nix' ]; then
continue
fi
# We use --test --no-run-tests to avoid re-building all the local packages in the
# subsequent test step.
# See https://github.com/commercialhaskell/stack/issues/4977.
stack --stack-yaml "${{matrix.stack-yaml}}" build --test --no-run-tests --copy-bins --local-bin-path ./bin "${package}"
done
- name: "Run tests"
shell: bash
run: |
packages=(
dhall
dhall-bash
dhall-csv
dhall-docs
dhall-json
dhall-lsp-server
dhall-nix
dhall-openapi
dhall-toml
dhall-yaml
)
for package in "${packages[@]}"; do
if [ '${{matrix.os.runner}}' == 'windows-latest' ] && [ "${package}" == 'dhall-nix' ]; then
continue
fi
stack --stack-yaml "${{matrix.stack-yaml}}" test "${package}"
done
- name: "Prepare packaging"
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
shell: bash
run: |
mkdir -p share/man/man1
cp dhall/man/dhall.1 share/man/man1/
cp dhall-docs/src/Dhall/data/man/dhall-docs.1 share/man/man1/
- id: package
name: "Create packages"
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
shell: bash
run: |
packages=(
dhall
dhall-bash
dhall-csv
dhall-docs
dhall-json
dhall-lsp-server
dhall-nix
dhall-openapi
dhall-toml
dhall-yaml
)
function package() (
local package="${1}"
local version="$(stack query locals "${package}" version)"
shift
local assets=("${@}")
local package_file="${package}-${version}-${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}"
${{matrix.os.archive-command}} "${package_file}" "${assets[@]}"
)
exe='${{matrix.os.executable-extension}}'
package 'dhall' "bin/dhall${exe}" 'share/man/man1/dhall.1'
package 'dhall-bash' "bin/dhall-to-bash${exe}"
package 'dhall-csv' "bin/csv-to-dhall${exe}" "bin/dhall-to-csv${exe}"
package 'dhall-docs' "bin/dhall-docs${exe}" 'share/man/man1/dhall-docs.1'
package 'dhall-json' "bin/dhall-to-json${exe}" "bin/dhall-to-yaml${exe}" "bin/json-to-dhall${exe}"
package 'dhall-lsp-server' "bin/dhall-lsp-server${exe}"
if [ '${{matrix.os.runner}}' != 'windows-latest' ]; then
package 'dhall-nix' "bin/dhall-to-nix${exe}"
fi
package 'dhall-openapi' "bin/openapi-to-dhall${exe}"
package 'dhall-toml' "bin/dhall-to-toml${exe}" "bin/toml-to-dhall${exe}"
package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}"
- name: "Upload package"
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
uses: actions/upload-artifact@v4
with:
name: 'dhall-${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}'
path: 'dhall-*${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}'