-
Notifications
You must be signed in to change notification settings - Fork 33
112 lines (102 loc) · 3.89 KB
/
Copy pathpythonapp.yml
File metadata and controls
112 lines (102 loc) · 3.89 KB
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
name: Python application
on: [push, workflow_dispatch]
jobs:
python_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-pinned.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=20 --max-line-length=160 --statistics
- name: Test with pytest
run: |
# find and run tests, capturing stdout and stderr for the log
pytest --capture=tee-sys
windows_executable:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install the Cairo runtime used by CairoSVG
id: msys2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: mingw-w64-x86_64-cairo
- name: Locate Cairo for the standalone build
shell: pwsh
env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
run: |
$cairoDll = Join-Path $env:MSYS2_LOCATION 'mingw64\bin\libcairo-2.dll'
if (-not (Test-Path $cairoDll)) {
throw "The MSYS2 Cairo DLL was not installed at $cairoDll"
}
"CEWE2PDF_CAIRO_DLL=$cairoDll" >> $env:GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-winexe.txt
- name: Build Windows standalone executable
run: python -m PyInstaller cewe2pdf.spec --noconfirm --clean
- name: Smoke-test Windows executable
run: |
& .\dist\cewe2pdf.exe --version
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& .\dist\cewe2pdf.exe --outFile tests\testEmptyPageOne\executable-smoke.pdf tests\testEmptyPageOne\test_emptyPageOne.mcf
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
if (-not (Test-Path tests\testEmptyPageOne\executable-smoke.pdf)) {
throw 'The standalone executable did not create executable-smoke.pdf'
}
tag_successful_canonical_master:
needs: [python_build, windows_executable]
if: ${{ always() && needs.python_build.result == 'success' && needs.windows_executable.result == 'success' && github.repository == 'bash0/cewe2pdf' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Tag successful canonical-master build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(python -c "from programversion import PROGRAM_VERSION; print(PROGRAM_VERSION)")
tag="cewe2pdf-v${version}-build-${GITHUB_RUN_NUMBER}"
if git rev-parse -q --verify "refs/tags/${tag}"; then
existing_commit=$(git rev-list -n 1 "${tag}")
if [ "${existing_commit}" != "${GITHUB_SHA}" ]; then
echo "Existing tag ${tag} identifies ${existing_commit}, not ${GITHUB_SHA}" >&2
exit 1
fi
echo "Tag ${tag} already identifies this build."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${tag}" -m "Successful cewe2pdf build ${tag}"
git push origin "${tag}"