-
Notifications
You must be signed in to change notification settings - Fork 34
134 lines (129 loc) · 5.41 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
cancel_previous_run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build_details:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.packages.outputs.packages }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Grab packages to build
id: packages
run: |
PACKAGES_TO_RUN=$(OUTPUT_ONLY=true ./tests/run_tests.sh | while read i; do echo "\\\"$i\\\""; done | xargs | sed -e 's# #,#g' | tr -d '\n')
echo "Packages to run: ${PACKAGES_TO_RUN}"
echo "packages=[${PACKAGES_TO_RUN}]" >> "${GITHUB_OUTPUT}"
build_package:
runs-on: ubuntu-latest
needs: build_details
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.build_details.outputs.packages) }}
# ocaml compiler 4.14.1 does not have an option to build in 32 bit mode anymore.
arch: [x64]
ocaml_version: [4.14.1, 5.1.1]
container:
image: ocamlcross/windows-${{ matrix.arch }}-base:${{ matrix.ocaml_version }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build package
env:
PKG_CONFIG_PATH: ${{ matrix.arch == 'x64' && '/usr/src/mxe/usr/x86_64-w64-mingw32.static/lib/pkgconfig/' || '/usr/src/mxe/usr/i686-w64-mingw32.static/lib/pkgconfig/' }}
run: |
rm -rf /home/opam/opam-cross-windows/packages /home/opam/opam-cross-windows/repo
mv packages /home/opam/opam-cross-windows
mv repo /home/opam/opam-cross-windows
sudo -u opam opam update
sudo -u opam opam list --short --recursive --external --vars os-distribution=mxe,os-family=mingw --required-by=${{ matrix.package }} > /home/opam/mxe-deps
if [ -s /home/opam/mxe-deps ]; then
cd /usr/src/mxe/ && cat /home/opam/mxe-deps | xargs make
fi
eval $(sudo -u opam opam env)
sudo -u opam opam reinstall --verbose -y ${{ matrix.package }} ocaml-windows.${{ matrix.ocaml_version }}
- name: Export revdeps
id: revdeps
if: matrix.arch == 'x64'
run: |
eval $(sudo -u opam opam env)
BASE_PACKAGE=$(echo ${{ matrix.package }} | cut -d'.' -f 1)
REVDEPS_TO_BUILD=$(sudo -u opam opam list --rec --short --sort --depends-on=${{ matrix.package }} | grep -v "${BASE_PACKAGE}" | while read i; do echo "\\\"$i\\\""; done | xargs | sed -e 's# #,#g' | tr -d '\n')
echo "Revdeps to build: ${REVDEPS_TO_BUILD}"
echo "revdeps=[${REVDEPS_TO_BUILD}]" >> "${GITHUB_OUTPUT}"
- name: Write matrix output
if: matrix.arch == 'x64'
id: matrix_output
uses: cloudposse/github-action-matrix-outputs-write@main
with:
matrix-step-name: ${{ github.job }}
matrix-key: ${{ matrix.package }}
outputs: |-
revdeps: ${{ steps.revdeps.outputs.revdeps }}
collect_revdeps:
runs-on: ubuntu-latest
needs: [build_package]
outputs:
revdeps: ${{ steps.revdeps.outputs.revdeps }}
has_revdeps: ${{ steps.revdeps.outputs.has_revdeps }}
steps:
- name: Collect revdeps
uses: cloudposse/github-action-matrix-outputs-read@main
id: collect_revdeps
with:
matrix-step-name: build_package
- name: Export all revdeps
uses: satackey/[email protected]
id: revdeps
with:
script: |
const core = require("@actions/core")
const { revdeps } = JSON.parse('${{ steps.collect_revdeps.outputs.result }}')
const result = Object.keys(revdeps).reduce((result, key) =>
[...result, ...revdeps[key]], []);
console.log(`Collected revdeps: ${result}`);
core.setOutput("revdeps", JSON.stringify(result));
core.setOutput("has_revdeps", result.length !== 0);
build_revdeps:
runs-on: ubuntu-latest
needs: collect_revdeps
if: needs.collect_revdeps.outputs.has_revdeps == 'true'
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.collect_revdeps.outputs.revdeps) }}
arch: [x64]
ocaml_version: [4.14.1, 5.1.1]
container:
image: ocamlcross/windows-${{ matrix.arch }}-base:${{ matrix.ocaml_version }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build revdep
env:
PKG_CONFIG_PATH: ${{ matrix.arch == 'x64' && '/usr/src/mxe/usr/x86_64-w64-mingw32.static/lib/pkgconfig/' || '/usr/src/mxe/usr/i686-w64-mingw32.static/lib/pkgconfig/' }}
run: |
rm -rf /home/opam/opam-cross-windows/packages /home/opam/opam-cross-windows/repo
mv packages /home/opam/opam-cross-windows
mv repo /home/opam/opam-cross-windows
sudo -u opam opam update
sudo -u opam opam list --short --recursive --external --vars os-distribution=mxe,os-family=mingw --required-by=${{ matrix.package }} > /home/opam/mxe-deps
if [ -s /home/opam/mxe-deps ]; then
cd /usr/src/mxe/ && cat /home/opam/mxe-deps | xargs make
fi
eval $(sudo -u opam opam env)
sudo -u opam opam reinstall --verbose -y ${{ matrix.package }} ocaml-windows.${{ matrix.ocaml_version }}