• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2# This is the CI workflow (not the artifact build/release workflow). The workflows
3# are split because GHA doesn't support a dynamic/conditional matrix. This workflow
4# has slow jobs and jobs that require private GHA runners (eg, M1 Mac) commented out.defaults:
5# Ensure changes are synced with manual_artifact_build.yaml.
6name: PyYAML CI
7
8on:
9  push:
10  pull_request:
11    types: [opened, synchronize, edited, reopened]
12  workflow_dispatch:
13
14env:
15  LIBYAML_REPO: https://github.com/yaml/libyaml
16  LIBYAML_REF: 0.2.5
17
18jobs:
19  python_sdist:
20    name: pyyaml sdist
21    runs-on: ubuntu-latest
22    steps:
23    - name: Checkout PyYAML
24      uses: actions/checkout@v2
25
26    - name: Install a python
27      uses: actions/setup-python@v2
28      with:
29        python-version: 3.x
30
31    - name: Build sdist
32      env:
33        PYYAML_FORCE_CYTHON: 1
34        PYYAML_FORCE_LIBYAML: 0
35      run: |
36        python -V
37        python -m pip install build
38
39        python -m build .
40
41        # Ensure exactly one artifact was produced.
42        [[ $(shopt -s nullglob; ls dist/*.tar.gz | wc -w) == 1 ]] || {
43          echo "Unexpected content in dist dir: '$(ls dist/*.tar.gz)'."
44          exit 1
45        }
46
47    - name: Test sdist
48      run: |
49        # Install some libyaml headers.
50        # TODO Should we smoke test the sdist against the libyaml we built?
51        sudo apt update
52        sudo apt install libyaml-dev -y
53
54        # Ensure Cython is not present so we use only what's in the sdist.
55        python -m pip uninstall Cython -y || true
56
57        # Pass no extra args.
58        # We should auto-install with libyaml since it's present.
59        python -m pip install dist/*.tar.gz -v
60
61        python packaging/build/smoketest.py
62
63    - name: Upload sdist artifact
64      uses: actions/upload-artifact@v2
65      with:
66        name: dist
67        path: dist/*.tar.gz
68
69
70  linux_libyaml:
71    name: libyaml ${{matrix.cfg.arch}} ${{matrix.cfg.platform}}
72    runs-on: ubuntu-latest
73    strategy:
74      matrix:
75        cfg:
76        - { platform: manylinux1, arch: x86_64 }
77        - { platform: manylinux2014, arch: x86_64 }
78#        - { platform: manylinux2014, arch: aarch64 }
79#        - { platform: manylinux2014, arch: s390x }
80    env:
81      DOCKER_IMAGE: quay.io/pypa/${{matrix.cfg.platform}}_${{matrix.cfg.arch}}
82    steps:
83    - name: Check cached libyaml state
84      id: cached_libyaml
85      uses: actions/cache@v2
86      with:
87        path: libyaml
88        key: libyaml_${{matrix.cfg.platform}}_${{matrix.cfg.arch}}_${{env.LIBYAML_REF}}
89
90    - name: configure docker foreign arch support
91      uses: docker/setup-qemu-action@v1
92      if: matrix.cfg.arch != 'x86_64' && steps.cached_libyaml.outputs.cache-hit != 'true'
93
94    - name: Checkout pyyaml
95      uses: actions/checkout@v2
96      if: steps.cached_libyaml.outputs.cache-hit != 'true'
97
98    - name: Build libyaml
99      run: >
100        docker run --rm
101        --volume "$(pwd):/io"
102        --env LIBYAML_REF
103        --env LIBYAML_REPO
104        --workdir /io
105        "$DOCKER_IMAGE"
106        /io/packaging/build/libyaml.sh
107      if: steps.cached_libyaml.outputs.cache-hit != 'true'
108
109    - name: ensure output is world readable (or cache fill fails with Permission Denied)
110      run: >
111        sudo chmod -R a+r ./libyaml/
112      if: steps.cached_libyaml.outputs.cache-hit != 'true'
113
114
115  linux_pyyaml:
116    needs: linux_libyaml
117    name: pyyaml ${{matrix.arch}} ${{matrix.platform}} ${{matrix.spec}}
118    runs-on: ubuntu-latest
119    strategy:
120      matrix:
121        include:
122        - { platform: manylinux1, arch: x86_64, spec: cp36 }
123#        - { platform: manylinux1, arch: x86_64, spec: cp37 }
124#        - { platform: manylinux1, arch: x86_64, spec: cp38 }
125#        - { platform: manylinux1, arch: x86_64, spec: cp39 }
126#        - { platform: manylinux2014, arch: x86_64, spec: cp310 }
127        - { platform: manylinux2014, arch: x86_64, spec: cp311 }
128#        - { platform: manylinux2014, arch: aarch64, spec: cp36 }
129#        - { platform: manylinux2014, arch: aarch64, spec: cp37 }
130#        - { platform: manylinux2014, arch: aarch64, spec: cp38 }
131#        - { platform: manylinux2014, arch: aarch64, spec: cp39 }
132#        - { platform: manylinux2014, arch: aarch64, spec: cp310 }
133#        - { platform: manylinux2014, arch: aarch64, spec: cp311 }
134#        - { platform: manylinux2014, arch: s390x, spec: cp36 }
135#        - { platform: manylinux2014, arch: s390x, spec: cp37 }
136#        - { platform: manylinux2014, arch: s390x, spec: cp38 }
137#        - { platform: manylinux2014, arch: s390x, spec: cp39 }
138#        - { platform: manylinux2014, arch: s390x, spec: cp310 }
139#        - { platform: manylinux2014, arch: s390x, spec: cp311 }
140
141    steps:
142    - name: Checkout PyYAML
143      uses: actions/checkout@v2
144
145    - name: Fetch cached libyaml
146      id: cached_libyaml
147      uses: actions/cache@v2
148      with:
149        path: libyaml
150        key: libyaml_${{matrix.platform}}_${{matrix.arch}}_${{env.LIBYAML_REF}}
151
152    - name: Ensure libyaml fetched
153      run: exit 1
154      if: steps.cached_libyaml.outputs.cache-hit != 'true'
155
156    - name: configure docker foreign arch support
157      uses: docker/setup-qemu-action@v1
158      if: matrix.arch != 'x86_64'
159
160    - name: Build/Test/Package
161      env:
162        CIBW_ARCHS: all
163        CIBW_BUILD: ${{matrix.spec}}-manylinux_${{matrix.arch}}
164        CIBW_BUILD_VERBOSITY: 1
165        # containerized Linux builds require explicit CIBW_ENVIRONMENT
166        CIBW_ENVIRONMENT: >
167          C_INCLUDE_PATH=libyaml/include
168          LIBRARY_PATH=libyaml/src/.libs
169          LD_LIBRARY_PATH=libyaml/src/.libs
170          PYYAML_FORCE_CYTHON=1
171          PYYAML_FORCE_LIBYAML=1
172        CIBW_TEST_COMMAND: cd {project}; python tests/lib/test_all.py
173      run: |
174        set -eux
175        python3 -V
176        python3 -m pip install -U --user cibuildwheel
177        python3 -m cibuildwheel --platform auto --output-dir dist .
178
179    - name: Upload artifacts
180      uses: actions/upload-artifact@v2
181      with:
182        name: dist
183        path: dist/*.whl
184        if-no-files-found: error
185
186  macos_libyaml:
187    name: libyaml macos ${{matrix.arch}}
188    strategy:
189      matrix:
190        include:
191        - arch: x86_64
192#        - arch: arm64
193#          runs_on: [self-hosted, macOS, arm64]
194#          deployment_target: '11.0'
195#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
196#          sdkroot: macosx11.3
197    defaults:
198      run:
199        shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
200    runs-on: ${{ matrix.runs_on || 'macos-11' }}
201    steps:
202    - name: Check cached libyaml state
203      id: cached_libyaml
204      uses: actions/cache@v2
205      with:
206        path: libyaml
207        key: libyaml_macos_${{matrix.arch}}_${{env.LIBYAML_REF}}
208
209    - name: Checkout PyYAML
210      uses: actions/checkout@v2
211      if: steps.cached_libyaml.outputs.cache-hit != 'true'
212
213    - name: Build libyaml
214      env:
215        MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '10.9' }}
216        SDKROOT: ${{ matrix.sdkroot || 'macosx' }}
217      run: |
218        set -eux
219        brew install automake coreutils m4
220        bash ./packaging/build/libyaml.sh
221        echo "finished artifact arch is $(lipo -archs libyaml/src/.libs/libyaml.a)"
222      if: steps.cached_libyaml.outputs.cache-hit != 'true'
223
224
225  macos_pyyaml:
226    needs: macos_libyaml
227    name: pyyaml ${{ matrix.spec }}
228    runs-on: ${{ matrix.runs_on || 'macos-11' }}
229    defaults:
230      run:
231        shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
232    strategy:
233      matrix:
234        include:
235        - spec: cp36-macosx_x86_64
236          cibw_version: cibuildwheel==2.11.1
237#        - spec: cp37-macosx_x86_64
238#        - spec: cp38-macosx_x86_64
239#        - spec: cp39-macosx_x86_64
240#        - spec: cp310-macosx_x86_64
241        - spec: cp311-macosx_x86_64
242
243#        # build for arm64 under a hacked macOS 12 self-hosted x86_64-on-arm64 runner until arm64 is fully supported
244#        # FIXME: ? cp38-macosx_arm64 requires special handling and fails some test_zdist tests under cibw 2.1.2, skip it (so Apple's XCode python3 won't have a wheel)
245#        - spec: cp39-macosx_arm64
246#          deployment_target: '11.0'
247#          runs_on: [self-hosted, macOS, arm64]
248#          arch: arm64
249#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
250#          sdkroot: macosx11.3
251#
252#        - spec: cp310-macosx_arm64
253#          deployment_target: '11.0'
254#          runs_on: [self-hosted, macOS, arm64]
255#          arch: arm64
256#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
257#          sdkroot: macosx11.3
258#
259#        - spec: cp311-macosx_arm64
260#          deployment_target: '11.0'
261#          runs_on: [self-hosted, macOS, arm64]
262#          arch: arm64
263#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
264#          sdkroot: macosx11.3
265
266    steps:
267    - name: Checkout PyYAML
268      uses: actions/checkout@v2
269
270    - name: Get cached libyaml state
271      id: cached_libyaml
272      uses: actions/cache@v2
273      with:
274        path: libyaml
275        key: libyaml_macos_${{ matrix.arch || 'x86_64' }}_${{env.LIBYAML_REF}}
276
277    - name: Ensure libyaml fetched
278      run: exit 1
279      if: steps.cached_libyaml.outputs.cache-hit != 'true'
280
281    - name: Build/Test/Package
282      env:
283        C_INCLUDE_PATH: libyaml/include
284        CIBW_BUILD: ${{matrix.spec}}
285        CIBW_BUILD_VERBOSITY: 1
286        CIBW_TEST_COMMAND: cd {project}; python tests/lib/test_all.py
287        LIBRARY_PATH: libyaml/src/.libs
288        MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '10.9' }}
289        SDKROOT: ${{ matrix.sdkroot || 'macosx' }}
290      run: |
291        python3 -V
292        python3 -m pip install -U --user ${{ matrix.cibw_version || 'cibuildwheel' }}
293        python3 -m cibuildwheel --platform auto --output-dir dist .
294
295    - name: Upload artifacts
296      uses: actions/upload-artifact@v2
297      with:
298        name: dist
299        path: dist/*.whl
300        if-no-files-found: error
301
302  windows_libyaml:
303    name: libyaml ${{matrix.platform}} ${{matrix.arch}}
304    runs-on: ${{matrix.platform}}
305    strategy:
306      matrix:
307        include:
308        - platform: windows-2019
309          arch: x64
310        - platform: windows-2019
311          arch: win32
312    steps:
313    - name: Get cached libyaml state
314      id: cached_libyaml
315      uses: actions/cache@v2
316      with:
317        path: libyaml
318        key: libyaml_${{matrix.platform}}_${{matrix.arch}}_${{env.LIBYAML_REF}}
319
320    - name: Build libyaml
321      shell: bash
322      if: steps.cached_libyaml.outputs.cache-hit != 'true'
323      run: |
324        # git spews all over stderr unless we tell it not to
325        export GIT_REDIRECT_STDERR="2>&1"
326
327        if [[ ! -d ./libyaml ]]; then
328          git clone -b ${{ env.LIBYAML_REF }} ${{ env.LIBYAML_REPO }} 2>&1
329        fi
330
331        pushd libyaml
332        git clean -fdx
333        popd
334
335        mkdir libyaml/build
336
337        pushd libyaml/build
338        cmake.exe -G "Visual Studio 16 2019" -A ${{ matrix.arch }} -DYAML_STATIC_LIB_NAME=yaml ..
339        cmake.exe --build . --config Release
340        popd
341
342
343  windows_pyyaml:
344    needs: windows_libyaml
345    name: pyyaml ${{ matrix.platform }} ${{matrix.python_arch}} ${{matrix.spec}}
346    runs-on: ${{matrix.platform}}
347    strategy:
348      matrix:
349        include:
350        - platform: windows-2019
351          build_arch: x64
352          python_arch: x64
353          spec: 3.6
354#        - platform: windows-2019
355#          build_arch: x64
356#          python_arch: x64
357#          spec: 3.7
358#        - platform: windows-2019
359#          build_arch: x64
360#          python_arch: x64
361#          spec: 3.8
362#        - platform: windows-2019
363#          build_arch: x64
364#          python_arch: x64
365#          spec: 3.9
366#        - platform: windows-2019
367#          build_arch: x64
368#          python_arch: x64
369#          spec: '3.10'
370        - platform: windows-2019
371          build_arch: x64
372          python_arch: x64
373          spec: '3.11'
374        - platform: windows-2019
375          build_arch: win32
376          python_arch: x86
377          spec: 3.6
378#        - platform: windows-2019
379#          build_arch: win32
380#          python_arch: x86
381#          spec: 3.7
382#        - platform: windows-2019
383#          build_arch: win32
384#          python_arch: x86
385#          spec: 3.8
386#        - platform: windows-2019
387#          build_arch: win32
388#          python_arch: x86
389#          spec: 3.9
390#        - platform: windows-2019
391#          build_arch: win32
392#          python_arch: x86
393#          spec: '3.10'
394        - platform: windows-2019
395          build_arch: win32
396          python_arch: x86
397          spec: '3.11'
398    steps:
399    # autocrlf screws up tests under Windows
400    - name: Set git to use LF
401      run: |
402        git config --global core.autocrlf false
403        git config --global core.eol lf
404
405    - name: Checkout pyyaml
406      uses: actions/checkout@v2
407
408    - name: Get cached libyaml state
409      id: cached_libyaml
410      uses: actions/cache@v2
411      with:
412        path: libyaml
413        key: libyaml_${{matrix.platform}}_${{matrix.build_arch}}_${{env.LIBYAML_REF}}
414
415    - name: Ensure libyaml fetched
416      run: exit 1
417      if: steps.cached_libyaml.outputs.cache-hit != 'true'
418
419    - name: Install python ${{ matrix.spec }}
420      uses: actions/setup-python@v2
421      with:
422        architecture: ${{ matrix.python_arch }}
423        python-version: ${{ matrix.spec }}
424
425    - name: Build/Test/Package
426      env:
427        PYYAML_FORCE_CYTHON: 1
428        PYYAML_FORCE_LIBYAML: 1
429      shell: bash
430      run: |
431        set -eux
432        python -V
433        python -m pip install "Cython<3.0" wheel
434
435        python setup.py \
436        --with-libyaml build_ext \
437        -I libyaml/include \
438        -L libyaml/build/Release \
439        -D YAML_DECLARE_STATIC \
440        build bdist_wheel
441
442        # run tests on built wheel
443        python -m pip install dist/*.whl
444        python tests/lib/test_all.py
445
446    - name: Upload artifacts
447      uses: actions/upload-artifact@v2
448      with:
449        name: dist
450        path: dist/*.whl
451        if-no-files-found: error
452...
453