aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 3b1f44e87b291418432ae915221f3cd9f2a1ff11 (plain)
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
name: CI

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - master
      - stable
      - v*

jobs:
  # This is the "main" test suite, which tests a large number of different
  # versions of default compilers and Python versions in GitHub Actions.
  standard:
    strategy:
      fail-fast: false
      matrix:
        runs-on: [ubuntu-latest, windows-latest, macos-latest]
        python:
        - 2.7
        - 3.5
        - 3.6
        - 3.9
        - 3.10-dev
        - pypy2
        - pypy3

        # Items in here will either be added to the build matrix (if not
        # present), or add new keys to an existing matrix element if all the
        # existing keys match.
        #
        # We support three optional keys: args (both build), args1 (first
        # build), and args2 (second build).
        include:
          # Just add a key
          - runs-on: ubuntu-latest
            python: 3.6
            args: >
              -DPYBIND11_FINDPYTHON=ON
          - runs-on: windows-latest
            python: 3.6
            args: >
              -DPYBIND11_FINDPYTHON=ON

        # These items will be removed from the build matrix, keys must match.
        exclude:
            # Currently 32bit only, and we build 64bit
          - runs-on: windows-latest
            python: pypy2
          - runs-on: windows-latest
            python: pypy3

          # TODO: PyPy2 7.3.3 segfaults, while 7.3.2 was fine.
          - runs-on: ubuntu-latest
            python: pypy2

    name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
    runs-on: ${{ matrix.runs-on }}

    steps:
    - uses: actions/checkout@v2

    - name: Setup Python ${{ matrix.python }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}

    - name: Setup Boost (Windows / Linux latest)
      shell: bash
      run: echo "BOOST_ROOT=$BOOST_ROOT_1_72_0" >> $GITHUB_ENV

    - name: Update CMake
      uses: jwlawson/actions-setup-cmake@v1.4
      with:
        cmake-version: 3.19.1

    - name: Cache wheels
      if: runner.os == 'macOS'
      uses: actions/cache@v2
      with:
        # This path is specific to macOS - we really only need it for PyPy NumPy wheels
        # See https://github.com/actions/cache/blob/master/examples.md#python---pip
        # for ways to do this more generally
        path: ~/Library/Caches/pip
        # Look to see if there is a cache hit for the corresponding requirements file
        key: ${{ runner.os }}-pip-${{ matrix.python }}-x64-${{ hashFiles('tests/requirements.txt') }}

    - name: Prepare env
      run: python -m pip install -r tests/requirements.txt --prefer-binary

    - name: Setup annotations on Linux
      if: runner.os == 'Linux'
      run: python -m pip install pytest-github-actions-annotate-failures

    # First build - C++11 mode and inplace
    - name: Configure C++11 ${{ matrix.args }}
      run: >
        cmake -S . -B .
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DDOWNLOAD_EIGEN=ON
        -DCMAKE_CXX_STANDARD=11
        ${{ matrix.args }}

    - name: Build C++11
      run: cmake --build . -j 2

    - name: Python tests C++11
      run: cmake --build . --target pytest -j 2

    - name: C++11 tests
      # TODO: Figure out how to load the DLL on Python 3.8+
      if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))"
      run: cmake --build .  --target cpptest -j 2

    - name: Interface test C++11
      run: cmake --build . --target test_cmake_build

    - name: Clean directory
      run: git clean -fdx

    # Second build - C++17 mode and in a build directory
    - name: Configure ${{ matrix.args2 }}
      run: >
        cmake -S . -B build2
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DDOWNLOAD_EIGEN=ON
        -DCMAKE_CXX_STANDARD=17
        ${{ matrix.args }}
        ${{ matrix.args2 }}

    - name: Build
      run: cmake --build build2 -j 2

    - name: Python tests
      run: cmake --build build2 --target pytest

    - name: C++ tests
      # TODO: Figure out how to load the DLL on Python 3.8+
      if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))"
      run: cmake --build build2 --target cpptest

    - name: Interface test
      run: cmake --build build2 --target test_cmake_build

    # Eventually Microsoft might have an action for setting up
    # MSVC, but for now, this action works:
    - name: Prepare compiler environment for Windows 🐍 2.7
      if: matrix.python == 2.7 && runner.os == 'Windows'
      uses: ilammy/msvc-dev-cmd@v1
      with:
        arch: x64

    # This makes two environment variables available in the following step(s)
    - name: Set Windows 🐍 2.7 environment variables
      if: matrix.python == 2.7 && runner.os == 'Windows'
      shell: bash
      run: |
        echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV
        echo "MSSdk=1" >> $GITHUB_ENV

    # This makes sure the setup_helpers module can build packages using
    # setuptools
    - name: Setuptools helpers test
      run: pytest tests/extra_setuptools


  # Testing on clang using the excellent silkeh clang docker images
  clang:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        clang:
          - 3.6
          - 3.7
          - 3.9
          - 7
          - 9
          - dev
        std:
          - 11
        include:
          - clang: 5
            std: 14
          - clang: 10
            std: 20
          - clang: 10
            std: 17

    name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64"
    container: "silkeh/clang:${{ matrix.clang }}"

    steps:
    - uses: actions/checkout@v2

    - name: Add wget and python3
      run: apt-get update && apt-get install -y python3-dev python3-numpy python3-pytest libeigen3-dev

    - name: Configure
      shell: bash
      run: >
        cmake -S . -B build
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DCMAKE_CXX_STANDARD=${{ matrix.std }}
        -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

    - name: Build
      run: cmake --build build -j 2

    - name: Python tests
      run: cmake --build build --target pytest

    - name: C++ tests
      run: cmake --build build --target cpptest

    - name: Interface test
      run: cmake --build build --target test_cmake_build


  # Testing NVCC; forces sources to behave like .cu files
  cuda:
    runs-on: ubuntu-latest
    name: "🐍 3.8 • CUDA 11 • Ubuntu 20.04"
    container: nvidia/cuda:11.0-devel-ubuntu20.04

    steps:
    - uses: actions/checkout@v2

    # tzdata will try to ask for the timezone, so set the DEBIAN_FRONTEND
    - name: Install 🐍 3
      run: apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cmake git python3-dev python3-pytest python3-numpy

    - name: Configure
      run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON

    - name: Build
      run: cmake --build build -j2 --verbose

    - name: Python tests
      run: cmake --build build --target pytest


