• 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: aarch64, spec: cp36 }
128#        - { platform: manylinux2014, arch: aarch64, spec: cp37 }
129#        - { platform: manylinux2014, arch: aarch64, spec: cp38 }
130#        - { platform: manylinux2014, arch: aarch64, spec: cp39 }
131#        - { platform: manylinux2014, arch: aarch64, spec: cp310 }
132#        - { platform: manylinux2014, arch: s390x, spec: cp36 }
133#        - { platform: manylinux2014, arch: s390x, spec: cp37 }
134#        - { platform: manylinux2014, arch: s390x, spec: cp38 }
135#        - { platform: manylinux2014, arch: s390x, spec: cp39 }
136#        - { platform: manylinux2014, arch: s390x, spec: cp310 }
137
138    steps:
139    - name: Checkout PyYAML
140      uses: actions/checkout@v2
141
142    - name: Fetch cached libyaml
143      id: cached_libyaml
144      uses: actions/cache@v2
145      with:
146        path: libyaml
147        key: libyaml_${{matrix.platform}}_${{matrix.arch}}_${{env.LIBYAML_REF}}
148
149    - name: Ensure libyaml fetched
150      run: exit 1
151      if: steps.cached_libyaml.outputs.cache-hit != 'true'
152
153    - name: configure docker foreign arch support
154      uses: docker/setup-qemu-action@v1
155      if: matrix.arch != 'x86_64'
156
157    - name: Build/Test/Package
158      env:
159        CIBW_ARCHS: all
160        CIBW_BUILD: ${{matrix.spec}}-manylinux_${{matrix.arch}}
161        CIBW_BUILD_VERBOSITY: 1
162        # containerized Linux builds require explicit CIBW_ENVIRONMENT
163        CIBW_ENVIRONMENT: >
164          C_INCLUDE_PATH=libyaml/include
165          LIBRARY_PATH=libyaml/src/.libs
166          LD_LIBRARY_PATH=libyaml/src/.libs
167          PYYAML_FORCE_CYTHON=1
168          PYYAML_FORCE_LIBYAML=1
169        CIBW_TEST_COMMAND: cd {project}; python tests/lib/test_all.py
170      run: |
171        set -eux
172        python3 -V
173        python3 -m pip install -U --user cibuildwheel
174        python3 -m cibuildwheel --platform auto --output-dir dist .
175
176    - name: Upload artifacts
177      uses: actions/upload-artifact@v2
178      with:
179        name: dist
180        path: dist/*.whl
181        if-no-files-found: error
182
183  macos_libyaml:
184    name: libyaml macos ${{matrix.arch}}
185    strategy:
186      matrix:
187        include:
188        - arch: x86_64
189#        - arch: arm64
190#          runs_on: [self-hosted, macOS, arm64]
191#          deployment_target: '11.0'
192#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
193#          sdkroot: macosx11.3
194    defaults:
195      run:
196        shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
197    runs-on: ${{ matrix.runs_on || 'macos-10.15' }}
198    steps:
199    - name: Check cached libyaml state
200      id: cached_libyaml
201      uses: actions/cache@v2
202      with:
203        path: libyaml
204        key: libyaml_macos_${{matrix.arch}}_${{env.LIBYAML_REF}}
205
206    - name: Checkout PyYAML
207      uses: actions/checkout@v2
208      if: steps.cached_libyaml.outputs.cache-hit != 'true'
209
210    - name: Build libyaml
211      env:
212        MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '10.9' }}
213        SDKROOT: ${{ matrix.sdkroot || 'macosx' }}
214      run: |
215        set -eux
216        brew install automake coreutils m4
217        bash ./packaging/build/libyaml.sh
218        echo "finished artifact arch is $(lipo -archs libyaml/src/.libs/libyaml.a)"
219      if: steps.cached_libyaml.outputs.cache-hit != 'true'
220
221
222  macos_pyyaml:
223    needs: macos_libyaml
224    name: pyyaml ${{ matrix.spec }}
225    runs-on: ${{ matrix.runs_on || 'macos-10.15' }}
226    defaults:
227      run:
228        shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
229    strategy:
230      matrix:
231        include:
232        - spec: cp36-macosx_x86_64
233#        - spec: cp37-macosx_x86_64
234#        - spec: cp38-macosx_x86_64
235#        - spec: cp39-macosx_x86_64
236        - spec: cp310-macosx_x86_64
237
238#        # build for arm64 under a hacked macOS 12 self-hosted x86_64-on-arm64 runner until arm64 is fully supported
239#        # 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)
240#        - spec: cp39-macosx_arm64
241#          deployment_target: '11.0'
242#          runs_on: [self-hosted, macOS, arm64]
243#          arch: arm64
244#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
245#          sdkroot: macosx11.3
246#
247#        - spec: cp310-macosx_arm64
248#          deployment_target: '11.0'
249#          runs_on: [self-hosted, macOS, arm64]
250#          arch: arm64
251#          run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
252#          sdkroot: macosx11.3
253
254    steps:
255    - name: Checkout PyYAML
256      uses: actions/checkout@v2
257
258    - name: Get cached libyaml state
259      id: cached_libyaml
260      uses: actions/cache@v2
261      with:
262        path: libyaml
263        key: libyaml_macos_${{ matrix.arch || 'x86_64' }}_${{env.LIBYAML_REF}}
264
265    - name: Ensure libyaml fetched
266      run: exit 1
267      if: steps.cached_libyaml.outputs.cache-hit != 'true'
268
269    - name: Build/Test/Package
270      env:
271        C_INCLUDE_PATH: libyaml/include
272        CIBW_BUILD: ${{matrix.spec}}
273        CIBW_BUILD_VERBOSITY: 1
274        CIBW_TEST_COMMAND: cd {project}; python tests/lib/test_all.py
275        LIBRARY_PATH: libyaml/src/.libs
276        MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '10.9' }}
277        SDKROOT: ${{ matrix.sdkroot || 'macosx' }}
278      run: |
279        python3 -V
280        python3 -m pip install -U --user cibuildwheel
281        python3 -m cibuildwheel --platform auto --output-dir dist .
282
283    - name: Upload artifacts
284      uses: actions/upload-artifact@v2
285      with:
286        name: dist
287        path: dist/*.whl
288        if-no-files-found: error
289
290  windows_libyaml:
291    name: libyaml ${{matrix.platform}} ${{matrix.arch}}
292    runs-on: ${{matrix.platform}}
293    strategy:
294      matrix:
295        include:
296        - platform: windows-2016
297          arch: x64
298        - platform: windows-2016
299          arch: win32
300    steps:
301    - name: Get cached libyaml state
302      id: cached_libyaml
303      uses: actions/cache@v2
304      with:
305        path: libyaml
306        key: libyaml_${{matrix.platform}}_${{matrix.arch}}_${{env.LIBYAML_REF}}
307
308    - name: Build libyaml
309      shell: bash
310      if: steps.cached_libyaml.outputs.cache-hit != 'true'
311      run: |
312        # git spews all over stderr unless we tell it not to
313        export GIT_REDIRECT_STDERR="2>&1"
314
315        if [[ ! -d ./libyaml ]]; then
316          git clone -b ${{ env.LIBYAML_REF }} ${{ env.LIBYAML_REPO }} 2>&1
317        fi
318
319        pushd libyaml
320        git clean -fdx
321        popd
322
323        mkdir libyaml/build
324
325        pushd libyaml/build
326        cmake.exe -G "Visual Studio 15 2017" -A ${{ matrix.arch }} -DYAML_STATIC_LIB_NAME=yaml ..
327        cmake.exe --build . --config Release
328        popd
329
330
331  windows_pyyaml:
332    needs: windows_libyaml
333    name: pyyaml ${{ matrix.platform }} ${{matrix.python_arch}} ${{matrix.spec}}
334    runs-on: ${{matrix.platform}}
335    strategy:
336      matrix:
337        include:
338        - platform: windows-2016
339          build_arch: x64
340          python_arch: x64
341          spec: 3.6
342#        - platform: windows-2016
343#          build_arch: x64
344#          python_arch: x64
345#          spec: 3.7
346#        - platform: windows-2016
347#          build_arch: x64
348#          python_arch: x64
349#          spec: 3.8
350#        - platform: windows-2016
351#          build_arch: x64
352#          python_arch: x64
353#          spec: 3.9
354        - platform: windows-2016
355          build_arch: x64
356          python_arch: x64
357          spec: '3.10'
358        - platform: windows-2016
359          build_arch: win32
360          python_arch: x86
361          spec: 3.6
362#        - platform: windows-2016
363#          build_arch: win32
364#          python_arch: x86
365#          spec: 3.7
366#        - platform: windows-2016
367#          build_arch: win32
368#          python_arch: x86
369#          spec: 3.8
370#        - platform: windows-2016
371#          build_arch: win32
372#          python_arch: x86
373#          spec: 3.9
374        - platform: windows-2016
375          build_arch: win32
376          python_arch: x86
377          spec: '3.10'
378    steps:
379    # autocrlf screws up tests under Windows
380    - name: Set git to use LF
381      run: |
382        git config --global core.autocrlf false
383        git config --global core.eol lf
384
385    - name: Checkout pyyaml
386      uses: actions/checkout@v2
387
388    - name: Get cached libyaml state
389      id: cached_libyaml
390      uses: actions/cache@v2
391      with:
392        path: libyaml
393        key: libyaml_${{matrix.platform}}_${{matrix.build_arch}}_${{env.LIBYAML_REF}}
394
395    - name: Ensure libyaml fetched
396      run: exit 1
397      if: steps.cached_libyaml.outputs.cache-hit != 'true'
398
399    - name: Install python ${{ matrix.spec }}
400      uses: actions/setup-python@v2
401      with:
402        architecture: ${{ matrix.python_arch }}
403        python-version: ${{ matrix.spec }}
404
405    - name: Build/Test/Package
406      env:
407        PYYAML_FORCE_CYTHON: 1
408        PYYAML_FORCE_LIBYAML: 1
409      shell: bash
410      run: |
411        set -eux
412        python -V
413        python -m pip install Cython wheel
414
415        python setup.py \
416        --with-libyaml build_ext \
417        -I libyaml/include \
418        -L libyaml/build/Release \
419        -D YAML_DECLARE_STATIC \
420        build bdist_wheel
421
422        # run tests on built wheel
423        python -m pip install dist/*.whl
424        python tests/lib/test_all.py
425
426    - name: Upload artifacts
427      uses: actions/upload-artifact@v2
428      with:
429        name: dist
430        path: dist/*.whl
431        if-no-files-found: error
432...
433