Skip to content

Commit

Permalink
Add pageload_smoketest.py and CI setup and jobs
Browse files Browse the repository at this point in the history
A smoketest that sets up `site_vars.php` and a minimal set of database
tables so that PGDP can be served from the `php -S` CLI web server.

Then it loads many pages (soon to be every page) with representative
parameters and checks if there are any PHP errors, warnings, or
notices in the server logs.

Useful for, e.g., catching variables that aren't defined at runtime,
and other issues that PHPStan and the PHP linter can't find.

This is deliberately not an exhaustive test of all possible inputs --
smoke tests are meant to be fast and to weed out obvious brokenness.

That said, we probably should check each of, e.g. `task.php`'s
`action=` parameters so we get reasonable code coverage.

This is incomplete, but is good enough to be useful as is.
  • Loading branch information
bpfoley authored and cpeel committed Mar 27, 2024
1 parent 61c6b14 commit dc8349a
Show file tree
Hide file tree
Showing 10 changed files with 725 additions and 11 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/static-checks.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static code checks
name: CI tests
on: [push, pull_request]
jobs:
phpunit:
Expand Down Expand Up @@ -97,3 +97,28 @@ jobs:
run: make -C SETUP lint_css
- name: Run best practice checks
run: make -C SETUP best_practice_checks
pageload-smoketest:
strategy:
matrix:
cfg:
- { os: 'ubuntu-20.04', php: '7.4' }
- { os: 'ubuntu-22.04', php: '8.1' }
runs-on: ${{ matrix.cfg.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup PHP, composer
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.cfg.php }}
- name: Setup MySQL, install schema
uses: ./.github/actions/setup-mysql-db
- name: Install aspell dependencies for WordCheck tests
run: sudo apt --fix-broken install aspell aspell-en
- name: Add smoketest DB entries
run: |
mysql -uroot -proot < SETUP/smoketests/test_tables.sql
- name: Run pageload smoketest
run: |
SETUP/smoketests/pageload_smoketest.py \
-u admin -p admin_pass -k admin_key
3 changes: 3 additions & 0 deletions SETUP/smoketests/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
// To test that errors are detected correctly.
trigger_error("Yes, it is a problem, sir.", E_USER_ERROR);
3 changes: 3 additions & 0 deletions SETUP/smoketests/hello.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
// An 'always suceeds' script to check server liveness.
echo "Hello world\n";
3 changes: 3 additions & 0 deletions SETUP/smoketests/notice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
// To test that notices are detected correctly.
trigger_error("Good morning, Mr. Wooster.", E_USER_NOTICE);
Loading

0 comments on commit dc8349a

Please sign in to comment.