File: ci.yml

package info (click to toggle)
mlpack 4.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 31,272 kB
  • sloc: cpp: 226,039; python: 1,934; sh: 1,198; lisp: 414; makefile: 85
file content (364 lines) | stat: -rw-r--r-- 14,553 bytes parent folder | download
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# ci.yml: defines all the CI jobs run for each commit and pull request.  For
# Linux and macOS, we run a matrix job that tests all the bindings.  For
# Windows, we just run one build (see the later part of the file).

on:
  workflow_dispatch:
  push:
    branches:
      - master
      - main
  pull_request:
    branches:
      - master
      - main
  release:
    types: [published, created, edited]
permissions:
  contents: read
name: mlpack.mlpack

jobs:
  ###
  ### Linux and macOS test matrix for all binding types.
  ###
  ci_matrix:
    strategy:
      fail-fast: false # Run all configurations even if one fails.
      matrix:
        config: [
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'Debug',
            # Disable [DEBUG] output from the tests because it's WAY too verbose.
            cmakeVars: '-DCMAKE_BUILD_TYPE=Debug -DBUILD_CLI_EXECUTABLES=OFF -DCMAKE_CXX_FLAGS="-DMLPACK_NO_PRINT_DEBUG"'
          },
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'CLI',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=ON'
          },
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'Python',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=OFF -DBUILD_PYTHON_BINDINGS=ON'
          },
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'Julia',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=OFF -DBUILD_JULIA_BINDINGS=ON'
          },
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'R',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=OFF -DBUILD_R_BINDINGS=ON -DCEREAL_INCLUDE_DIR=../cereal-1.3.2/include/'
          },
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'Go',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=OFF -DBUILD_GO_BINDINGS=ON'
          },
          {
            runner: ubuntu-latest,
            os: 'Linux',
            name: 'Markdown',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=OFF -DBUILD_MARKDOWN_BINDINGS=ON'
          },
          {
            runner: macOS-latest,
            os: 'macOS',
            name: 'CLI',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=ON'
          },
          {
            runner: macOS-latest,
            os: 'macOS',
            name: 'Python',
            cmakeVars: '-DBUILD_CLI_EXECUTABLES=OFF -DBUILD_PYTHON_BINDINGS=ON'
          }
        ]

    name: '${{ matrix.config.os }} (${{ matrix.config.name }})'
    if: ${{ github.repository == 'mlpack/mlpack' }}
    runs-on: ${{ matrix.config.runner }}

    steps:
      - uses: actions/checkout@v3

      # Set up ccache.
      - name: Get ccache
        uses: hendrikmuhs/ccache-action@v1.2
        with:
          key: ${{ matrix.config.os }}-${{ matrix.config.name }}
          variant: ccache
          max-size: 1G

      # Set up the build environment for any bindings, if needed.
      - name: Set up binding dependencies
        uses: ./.github/actions/binding_setup
        with:
          lang: ${{ matrix.config.name }}

      # Install build dependencies.
      - name: Install build dependencies (Linux)
        if: matrix.config.os == 'Linux'
        run: |
          git clone --depth 1 https://github.com/mlpack/jenkins-conf.git conf
          sudo apt-get update
          sudo apt-get install --yes --allow-unauthenticated \
              libopenblas-dev libstb-dev libcereal-dev xz-utils
          # Install the oldest Armadillo version that we support.
          curl -k -L https://sourceforge.net/projects/arma/files/armadillo-10.8.2.tar.xz | tar -xvJ
          cd armadillo*
          # Armadillo 10.8.2 requests CMake 2.8.12+ compatibility, but that has
          # been dropped from newer CMake versions.  However, with Armadillo's
          # CMake configuration, it works just fine to specify
          # CMAKE_POLICY_VERSION_MINIMUM to ignore the missing reverse
          # compatibility.
          cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .
          make
          sudo make install
          cd ..
          # Install the latest ensmallen version.
          wget https://ensmallen.org/files/ensmallen-latest.tar.gz
          tar -xvzpf ensmallen-latest.tar.gz # Unpack into ensmallen-*/.
          cd ensmallen-*/
          sudo cp -vr include/* /usr/include/
          cd ..

      - name: Install build dependencies (macOS)
        if: matrix.config.os == 'macOS'
        run: |
          sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
          brew install libomp openblas armadillo cereal ensmallen ccache

      # Because mlpack's precompiled headers basically include everything
      # (mlpack.hpp, core.hpp, etc.), changes to a single file will invalidate
      # the ccache entry---so it is better to leave it turned off, so that
      # ccache entries will be at a more granular level and are more likely to
      # be reused across runs.
      - name: Configure mlpack with CMake
        run: |
          mkdir build && cd build
          cmake ${{ matrix.config.cmakeVars }} $CMAKE_BINDING_ARGS -DUSE_PRECOMPILED_HEADERS=OFF -DBUILD_TESTS=ON ../

      - name: Build mlpack
        run: cd build && make -j4

      # Run the tests manually so that we can get JUnit output.
      - name: Run mlpack_test
        run: |
          cd build
          # The use of only one thread is to prevent thrashing on older versions
          # of OpenBLAS (0.3.26 and older) where OpenMP and pthreads aren't
          # playing together well.
          OMP_NUM_THREADS=1 bin/mlpack_test -r junit -o mlpack_test.junit.xml

      # Run binding tests for each binding type.
      - name: Run binding tests
        uses: ./.github/actions/binding_run_tests
        with:
          lang: ${{ matrix.config.name }}

      - name: Parse test output
        uses: rcurtin/test-summary-action@dist
        if: success() || failure()
        with:
          paths: "build/*.junit.xml"
          show: "fail, skip"
          fail_job: true
          print_output: true

  ###
  ### Windows CI testing.
  ###

  ci_windows:
    name: 'Windows build: VS2022'
    if: ${{ github.repository == 'mlpack/mlpack' }}
    runs-on: windows-2022

    steps:
      - uses: actions/checkout@v3

      # Set up ccache.
      - name: Get ccache
        uses: hendrikmuhs/ccache-action@v1.2
        with:
          key: ${{ runner.os }}
          variant: ccache
          max-size: 5G

      # Set up Visual Studio.
      - name: Set up Visual Studio
        uses: microsoft/setup-msbuild@v2

      # Install build dependencies.
      - name: Install build dependencies (Windows)
        shell: powershell
        run: |
          nuget install OpenBLAS -o deps
          nuget install ensmallen -o deps -Version 2.17.0
          # Delete all ensmallen dependencies including armadillo headers, we do not need them here.
          Remove-Item deps\ensmallen.2.17.0\installed\x64-linux\share -Force -Recurse
          Remove-Item deps\ensmallen.2.17.0\installed\x64-linux\include\armadillo_bits -Force -Recurse
          Remove-Item deps\ensmallen.2.17.0\installed\x64-linux\include\armadillo -Force

      # Install the oldest supported version of Armadillo and install cereal.
      - name: Install some dependencies manually
        shell: bash
        run: |
          cd deps/
          curl -L https://sourceforge.net/projects/arma/files/armadillo-10.8.2.tar.xz -o armadillo-10.8.2.tar.xz
          tar -xf armadillo-10.8.2.tar.xz
          cd armadillo-10.8.2/
          cmake -G "Visual Studio 17 2022" \
            -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
            -DBLAS_LIBRARY:FILEPATH=${{ github.workspace }}/deps/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a \
            -DLAPACK_LIBRARY:FILEPATH=${{ github.workspace }}/deps/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a \
            -DBUILD_SHARED_LIBS=OFF .
          # Disable the wrapper because transitive linking doesn't work on
          # Windows anyway.
          cp tmp/include/armadillo_bits/config.hpp tmp/include/armadillo_bits/config.hpp.tmp
          cat tmp/include/armadillo_bits/config.hpp.tmp | sed 's|#define ARMA_USE_WRAPPER|// #define ARMA_USE_WRAPPER|' \
              > tmp/include/armadillo_bits/config.hpp
          # Now download and unpack cereal.
          cd ../
          curl -L https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.2.tar.gz -o cereal-1.3.2.tar.gz
          tar -xzf cereal-1.3.2.tar.gz
          # Download and unpack STB.
          curl -O https://www.mlpack.org/files/stb.tar.gz
          tar -xzf stb.tar.gz

      # Because mlpack's precompiled headers basically include everything
      # (mlpack.hpp, core.hpp, etc.), changes to a single file will invalidate
      # the ccache entry---so it is better to leave it turned off, so that
      # ccache entries will be at a more granular level and are more likely to
      # be reused across runs.
      - name: Configure mlpack with CMake
        shell: bash
        run: |
          mkdir build && cd build
          cmake -DUSE_PRECOMPILED_HEADERS=OFF -DBUILD_TESTS=ON \
              -DARMADILLO_INCLUDE_DIR=../deps/armadillo-10.8.2/tmp/include/ \
              -DBLAS_LIBRARIES='${{ github.workspace }}'/deps/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a \
              -DLAPACK_LIBRARIES='${{ github.workspace }}'/deps/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a \
              -DENSMALLEN_INCLUDE_DIR=../deps/ensmallen.2.17.0/installed/x64-linux/include/ \
              -DCEREAL_INCLUDE_DIR=../deps/cereal-1.3.2/include/ \
              -DSTB_IMAGE_INCLUDE_DIR='${{ github.workspace }}'/deps/stb/include/ \
              -DCMAKE_HAS_WORKING_STATIC_STB=1 \
              ../

      - name: Build mlpack
        run: cd build && cmake --build . --config Release

      # Run the tests manually so that we can get JUnit output.
      - name: Run mlpack_test
        shell: bash
        run: |
          # The .dlls are stored in the bin/ directory, and those are the ones
          # we need to run with.
          cp -v '${{ github.workspace }}'/deps/OpenBLAS.0.2.14.1/lib/native/bin/x64/* build/Release
          cd build/
          ./Release/mlpack_test.exe -r junit > mlpack_test.junit.xml
          # Remove version numbers and other non-xml from the output.
          cat mlpack_test.junit.xml | sed '/<?xml/,$!d' > mlpack_test.junit.xml.tmp
          rm mlpack_test.junit.xml
          mv mlpack_test.junit.xml.tmp mlpack_test.junit.xml

      - name: Parse test output
        uses: rcurtin/test-summary-action@dist
        if: success() || failure()
        with:
          paths: "build/*.junit.xml"
          show: "fail, skip"
          fail_job: true
          print_output: true

      - name: Archive compiled programs
        run: mkdir exe_archive && cp -r build/Release/*.exe exe_archive/

      - name: Publish Windows no-libs archive
        uses: actions/upload-artifact@v4.4.0
        with:
          name: mlpack-windows-vs17-no-libs
          path: exe_archive/

      - name: Publish Windows libs archive
        uses: actions/upload-artifact@v4.4.0
        with:
          name: mlpack-windows-vs17
          path: build/Release/

      - name: Install Ruby for HTML documentation build
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: head

      - name: Build HTML documentation
        shell: bash
        run: |
          gem install kramdown kramdown-parser-gfm
          DISABLE_HTML_CHECKS=1 ./scripts/build-docs.sh

      - name: Build MSI installer
        shell: powershell
        run: |
          # Preparing installer staging.
          mkdir dist\win-installer\mlpack-win-installer\Sources\lib
          cp build\Release\*.lib dist\win-installer\mlpack-win-installer\Sources\lib\
          cp build\Release\*.exp dist\win-installer\mlpack-win-installer\Sources\lib\
          cp build\Release\*.dll dist\win-installer\mlpack-win-installer\Sources\
          cp build\Release\*.exe dist\win-installer\mlpack-win-installer\Sources\
          cp ${{ github.workspace }}\deps\OpenBLAS.0.2.14.1\lib\native\bin\x64\*.dll dist\win-installer\mlpack-win-installer\Sources\
          #
          # Copy documentation.
          mkdir dist\win-installer\mlpack-win-installer\Sources\doc
          cp doc\html dist\win-installer\mlpack-win-installer\Sources\doc -recurse
          #
          # Copy sources.
          mkdir dist\win-installer\mlpack-win-installer\Sources\include\mlpack
          cp src\mlpack.hpp dist\win-installer\mlpack-win-installer\Sources\include
          cp src\mlpack\*.hpp dist\win-installer\mlpack-win-installer\Sources\include\mlpack
          cp src\mlpack\core dist\win-installer\mlpack-win-installer\Sources\include\mlpack -recurse
          cp src\mlpack\methods dist\win-installer\mlpack-win-installer\Sources\include\mlpack -recurse
          #
          # Copy examples.
          cp doc\examples dist\win-installer\mlpack-win-installer\Sources\ -recurse
          cp src\mlpack\tests\data\german.csv dist\win-installer\mlpack-win-installer\Sources\examples\sample-ml-app\sample-ml-app\data\
          #
          # Check current git version or mlpack version.
          $ver = (Get-Content "src\mlpack\core\util\version.hpp" | where {$_ -like "*MLPACK_VERSION*"});
          $env:MLPACK_VERSION += $ver[0].substring($ver[0].length - 1, 1) + '.';
          $env:MLPACK_VERSION += $ver[1].substring($ver[1].length - 1, 1) + '.';
          $env:MLPACK_VERSION += $ver[2].substring($ver[2].length - 1, 1);
          #
          if (Test-Path "src/mlpack/core/util/gitversion.hpp")
          {
            $ver = (Get-Content "src/mlpack/core/util/gitversion.hpp");
            $env:INSTALL_VERSION = $ver.Split('"')[1].Split(' ')[1];
          }
          else
          {
            $env:INSTALL_VERSION = $env:MLPACK_VERSION;
          }
          #
          # Build the MSI installer.
          cd dist\win-installer\mlpack-win-installer
          & 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe' `
              -t:rebuild `
              -p:Configuration=Release `
              -p:TreatWarningsAsErrors=True `
              mlpack-win-installer.wixproj

      - name: Publish MSI installer
        uses: actions/upload-artifact@v4.4.0
        with:
          name: mlpack-windows-installer
          path: dist/win-installer/mlpack-win-installer/bin/Release/mlpack-windows.msi