Debian Codegraph @

.github/workflows/python.yml

raw symbols SCIP
1 name: Python
2
3 on:
4 push:
5 branches: [master]
6 pull_request:
7 branches: [master]
8
9 concurrency:
10 group: ${{ github.workflow }}-${{ github.ref }}
11 cancel-in-progress: true
12
13 jobs:
14 unit-test:
15 permissions:
16 contents: read
17 runs-on: ubuntu-latest
18 strategy:
19 matrix:
20 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
21
22 steps:
23 - uses: actions/checkout@v5
24 with:
25 fetch-depth: 0
26 - name: Compute version
27 id: version
28 shell: bash
29 run: |
30 VERSION=$(bash scripts/compute-version.sh)
31 echo "VERSION=$VERSION" >> "$GITHUB_ENV"
32 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
33 echo "Computed version: $VERSION"
34 - name: Set up Python ${{ matrix.python-version }}
35 uses: actions/setup-python@v6
36 with:
37 python-version: ${{ matrix.python-version }}
38 - name: Install dependencies
39 run: |
40 python -m pip install --upgrade pip
41 pip install flake8 pytest wheel setuptools
42 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
43 - name: Lint with flake8
44 run: |
45 # stop the build if there are Python syntax errors or undefined names
46 flake8 . --exclude deps --count --select=E9,F63,F7,F82 --show-source --statistics
47 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
48 flake8 . --exclude deps --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
49 - name: Build and install
50 run: python -m pip install .
51 - name: Test with pytest
52 run: python python/tests/run_pytest_with_artifacts.py python --artifact-dir python-test-artifacts/unit-test --artifact-prefix pytest
53 - name: upload artifacts
54 if: ${{ always() }}
55 uses: actions/upload-artifact@v7
56 with:
57 name: opencc-${{ env.VERSION }}-python-${{ matrix.python-version }}
58 path: |
59 python-test-artifacts/unit-test/**
60
61 test-pypi:
62 permissions:
63 contents: read
64 strategy:
65 fail-fast: false
66 matrix:
67 os: [ubuntu-latest, macos-latest, macos-14, windows-2022]
68 python-build: ["cp312"]
69 runs-on: ${{ matrix.os }}
70
71 steps:
72 - uses: actions/checkout@v5
73 with:
74 fetch-depth: 0
75 - name: Compute version
76 id: version
77 shell: bash
78 run: |
79 VERSION=$(bash scripts/compute-version.sh)
80 echo "VERSION=$VERSION" >> "$GITHUB_ENV"
81 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
82 echo "Computed version: $VERSION"
83
84 - name: Set up Python
85 uses: actions/setup-python@v6
86 with:
87 python-version: "3.12"
88
89 - name: Build and test wheel
90 uses: pypa/[email protected]
91 env:
92 CIBW_BUILD: ${{ matrix.python-build }}-*
93 CIBW_SKIP: "*-musllinux_*"
94 CIBW_ARCHS_WINDOWS: "AMD64"
95 CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
96 CIBW_TEST_REQUIRES: "pytest"
97 CIBW_TEST_COMMAND: "python {project}/python/tests/run_pytest_with_artifacts.py {project}/python/tests --artifact-dir {project}/python-test-artifacts/cibuildwheel --artifact-prefix pytest"
98
99 - name: upload artifacts
100 if: ${{ always() }}
101 uses: actions/upload-artifact@v7
102 with:
103 name: opencc-${{ env.VERSION }}-pypi-${{ matrix.os }}-${{ matrix.python-build }}
104 path: |
105 wheelhouse/*.whl
106 python-test-artifacts/cibuildwheel/**