# TODO: Internal compiler error - report to NVidia
#  # Testing CentOS 8 + PGI compilers
#  centos-nvhpc8:
#    runs-on: ubuntu-latest
#    name: "🐍 3 • CentOS8 / PGI 20.11 • x64"
#    container: centos:8
#
#    steps:
#    - uses: actions/checkout@v2
#
#    - name: Add Python 3 and a few requirements
#      run: yum update -y && yum install -y git python3-devel python3-numpy python3-pytest make environment-modules
#
#    - name: Install CMake with pip
#      run: |
#        python3 -m pip install --upgrade pip
#        python3 -m pip install cmake --prefer-binary
#
#    - name: Install NVidia HPC SDK
#      run: >
#        yum -y install
#        https://developer.download.nvidia.com/hpc-sdk/20.11/nvhpc-20-11-20.11-1.x86_64.rpm
#        https://developer.download.nvidia.com/hpc-sdk/20.11/nvhpc-2020-20.11-1.x86_64.rpm
#
#    - name: Configure
#      shell: bash
#      run: |
#        source /etc/profile.d/modules.sh
#        module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/20.11
#        cmake -S . -B build -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=14 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
#
#    - name: Build
#      run: cmake --build build -j 2 --verbose
#
#    - name: Python tests
#      run: cmake --build build --target pytest
#
#    - name: C++ tests
#      run: cmake --build build --target cpptest
#
#    - name: Interface test
#      run: cmake --build build --target test_cmake_build


  # Testing on CentOS 7 + PGI compilers, which seems to require more workarounds
  centos-nvhpc7:
    runs-on: ubuntu-latest
    name: "🐍 3 • CentOS7 / PGI 20.9 • x64"
    container: centos:7

    steps:
    - uses: actions/checkout@v2

    - name: Add Python 3 and a few requirements
      run: yum update -y && yum install -y epel-release && yum install -y git python3-devel make environment-modules cmake3

    - name: Install NVidia HPC SDK
      run:  yum -y install https://developer.download.nvidia.com/hpc-sdk/20.9/nvhpc-20-9-20.9-1.x86_64.rpm https://developer.download.nvidia.com/hpc-sdk/20.9/nvhpc-2020-20.9-1.x86_64.rpm

    # On CentOS 7, we have to filter a few tests (compiler internal error)
    # and allow deeper templete recursion (not needed on CentOS 8 with a newer
    # standard library). On some systems, you many need further workarounds:
    # https://github.com/pybind/pybind11/pull/2475
    - name: Configure
      shell: bash
      run: |
        source /etc/profile.d/modules.sh
        module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/20.9
        cmake3 -S . -B build -DDOWNLOAD_CATCH=ON \
                            -DCMAKE_CXX_STANDARD=11 \
                            -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \
                            -DCMAKE_CXX_FLAGS="-Wc,--pending_instantiations=0" \
                            -DPYBIND11_TEST_FILTER="test_smart_ptr.cpp;test_virtual_functions.cpp"

    # Building before installing Pip should produce a warning but not an error
    - name: Build
      run: cmake3 --build build -j 2 --verbose

    - name: Install CMake with pip
      run: |
        python3 -m pip install --upgrade pip
        python3 -m pip install pytest

    - name: Python tests
      run: cmake3 --build build --target pytest

    - name: C++ tests
      run: cmake3 --build build --target cpptest

    - name: Interface test
      run: cmake3 --build build --target test_cmake_build

  # Testing on GCC using the GCC docker images (only recent images supported)
  gcc:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        gcc:
          - 7
          - latest
        std:
          - 11
        include:
          - gcc: 10
            std: 20

    name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }}• x64"
    container: "gcc:${{ matrix.gcc }}"

    steps:
    - uses: actions/checkout@v1

    - name: Add Python 3
      run: apt-get update; apt-get install -y python3-dev python3-numpy python3-pytest python3-pip libeigen3-dev

    - name: Update pip
      run: python3 -m pip install --upgrade pip

    - name: Setup CMake 3.18
      uses: jwlawson/actions-setup-cmake@v1.4
      with:
        cmake-version: 3.18

    - name: Configure
      shell: bash
      run: >
        cmake -S . -B build
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DCMAKE_CXX_STANDARD=${{ matrix.std }}
        -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

    - name: Build
      run: cmake --build build -j 2

    - name: Python tests
      run: cmake --build build --target pytest

    - name: C++ tests
      run: cmake --build build --target cpptest

    - name: Interface test
      run: cmake --build build --target test_cmake_build


  # Testing on CentOS (manylinux uses a centos base, and this is an easy way
  # to get GCC 4.8, which is the manylinux1 compiler).
  centos:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        centos:
          - 7  # GCC 4.8
          - 8

    name: "🐍 3 • CentOS ${{ matrix.centos }} • x64"
    container: "centos:${{ matrix.centos }}"

    steps:
    - uses: actions/checkout@v2

    - name: Add Python 3
      run: yum update -y && yum install -y python3-devel gcc-c++ make git

    - name: Update pip
      run: python3 -m pip install --upgrade pip

    - name: Install dependencies
      run: python3 -m pip install cmake -r tests/requirements.txt --prefer-binary

    - name: Configure
      shell: bash
      run: >
        cmake -S . -B build
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DDOWNLOAD_EIGEN=ON
        -DCMAKE_CXX_STANDARD=11
        -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

    - name: Build
      run: cmake --build build -j 2

    - name: Python tests
      run: cmake --build build --target pytest

    - name: C++ tests
      run: cmake --build build --target cpptest

    - name: Interface test
      run: cmake --build build --target test_cmake_build


  # This tests an "install" with the CMake tools
  install-classic:
    name: "🐍 3.5 • Debian • x86 •  Install"
    runs-on: ubuntu-latest
    container: i386/debian:stretch

    steps:
    - uses: actions/checkout@v1

    - name: Install requirements
      run: |
        apt-get update
        apt-get install -y git make cmake g++ libeigen3-dev python3-dev python3-pip
        pip3 install "pytest==3.1.*"

    - name: Configure for install
      run: >
        cmake .
        -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0
        -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

    - name: Make and install
      run: make install

    - name: Copy tests to new directory
      run: cp -a tests /pybind11-tests

    - name: Make a new test directory
      run: mkdir /build-tests

    - name: Configure tests
      run: >
        cmake ../pybind11-tests
        -DDOWNLOAD_CATCH=ON
        -DPYBIND11_WERROR=ON
        -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
      working-directory: /build-tests

    - name: Run tests
      run: make pytest -j 2
      working-directory: /build-tests


  # This verifies that the documentation is not horribly broken, and does a
  # basic sanity check on the SDist.
  doxygen:
    name: "Documentation build test"
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - uses: actions/setup-python@v2

    - name: Install Doxygen
      run: sudo apt-get install -y doxygen librsvg2-bin # Changed to rsvg-convert in 20.04

    - name: Install docs & setup requirements
      run: python3 -m pip install -r docs/requirements.txt

    - name: Build docs
      run: python3 -m sphinx -W -b html docs docs/.build

    - name: Make SDist
      run: python3 setup.py sdist

    - run: git status --ignored

    - name: Check local include dir
      run: >
        ls pybind11;
        python3 -c "import pybind11, pathlib; assert (a := pybind11.get_include()) == (b := str(pathlib.Path('include').resolve())), f'{a} != {b}'"

    - name: Compare Dists (headers only)
      working-directory: include
      run: |
        python3 -m pip install --user -U ../dist/*
        installed=$(python3 -c "import pybind11; print(pybind11.get_include() + '/pybind11')")
        diff -rq $installed ./pybind11

  win32:
    strategy:
      fail-fast: false
      matrix:
        python:
        - 3.5
        - 3.6
        - 3.7
        - 3.8
        - 3.9
        - pypy3
        # TODO: fix hang on pypy2

        include:
          - python: 3.9
            args: -DCMAKE_CXX_STANDARD=20 -DDOWNLOAD_EIGEN=OFF
          - python: 3.8
            args: -DCMAKE_CXX_STANDARD=17

    name: "🐍 ${{ matrix.python }} • MSVC 2019 • x86 ${{ matrix.args }}"
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup Python ${{ matrix.python }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}
        architecture: x86

    - name: Update CMake
      uses: jwlawson/actions-setup-cmake@v1.4
      with:
        cmake-version: 3.19.1

    - name: Prepare MSVC
      uses: ilammy/msvc-dev-cmd@v1
      with:
        arch: x86

    - name: Prepare env
      run: python -m pip install -r tests/requirements.txt --prefer-binary

    # First build - C++11 mode and inplace
    - name: Configure ${{ matrix.args }}
      run: >
        cmake -S . -B build
        -G "Visual Studio 16 2019" -A Win32
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DDOWNLOAD_EIGEN=ON
        ${{ matrix.args }}
    - name: Build C++11
      run: cmake --build build -j 2

    - name: Run tests
      run: cmake --build build -t pytest

  win32-msvc2015:
    name: "🐍 ${{ matrix.python }} • MSVC 2015 • x64"
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        python:
          - 2.7
          - 3.6
          - 3.7
          # todo: check/cpptest does not support 3.8+ yet

    steps:
    - uses: actions/checkout@v2

    - name: Setup 🐍 ${{ matrix.python }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}

    - name: Update CMake
      uses: jwlawson/actions-setup-cmake@v1.4
      with:
        cmake-version: 3.19.1

    - name: Prepare MSVC
      uses: ilammy/msvc-dev-cmd@v1
      with:
        toolset: 14.0

    - name: Prepare env
      run: python -m pip install -r tests/requirements.txt --prefer-binary

    # First build - C++11 mode and inplace
    - name: Configure
      run: >
        cmake -S . -B build
        -G "Visual Studio 14 2015" -A x64
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DDOWNLOAD_EIGEN=ON

    - name: Build C++14
      run: cmake --build build -j 2

    - name: Run all checks
      run: cmake --build build -t check


  win32-msvc2017:
    name: "🐍 ${{ matrix.python }} • MSVC 2017 • x64"
    runs-on: windows-2016
    strategy:
      fail-fast: false
      matrix:
        python:
          - 2.7
          - 3.5
          - 3.7
        std:
          - 14

        include:
          - python: 2.7
            std: 17
            args: >
              -DCMAKE_CXX_FLAGS="/permissive- /EHsc /GR"

    steps:
    - uses: actions/checkout@v2

    - name: Setup 🐍 ${{ matrix.python }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}

    - name: Update CMake
      uses: jwlawson/actions-setup-cmake@v1.4
      with:
        cmake-version: 3.19.1

    - name: Prepare env
      run: python -m pip install -r tests/requirements.txt --prefer-binary

    # First build - C++11 mode and inplace
    - name: Configure
      run: >
        cmake -S . -B build
        -G "Visual Studio 15 2017" -A x64
        -DPYBIND11_WERROR=ON
        -DDOWNLOAD_CATCH=ON
        -DDOWNLOAD_EIGEN=ON
        -DCMAKE_CXX_STANDARD=${{ matrix.std }}
        ${{ matrix.args }}

    - name: Build ${{ matrix.std }}
      run: cmake --build build -j 2

    - name: Run all checks
      run: cmake --build build -t check