From d1e5a1dcd6ea783568e34fd3f23122abec73f977 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 07:03:06 +0200 Subject: [PATCH 01/10] First try of running web integration tests from github action --- .github/workflows/web-integration-tests.yml | 130 ++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 .github/workflows/web-integration-tests.yml diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml new file mode 100644 index 000000000..8a7ead85e --- /dev/null +++ b/.github/workflows/web-integration-tests.yml @@ -0,0 +1,130 @@ +name: Web Integration Tests + +on: + workflow_dispatch: + inputs: + branch: + description: Branch to run tests on + required: true + default: main + type: choice + options: + - main + - release + +permissions: + issues: write + +jobs: + web-integration: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + + - name: Set up Python 3.9.2 + uses: actions/setup-python@v5 + with: + python-version: '3.9.2' + + - name: Create virtual environment and install dependencies + working-directory: python + run: | + python -m venv .venv + source .venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + + - name: Set up PiFinder_data directory + run: | + mkdir -p ~/PiFinder_data/obslists + mkdir -p ~/PiFinder_data/captures + cp default_config.json ~/PiFinder_data/config.json + + - name: Start PiFinder with fake hardware + working-directory: python + run: | + source .venv/bin/activate + SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy \ + python -m PiFinder.main -fh --camera debug --keyboard none \ + > /tmp/pifinder.log 2>&1 & + echo $! > /tmp/pifinder.pid + echo "PiFinder started with PID $(cat /tmp/pifinder.pid)" + + - name: Wait for PiFinder web server (port 8080) + run: | + for i in $(seq 1 30); do + if curl -sf http://localhost:8080/ > /dev/null 2>&1; then + echo "PiFinder web server is ready" + break + fi + if [ "$i" -eq 30 ]; then + echo "ERROR: server did not start within 150s" + cat /tmp/pifinder.log + exit 1 + fi + echo "Attempt $i/30, sleeping 5s..." + sleep 5 + done + + - name: Run web tests + id: pytest_first + continue-on-error: true + working-directory: python + env: + PIFINDER_HOMEPAGE: http://localhost:8080 + run: | + source .venv/bin/activate + pytest -m web --local -v + + - name: Rerun failed tests with --lf + id: pytest_rerun + if: steps.pytest_first.outcome == 'failure' + continue-on-error: true + working-directory: python + env: + PIFINDER_HOMEPAGE: http://localhost:8080 + run: | + source .venv/bin/activate + pytest -m web --local -v --lf + + - name: Alert maintainers via GitHub Issue + if: steps.pytest_rerun.outcome == 'failure' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh issue create \ + --title "Web Integration Tests failed — $(date -u '+%Y-%m-%d %H:%M UTC')" \ + --body "Web integration tests failed on both the initial run and the --lf rerun. + + **Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + **Triggered by:** ${{ github.actor }} + **Branch:** ${{ inputs.branch }}" \ + --label "bug" + + - name: Fail job after persistent test failure + if: steps.pytest_first.outcome == 'failure' && steps.pytest_rerun.outcome != 'failure' + run: | + echo "First run failed but --lf rerun passed — treating as flaky, not failing job." + + - name: Fail job if rerun also failed + if: steps.pytest_rerun.outcome == 'failure' + run: exit 1 + + - name: Upload PiFinder log on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: pifinder-log + path: /tmp/pifinder.log + + - name: Stop PiFinder + if: always() + run: | + if [ -f /tmp/pifinder.pid ]; then + kill "$(cat /tmp/pifinder.pid)" || true + fi From cdee23796144708f1cc8cc9e3d72461d413c8149 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 07:13:26 +0200 Subject: [PATCH 02/10] Do not need an extra selection of branch Co-authored-by: Copilot --- .github/workflows/web-integration-tests.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 8a7ead85e..ae2b8b2af 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -2,15 +2,6 @@ name: Web Integration Tests on: workflow_dispatch: - inputs: - branch: - description: Branch to run tests on - required: true - default: main - type: choice - options: - - main - - release permissions: issues: write @@ -22,8 +13,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch }} - name: Set up Python 3.9.2 uses: actions/setup-python@v5 From e243c80d6bb28928b3640c533f04215a26fd0eb9 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 07:22:51 +0200 Subject: [PATCH 03/10] Use python 3.2.25 --- .github/workflows/web-integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index ae2b8b2af..4d482bf20 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python 3.9.2 + - name: Set up Python 3.9.25 uses: actions/setup-python@v5 with: python-version: '3.9.2' From 2ef40edd9542f4761e6d10c4cbb783c343b84dcf Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 08:02:39 +0200 Subject: [PATCH 04/10] Really use python 3.9.25 --- .github/workflows/web-integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 4d482bf20..b1a4dd099 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python 3.9.25 uses: actions/setup-python@v5 with: - python-version: '3.9.2' + python-version: '3.9.25' - name: Create virtual environment and install dependencies working-directory: python From 353e27f69fd9fcd8fdfbfe81f1cc8c674c524e33 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 08:14:18 +0200 Subject: [PATCH 05/10] Init submoduels (tetra3) and create symlink Co-authored-by: Copilot --- .github/workflows/web-integration-tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index b1a4dd099..1735a6659 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -28,6 +28,12 @@ jobs: pip install -r requirements.txt pip install -r requirements_dev.txt + - name: Initialize tetra3 + working-directory: python + run: | + git submodules update --init --recursive + ln -s PiFinder/tetra3/tetra3 tetra3 + - name: Set up PiFinder_data directory run: | mkdir -p ~/PiFinder_data/obslists From 3d6da399cffc3cca2872fa1ba2139cfcba5e2823 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 08:16:39 +0200 Subject: [PATCH 06/10] Fix typo initializing submodels --- .github/workflows/web-integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 1735a6659..20b0c07db 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -31,7 +31,7 @@ jobs: - name: Initialize tetra3 working-directory: python run: | - git submodules update --init --recursive + git submodule update --init --recursive ln -s PiFinder/tetra3/tetra3 tetra3 - name: Set up PiFinder_data directory From def4ef162db6bc9a7d05e6a237e607434c1f7b80 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 08:30:58 +0200 Subject: [PATCH 07/10] Use webserver log conf for testing. Co-authored-by: Copilot --- .github/workflows/web-integration-tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 20b0c07db..2ad25939d 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -28,9 +28,15 @@ jobs: pip install -r requirements.txt pip install -r requirements_dev.txt + - name: Use webserver log configuration + working-directory: python + run: | + ln -s logconf_webserver.json pifinder_logconf.json + - name: Initialize tetra3 working-directory: python run: | + git submodule sync git submodule update --init --recursive ln -s PiFinder/tetra3/tetra3 tetra3 From 4ffcf2d556e84e9e52938303653f68d631dd0419 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Wed, 29 Apr 2026 08:46:51 +0200 Subject: [PATCH 08/10] Use local keyboard. --- .github/workflows/web-integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 2ad25939d..4fad54674 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -51,7 +51,7 @@ jobs: run: | source .venv/bin/activate SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy \ - python -m PiFinder.main -fh --camera debug --keyboard none \ + python -m PiFinder.main -fh --camera debug --keyboard local \ > /tmp/pifinder.log 2>&1 & echo $! > /tmp/pifinder.pid echo "PiFinder started with PID $(cat /tmp/pifinder.pid)" From e8d1f121d2d7405a9b7016a835079c1bff32fccd Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Thu, 30 Apr 2026 08:37:43 +0200 Subject: [PATCH 09/10] Download hip_main as part of setting up the webtests. Co-authored-by: Copilot --- .github/workflows/web-integration-tests.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 4fad54674..96f61ac24 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -7,7 +7,8 @@ permissions: issues: write jobs: - web-integration: + web-integration-tests: + name: Web Integration Tests runs-on: ubuntu-latest steps: @@ -40,6 +41,11 @@ jobs: git submodule update --init --recursive ln -s PiFinder/tetra3/tetra3 tetra3 + - name: Download hip_main.dat star catalog + run: | + wget -q -O astro_data/hip_main.dat \ + https://cdsarc.cds.unistra.fr/ftp/cats/I/239/hip_main.dat + - name: Set up PiFinder_data directory run: | mkdir -p ~/PiFinder_data/obslists @@ -50,8 +56,7 @@ jobs: working-directory: python run: | source .venv/bin/activate - SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy \ - python -m PiFinder.main -fh --camera debug --keyboard local \ + SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python -m PiFinder.main -fh --camera debug --keyboard local \ > /tmp/pifinder.log 2>&1 & echo $! > /tmp/pifinder.pid echo "PiFinder started with PID $(cat /tmp/pifinder.pid)" From 59ec6d95b1d814823048db825daf8023c8718533 Mon Sep 17 00:00:00 2001 From: Jens Scheidtmann Date: Fri, 1 May 2026 19:36:33 +0200 Subject: [PATCH 10/10] Caching of hip_main.dat Co-authored-by: Copilot --- .github/workflows/web-integration-tests.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/web-integration-tests.yml b/.github/workflows/web-integration-tests.yml index 96f61ac24..35a1c2a7a 100644 --- a/.github/workflows/web-integration-tests.yml +++ b/.github/workflows/web-integration-tests.yml @@ -41,7 +41,17 @@ jobs: git submodule update --init --recursive ln -s PiFinder/tetra3/tetra3 tetra3 + - name: Use cache of hip_main.dat star catalog + + id: cache-hip-main + uses: actions/cache@v4 + with: + path: astro_data/hip_main.dat + key: hip_main-dat-v1 + # Bump this key, to force redownloading the catalog if it changes or if we want to refresh the cache + - name: Download hip_main.dat star catalog + if: steps.cache-hip-main.outputs.cache-hit != 'true' run: | wget -q -O astro_data/hip_main.dat \ https://cdsarc.cds.unistra.fr/ftp/cats/I/239/hip_main.dat @@ -85,7 +95,7 @@ jobs: PIFINDER_HOMEPAGE: http://localhost:8080 run: | source .venv/bin/activate - pytest -m web --local -v + pytest -ra -m web --local -v - name: Rerun failed tests with --lf id: pytest_rerun @@ -96,7 +106,7 @@ jobs: PIFINDER_HOMEPAGE: http://localhost:8080 run: | source .venv/bin/activate - pytest -m web --local -v --lf + pytest -ra -m web --local -v --lf - name: Alert maintainers via GitHub Issue if: steps.pytest_rerun.outcome == 'failure'