| 1 |
name: BamBam |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
pull_request: |
| 6 |
workflow_dispatch: |
| 7 |
inputs: |
| 8 |
golden: |
| 9 |
default: false |
| 10 |
description: "Update and/or check golden files." |
| 11 |
type: boolean |
| 12 |
|
| 13 |
permissions: |
| 14 |
contents: read |
| 15 |
|
| 16 |
jobs: |
| 17 |
checks: |
| 18 |
|
| 19 |
runs-on: ubuntu-latest |
| 20 |
strategy: |
| 21 |
fail-fast: false |
| 22 |
matrix: |
| 23 |
python-version: ["3.9", "3.10", "3.11"] |
| 24 |
|
| 25 |
steps: |
| 26 |
- uses: actions/checkout@v3 |
| 27 |
|
| 28 |
- name: Set up Python ${{ matrix.python-version }} |
| 29 |
uses: actions/setup-python@v4 |
| 30 |
with: |
| 31 |
python-version: ${{ matrix.python-version }} |
| 32 |
|
| 33 |
- name: Install dependencies |
| 34 |
run: | |
| 35 |
python -m pip install --upgrade pip |
| 36 |
pip install -r requirements-dev.txt |
| 37 |
|
| 38 |
- name: Lint with flake8 |
| 39 |
run: | |
| 40 |
flake8 . --show-source --statistics |
| 41 |
|
| 42 |
- name: Lint with autopep8 |
| 43 |
run: | |
| 44 |
autopep8 -d *.py | awk 'BEGIN{had_data=0}{print;had_data=1}END{exit had_data}' |
| 45 |
|
| 46 |
- name: Run unit tests |
| 47 |
run: | |
| 48 |
python -m unittest *_test.py |
| 49 |
|
| 50 |
e2e: |
| 51 |
|
| 52 |
runs-on: ubuntu-latest |
| 53 |
strategy: |
| 54 |
matrix: |
| 55 |
python-version: ["3.9", "3.10", "3.11"] |
| 56 |
extension: ["none", "alphanumeric-en_US"] |
| 57 |
env: |
| 58 |
AUTOPKGTEST_TMP: /tmp |
| 59 |
AUTOPKGTEST_BAMBAM_PROGRAM: ./bambam.py |
| 60 |
BAMBAM_RANDOM_SEED: 0 |
| 61 |
|
| 62 |
steps: |
| 63 |
- uses: actions/checkout@v3 |
| 64 |
|
| 65 |
- name: Set up Python ${{ matrix.python-version }} |
| 66 |
uses: actions/setup-python@v4 |
| 67 |
with: |
| 68 |
python-version: ${{ matrix.python-version }} |
| 69 |
|
| 70 |
- name: Install dependencies |
| 71 |
run: | |
| 72 |
python -m pip install --upgrade pip |
| 73 |
pip install -r requirements-dev.txt |
| 74 |
|
| 75 |
- name: Install GUI packages |
| 76 |
run: | |
| 77 |
sudo apt-get update |
| 78 |
sudo apt-get install -y xvfb xauth imagemagick xdotool sox |
| 79 |
|
| 80 |
- name: Compute arguments |
| 81 |
id: args |
| 82 |
run: | |
| 83 |
case ${{ matrix.extension }} in |
| 84 |
none) echo extension_arg= >> $GITHUB_OUTPUT ;; |
| 85 |
*) echo extension_arg=-e=${{ matrix.extension }} >> $GITHUB_OUTPUT ;; |
| 86 |
esac |
| 87 |
if [[ "${{ inputs.golden }}" == true ]]; then |
| 88 |
echo golden_subdir_arg=--golden-subdir=${{ matrix.python-version }}/${{ matrix.extension }} >> $GITHUB_OUTPUT |
| 89 |
else |
| 90 |
echo golden_subdir_arg=--ignored= >> $GITHUB_OUTPUT |
| 91 |
fi |
| 92 |
|
| 93 |
- name: Run regular GUI tests |
| 94 |
run: ./run_e2e_test.sh regular ${{ steps.args.outputs.golden_subdir_arg }}/regular -- ${{ steps.args.outputs.extension_arg }} |
| 95 |
if: always() |
| 96 |
|
| 97 |
- name: Run GUI tests in dark mode |
| 98 |
run: ./run_e2e_test.sh dark --no-expect-light-mode ${{ steps.args.outputs.golden_subdir_arg }}/dark -- --dark ${{ steps.args.outputs.extension_arg }} |
| 99 |
if: always() |
| 100 |
|
| 101 |
- name: Run GUI tests with deterministic sounds |
| 102 |
run: ./run_e2e_test.sh deterministic ${{ steps.args.outputs.golden_subdir_arg }}/deterministic -- --deterministic-sounds ${{ steps.args.outputs.extension_arg }} |
| 103 |
if: always() |
| 104 |
|
| 105 |
- name: Run GUI tests muted |
| 106 |
run: ./run_e2e_test.sh muted --no-expect-sounds ${{ steps.args.outputs.golden_subdir_arg }}/muted -- --mute ${{ steps.args.outputs.extension_arg }} |
| 107 |
if: always() |
| 108 |
|
| 109 |
- name: Run GUI tests muted just initially |
| 110 |
run: ./run_e2e_test.sh start-muted ${{ steps.args.outputs.golden_subdir_arg }}/start-muted -- --mute ${{ steps.args.outputs.extension_arg }} |
| 111 |
if: always() |
| 112 |
|
| 113 |
- name: Run GUI tests without sound support |
| 114 |
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 }} |
| 115 |
if: always() |
| 116 |
|
| 117 |
- name: Save artifacts |
| 118 |
uses: actions/upload-artifact@v3 |
| 119 |
if: always() |
| 120 |
with: |
| 121 |
name: test-artifacts-${{ matrix.python-version }}-${{ matrix.extension }} |
| 122 |
path: artifacts |
| 123 |
|
| 124 |
- name: Save golden files |
| 125 |
uses: actions/upload-artifact@v3 |
| 126 |
if: always() && inputs.golden == true |
| 127 |
with: |
| 128 |
name: test-golden-${{ matrix.python-version }}-${{ matrix.extension }} |
| 129 |
path: test/golden |
| 130 |
|
| 131 |
nofonts: |
| 132 |
|
| 133 |
runs-on: ubuntu-latest |
| 134 |
strategy: |
| 135 |
matrix: |
| 136 |
python-version: ["3.11"] # Just latest to keep number of combinations down. |
| 137 |
|
| 138 |
steps: |
| 139 |
- uses: actions/checkout@v3 |
| 140 |
|
| 141 |
- name: Set up Python ${{ matrix.python-version }} |
| 142 |
uses: actions/setup-python@v4 |
| 143 |
with: |
| 144 |
python-version: ${{ matrix.python-version }} |
| 145 |
|
| 146 |
- name: Install dependencies |
| 147 |
run: | |
| 148 |
python -m pip install --upgrade pip |
| 149 |
pip install -r requirements-dev.txt |
| 150 |
|
| 151 |
- name: Install GUI packages |
| 152 |
run: | |
| 153 |
sudo apt-get install -y xvfb xauth |
| 154 |
|
| 155 |
- name: Run test for font absence |
| 156 |
run: | |
| 157 |
export AUTOPKGTEST_ARTIFACTS=`pwd`/artifacts |
| 158 |
mkdir -p $AUTOPKGTEST_ARTIFACTS |
| 159 |
export AUTOPKGTEST_TMP=/tmp |
| 160 |
|
| 161 |
# Prepare permissions for deleting freetype. |
| 162 |
for lib in $(./test/find-freetype.sh echo); do |
| 163 |
dir="$(dirname "${lib}")" |
| 164 |
echo "Granting write permission on ${dir}" >&2 |
| 165 |
sudo chmod a+w "${dir}" |
| 166 |
done |
| 167 |
|
| 168 |
xvfb-run \ |
| 169 |
-e $AUTOPKGTEST_ARTIFACTS/xvfb-run.stderr \ |
| 170 |
-s "-screen 0 1024x768x24 -fbdir $AUTOPKGTEST_TMP" \ |
| 171 |
./test/find-freetype.sh rm-and-run \ |
| 172 |
timeout -v -k 5 10 \ |
| 173 |
./test/redirect-stderr-and-run.sh errors.txt ./bambam.py || echo Bambam under xvfb exited code $? |
| 174 |
|
| 175 |
if grep -q 'Error: pygame fonts not available. Exiting.' errors.txt; then |
| 176 |
echo "Expected font absence message found." |
| 177 |
exit 0 |
| 178 |
fi |
| 179 |
echo "Expected font absence message not found." |
| 180 |
cat errors.txt |
| 181 |
exit 1 |