-
Notifications
You must be signed in to change notification settings - Fork 36
181 lines (146 loc) · 5.47 KB
/
python-app.yml
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
180
181
name: BamBam
on:
push:
pull_request:
workflow_dispatch:
inputs:
golden:
default: false
description: "Update and/or check golden files."
type: boolean
permissions:
contents: read
jobs:
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Lint with flake8
run: |
flake8 . --show-source --statistics
- name: Lint with autopep8
run: |
autopep8 -d *.py | awk 'BEGIN{had_data=0}{print;had_data=1}END{exit had_data}'
- name: Run unit tests
run: |
python -m unittest *_test.py
e2e:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
extension: ["none", "alphanumeric-en_US"]
env:
AUTOPKGTEST_TMP: /tmp
AUTOPKGTEST_BAMBAM_PROGRAM: ./bambam.py
BAMBAM_RANDOM_SEED: 0
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install GUI packages
run: |
sudo apt-get update
sudo apt-get install -y xvfb xauth imagemagick xdotool sox
- name: Compute arguments
id: args
run: |
case ${{ matrix.extension }} in
none) echo extension_arg= >> $GITHUB_OUTPUT ;;
*) echo extension_arg=-e=${{ matrix.extension }} >> $GITHUB_OUTPUT ;;
esac
if [[ "${{ inputs.golden }}" == true ]]; then
echo golden_subdir_arg=--golden-subdir=${{ matrix.python-version }}/${{ matrix.extension }} >> $GITHUB_OUTPUT
else
echo golden_subdir_arg=--ignored= >> $GITHUB_OUTPUT
fi
- name: Run regular GUI tests
run: ./run_e2e_test.sh regular ${{ steps.args.outputs.golden_subdir_arg }}/regular -- ${{ steps.args.outputs.extension_arg }}
if: always()
- name: Run GUI tests in dark mode
run: ./run_e2e_test.sh dark --no-expect-light-mode ${{ steps.args.outputs.golden_subdir_arg }}/dark -- --dark ${{ steps.args.outputs.extension_arg }}
if: always()
- name: Run GUI tests with deterministic sounds
run: ./run_e2e_test.sh deterministic ${{ steps.args.outputs.golden_subdir_arg }}/deterministic -- --deterministic-sounds ${{ steps.args.outputs.extension_arg }}
if: always()
- name: Run GUI tests muted
run: ./run_e2e_test.sh muted --no-expect-sounds ${{ steps.args.outputs.golden_subdir_arg }}/muted -- --mute ${{ steps.args.outputs.extension_arg }}
if: always()
- name: Run GUI tests muted just initially
run: ./run_e2e_test.sh start-muted ${{ steps.args.outputs.golden_subdir_arg }}/start-muted -- --mute ${{ steps.args.outputs.extension_arg }}
if: always()
- name: Run GUI tests without sound support
run: ./run_e2e_test.sh no-audio --no-expect-audio-output --sdl-audio-driver invalid ${{ steps.args.outputs.golden_subdir_arg }}/no-sound -- ${{ steps.args.outputs.extension_arg }}
if: always()
- name: Save artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: test-artifacts-${{ matrix.python-version }}-${{ matrix.extension }}
path: artifacts
- name: Save golden files
uses: actions/upload-artifact@v3
if: always() && inputs.golden == true
with:
name: test-golden-${{ matrix.python-version }}-${{ matrix.extension }}
path: test/golden
nofonts:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"] # Just latest to keep number of combinations down.
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install GUI packages
run: |
sudo apt-get install -y xvfb xauth
- name: Run test for font absence
run: |
export AUTOPKGTEST_ARTIFACTS=`pwd`/artifacts
mkdir -p $AUTOPKGTEST_ARTIFACTS
export AUTOPKGTEST_TMP=/tmp
# Prepare permissions for deleting freetype.
for lib in $(./test/find-freetype.sh echo); do
dir="$(dirname "${lib}")"
echo "Granting write permission on ${dir}" >&2
sudo chmod a+w "${dir}"
done
xvfb-run \
-e $AUTOPKGTEST_ARTIFACTS/xvfb-run.stderr \
-s "-screen 0 1024x768x24 -fbdir $AUTOPKGTEST_TMP" \
./test/find-freetype.sh rm-and-run \
timeout -v -k 5 10 \
./test/redirect-stderr-and-run.sh errors.txt ./bambam.py || echo Bambam under xvfb exited code $?
if grep -q 'Error: pygame fonts not available. Exiting.' errors.txt; then
echo "Expected font absence message found."
exit 0
fi
echo "Expected font absence message not found."
cat errors.txt
exit 1