|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
| 3 | + |
| 4 | +name: Python PR |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: {} |
| 8 | + pull_request: {} |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + # os: [ubuntu-latest, windows-latest, macOS-latest] |
| 18 | + os: [windows-latest] |
| 19 | + platform: [x86] |
| 20 | + python-version: ['3.8'] |
| 21 | + python-platform: [x86] |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + architecture: ${{ matrix.python-platform }} |
| 29 | + - name: Enable Developer Command Prompt |
| 30 | + |
| 31 | + with: |
| 32 | + arch: ${{ matrix.python-platform }} |
| 33 | + if: matrix.os == 'windows-latest' |
| 34 | + - name: Install dependencies |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + python -m pip install --upgrade wheel setuptools Cython |
| 39 | + pip install flake8 pytest |
| 40 | + pip install -r requirements.txt |
| 41 | + - name: Lint with flake8 |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + # stop the build if there are Python syntax errors or undefined names |
| 45 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude examples |
| 46 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 47 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude examples |
| 48 | +
|
| 49 | + - name: Run tests |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + python -m pip install pytest |
| 53 | + python -m pytest |
| 54 | +
|
| 55 | + - name: Build package |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + python setup.py sdist bdist_wheel |
| 59 | +
|
| 60 | + - name: Build wheel dependencies |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + python -m pip wheel . -w dist |
| 64 | +
|
| 65 | + - name: Run pyinstaller |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + python -m pip install pyinstaller |
| 69 | + pyinstaller --console --onefile ./sourcehold/__main__.py --name sourcehold |
| 70 | + |
| 71 | + - name: Archive packages |
| 72 | + uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: sourcehold-py${{ matrix.python-version }}-${{ matrix.python-platform }}-${{ matrix.os }}-${{ matrix.platform }} |
| 75 | + path: | |
| 76 | + dist/sourcehold* |
| 77 | +
|
| 78 | +
|
| 79 | + test_package: |
| 80 | + needs: build |
| 81 | + runs-on: ${{ matrix.os }} |
| 82 | + strategy: |
| 83 | + matrix: |
| 84 | + # os: [ubuntu-latest, windows-latest, macOS-latest] |
| 85 | + os: [windows-latest] |
| 86 | + platform: [x86, x64] |
| 87 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] |
| 88 | + python-platform: [x86, x64] |
| 89 | + steps: |
| 90 | + - name: Download package |
| 91 | + |
| 92 | + with: |
| 93 | + name: sourcehold-py${{ matrix.python-version }}-${{ matrix.python-platform }}-${{ matrix.os }}-${{ matrix.platform }} |
| 94 | + - name: Set up Python ${{ matrix.python-version }} |
| 95 | + uses: actions/setup-python@v5 |
| 96 | + with: |
| 97 | + python-version: ${{ matrix.python-version }} |
| 98 | + architecture: ${{ matrix.python-platform }} |
| 99 | + - name: Install wheel |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + python -m pip install --upgrade pip |
| 103 | + python -m pip install --upgrade wheel setuptools |
| 104 | + - name: Pip install module |
| 105 | + run: | |
| 106 | + python -m pip install $(ls *.whl) |
| 107 | + shell: bash |
| 108 | + - name: Pip test module |
| 109 | + run: | |
| 110 | + python -c "import sourcehold" |
| 111 | + shell: bash |
| 112 | + - name: Pip test cli |
| 113 | + run: | |
| 114 | + echo "hello world!" | python -m sourcehold compression --compress --input - --output - | python -m sourcehold compression --decompress --input - --output - |
| 115 | + shell: bash |
0 commit comments