Debian Codegraph @

.github/workflows/build.yml

raw
1 name: Build
2
3 on:
4 push:
5 branches:
6 - '4.**'
7 - '5.**'
8 - 'trunk'
9 pull_request:
10
11 # Restrict the GITHUB_TOKEN
12 permissions: {}
13
14 env:
15 # List of test directories for the debug-s4096 and linux-O0 jobs. These
16 # directories are selected because of their tendencies to reach corner cases
17 # in the runtime system.
18 PARALLEL_TESTS: parallel callback gc-roots weak-ephe-final
19 # Fully print commands executed by Make
20 # MAKEFLAGS: V=1
21
22 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
23 # Concurrent workflows are grouped by the PR or branch that triggered them
24 # (github.ref) and the name of the workflow (github.workflow). The
25 # 'cancel-in-progress' option then make sure that only one workflow is running
26 # at a time. This doesn't prevent new jobs from running, rather it cancels
27 # already running jobs before scheduling new jobs.
28 concurrency:
29 group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' || github.sha }}
30 cancel-in-progress: true
31
32 jobs:
33 # This job will do the initial build of the compiler (on linux), with flambda on.
34 # We then upload the compiler tree as a build artifact to enable re-use in
35 # subsequent jobs.
36 build:
37 runs-on: ubuntu-latest
38 outputs:
39 manual_changed: ${{ steps.manual.outputs.manual_changed }}
40 steps:
41 - name: Checkout
42 uses: actions/checkout@v5
43 with:
44 persist-credentials: false
45 - name: Check for manual changes
46 id: manual
47 run: >-
48 tools/ci/actions/check-manual-modified.sh
49 '${{ github.ref }}'
50 '${{ github.event_name }}'
51 '${{ github.event.pull_request.base.ref }}'
52 '${{ github.event.pull_request.base.sha }}'
53 '${{ github.event.pull_request.head.ref }}'
54 '${{ github.event.pull_request.head.sha }}'
55 '${{ github.event.ref }}'
56 '${{ github.event.before }}'
57 '${{ github.event.ref }}'
58 '${{ github.event.after }}'
59 '${{ github.event.repository.full_name }}'
60 - name: Configure tree
61 run: |
62 MAKE_ARG=-j CONFIG_ARG='--enable-flambda --enable-cmm-invariants --enable-codegen-invariants --enable-dependency-generation --enable-native-toplevel' OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh configure
63 - name: Build
64 run: |
65 MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh build
66 - name: Prepare Artifact
67 run: tar --zstd -cf /tmp/sources.tar.zstd .
68 - name: Upload Artifact
69 uses: actions/upload-artifact@v4
70 with:
71 name: compiler
72 path: /tmp/sources.tar.zstd
73 retention-days: 1
74
75 # Full testsuite run, and other sanity checks
76 # "extra" testsuite runs, reusing the previously built compiler tree.
77 # debug: running the full testsuite with the
78 # debug runtime and minor heap verification.
79 # debug-s4096: select testsuite run with the debug runtime and a small
80 # minor heap.
81 normal:
82 name: ${{ matrix.name }}
83 needs: [build, config]
84 runs-on: ubuntu-latest
85 strategy:
86 matrix:
87 include:
88 - id: normal
89 name: normal
90 dependencies: texlive-latex-extra texlive-fonts-recommended texlive-luatex hevea sass gdb lldb
91 - id: debug
92 name: extra (debug)
93 - id: debug-s4096
94 name: extra (debug-s4096)
95 fail-fast: true
96 steps:
97 - name: Download Artifact
98 uses: actions/download-artifact@v4
99 with:
100 name: compiler
101 - name: Unpack Artifact
102 run: |
103 tar --zstd -xf sources.tar.zstd
104 rm -f sources.tar.zstd
105 - name: Packages
106 if: matrix.dependencies != ''
107 run: |
108 sudo apt-get update -y
109 sudo apt-get install -y ${{ matrix.dependencies }}
110 - name: Run the testsuite
111 if: ${{ matrix.id == 'normal' && needs.config.outputs.skip-testsuite != 'true' }}
112 run: |
113 MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test
114 - name: Run the testsuite (debug runtime)
115 if: ${{ matrix.id == 'debug' && needs.config.outputs.skip-testsuite != 'true' }}
116 env:
117 OCAMLRUNPARAM: v=0,V=1
118 USE_RUNTIME: d
119 run: |
120 bash -cxe "SHOW_TIMINGS=1 tools/ci/actions/runner.sh test"
121 - name: Run the testsuite (s=4096, debug runtime)
122 if: ${{ matrix.id == 'debug-s4096' && needs.config.outputs.skip-testsuite != 'true' }}
123 env:
124 OCAMLRUNPARAM: s=4096,v=0
125 USE_RUNTIME: d
126 run: |
127 for dir in $PARALLEL_TESTS; do \
128 bash -cxe "SHOW_TIMINGS=1 tools/ci/actions/runner.sh test_prefix $dir"; \
129 done
130 - name: Build API Documentation
131 if: matrix.id == 'normal'
132 run: |
133 MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh api-docs
134 - name: Install
135 if: matrix.id == 'normal'
136 run: |
137 MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh install
138 - name: Build the manual
139 if: matrix.id == 'normal' && needs.build.outputs.manual_changed == 'true'
140 run: |
141 MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh manual
142 - name: Other checks
143 if: matrix.id == 'normal'
144 run: |
145 MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh other-checks
146
147 # macOS build+testsuite run, and other Linux configurations (-O0, etc.)
148 config:
149 runs-on: ubuntu-latest
150 outputs:
151 jobs: ${{ steps.jobs.outputs.result }}
152 skip-testsuite: ${{ steps.skip.outputs.result }}
153 steps:
154 - name: Compute matrix for the "others" job
155 id: jobs
156 uses: actions/github-script@v7
157 with:
158 script: |
159 // # Default jobs: Linux -O0, Linux arm64 & macOS
160 let jobs = [
161 {name: 'linux-O0', os: 'ubuntu-latest',
162 config_arg: "CFLAGS='-O0'"},
163 {name: 'linux-arm64', os: 'ubuntu-24.04-arm'},
164 {name: 'macos-x86_64', os: 'macos-15-intel'},
165 {name: 'macos-arm64', os: 'macos-latest'}];
166 // # If this is a pull request, see if the PR has the
167 // # 'CI: Full matrix' label. This is done using an API request,
168 // # rather than from context.payload.pull_request.labels, since we
169 // # want the _current_ list of labels. This allows the labelling to
170 // # be changed, and then forcing a re-run of the workflow, rather
171 // # than having labelling triggering a fresh workflow event (which
172 // # is wasteful).
173 if (context.payload.pull_request) {
174 const { data: labels } =
175 await github.rest.issues.listLabelsOnIssue({...context.repo, issue_number: context.payload.pull_request.number});
176 if (labels.some(label => label.name === 'CI: Full matrix')) {
177 console.log('Full matrix requested');
178 // # Add "static" and "minimal" jobs
179 jobs = jobs.concat([
180 {name: 'static', os: 'ubuntu-latest',
181 config_arg: '--disable-shared'},
182 {name: 'minimal', os: 'ubuntu-latest',
183 config_arg: '--disable-native-compiler --disable-shared --disable-debug-runtime --disable-instrumented-runtime --disable-systhreads --disable-str-lib --disable-unix-lib --disable-ocamldoc'}]);
184 }
185 }
186 return jobs;
187 - name: Determine if the testsuite should be skipped
188 id: skip
189 uses: actions/github-script@v7
190 with:
191 script: |
192 let skip_testsuite = false;
193 if (context.payload.pull_request) {
194 const { data: labels } =
195 await github.rest.issues.listLabelsOnIssue({...context.repo, issue_number: context.payload.pull_request.number});
196 skip_testsuite = labels.some(label => label.name === 'CI: Skip testsuite');
197 }
198 console.log('Skip testsuite: ' + skip_testsuite);
199 return skip_testsuite;
200
201 others:
202 name: ${{ matrix.name }}
203 needs: config
204 runs-on: ${{ matrix.os }}
205 strategy:
206 matrix:
207 include: ${{ fromJSON(needs.config.outputs.jobs) }}
208 fail-fast: true
209 steps:
210 - name: Checkout
211 uses: actions/checkout@v5
212 with:
213 persist-credentials: false
214 - name: macOS Dependencies
215 if: startsWith(matrix.os, 'macos-')
216 run: |
217 brew install parallel
218 # Allows starting up lldb from a remote terminal
219 # Note: in order to start lldb, the user must also be in
220 # one of these groups: "admin" or "_developer".
221 sudo DevToolsSecurity --enable
222 spctl developer-mode enable-terminal
223 # Select latest supported version
224 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
225 lldb --version
226 - name: configure tree
227 run: |
228 CONFIG_ARG='--enable-codegen-invariants ${{ matrix.config_arg }}' MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh configure
229 - name: Build
230 run: |
231 MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh build
232 - name: Run the testsuite
233 if: ${{ matrix.name != 'linux-O0' && needs.config.outputs.skip-testsuite != 'true' }}
234 run: |
235 bash -c 'SHOW_TIMINGS=1 tools/ci/actions/runner.sh test'
236 - name: Run the testsuite (linux-O0)
237 if: ${{ matrix.name == 'linux-O0' && needs.config.outputs.skip-testsuite != 'true' }}
238 env:
239 OCAMLRUNPARAM: v=0,V=1
240 USE_RUNTIME: d
241 run: |
242 for dir in $PARALLEL_TESTS; do \
243 bash -cxe "SHOW_TIMINGS=1 tools/ci/actions/runner.sh test_prefix $dir"; \
244 done
245
246 i386:
247 runs-on: ubuntu-latest
248 needs: config
249 container:
250 image: debian:13
251 options: --platform linux/i386 --user root
252 steps:
253 - name: OS Dependencies
254 run: |
255 apt-get update -y
256 apt-get install -y git gcc make parallel
257 adduser --disabled-password --gecos '' ocaml
258 - name: Checkout
259 # See https://github.com/actions/checkout/issues/334
260 uses: actions/checkout@v1
261 - name: configure tree
262 run: |
263 chown -R ocaml:ocaml .
264 MAKE_ARG=-j su ocaml -c "bash -xe tools/ci/actions/runner.sh configure"
265 - name: Build
266 run: |
267 MAKE_ARG=-j su ocaml -c "bash -xe tools/ci/actions/runner.sh build"
268 - name: Run the testsuite
269 if: ${{ needs.config.outputs.skip-testsuite != 'true' }}
270 run: |
271 su ocaml -c "bash -xe tools/ci/actions/runner.sh test"