-
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (151 loc) · 4.86 KB
/
Copy pathpython-package.yml
File metadata and controls
179 lines (151 loc) · 4.86 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Python Package CI
on:
workflow_dispatch:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
permissions:
contents: write
jobs:
changes:
name: Detect libdoc changes
runs-on: ubuntu-latest
outputs:
library_changed: ${{ steps.detect.outputs.library_changed }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0
- name: Detect changes in AITester/library.py
id: detect
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
elif [ "${{ github.event_name }}" = "push" ]; then
base="${{ github.event.before }}"
head="${{ github.sha }}"
else
head="${{ github.sha }}"
if git rev-parse "${head}^" >/dev/null 2>&1; then
base="$(git rev-parse "${head}^")"
else
base="$(git hash-object -t tree /dev/null)"
fi
fi
if [ "$base" = "0000000000000000000000000000000000000000" ]; then
base="$(git hash-object -t tree /dev/null)"
fi
if git diff --name-only "$base" "$head" | grep -qx 'AITester/library.py'; then
echo "library_changed=true" >> "$GITHUB_OUTPUT"
else
echo "library_changed=false" >> "$GITHUB_OUTPUT"
fi
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Run flake8
run: flake8 AITester/ --count --show-source --statistics
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run unit tests
run: |
python -m pytest unittests/ -v --tb=short --junitxml=test-results.xml
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-python-${{ matrix.python-version }}
path: test-results.xml
build:
name: Build package
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
pip install -e ".[dev]"
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
libdoc:
name: Generate libdoc
runs-on: ubuntu-latest
needs: [build, changes]
if: needs.changes.outputs.library_changed == 'true'
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install libdoc dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Generate Robot Framework libdoc
run: |
mkdir -p docs
python -m robot.libdoc AITester docs/index.html
- name: Commit updated libdoc
if: github.event_name != 'pull_request'
run: |
if git diff --quiet -- docs/index.html; then
echo "docs/index.html is already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add docs/index.html
git commit -m "Update generated libdoc [skip ci]"
git push origin HEAD:${{ github.ref_name }}
- name: Verify libdoc in pull requests
if: github.event_name == 'pull_request'
run: git diff --exit-code -- docs/index.html