Skip to content

Commit 27ed239

Browse files
authored
feat: Add integration test workflow + Python 3.12 setuptools fix (#611)
* feat: Add GitHub Actions workflow to trigger IIAB integration tests This workflow enables automated integration testing with Internet-in-a-Box (IIAB): - Triggers on PR labeled 'test-iiab-integration' - Triggers on merge to master - Dispatches events to ascoderu/iiab-lokole-tests repository - Posts test results back to PRs Related to integration test suite at: https://github.com/ascoderu/iiab-lokole-tests * fix: Use pull_request_target to enable secrets access for labeled fork PRs This implements the 'safe to test' pattern used by major OSS projects: - Maintainers explicitly approve fork PRs by adding test-iiab-integration label - pull_request_target runs in base repo context with access to secrets - Safe because we don't checkout/execute PR code, only read metadata - Enables integration testing for fork PRs after maintainer review Fixes the workflow failure on fork PRs while maintaining security. * chore: Remove trailing whitespace * fix: add setuptools for Python 3.12+ compatibility Python 3.12+ no longer includes setuptools by default, but flask-security 3.0.0 imports pkg_resources which requires it. This fixes the error: ModuleNotFoundError: No module named 'pkg_resources' * fix: pin setuptools <73 as newer versions removed pkg_resources Setuptools 73+ removed pkg_resources module which is still required by flask-security 3.0.0. Testing showed: - setuptools 72.2.0: ✅ pkg_resources available (deprecated but works) - setuptools 82.0.0: ❌ pkg_resources removed Constraint: setuptools>=65.5.0,<73.0.0 * fix: Add setuptools constraint to requirements.txt for gunicorn compatibility API server was crashing with 'ModuleNotFoundError: No module named pkg_resources' because gunicorn requires pkg_resources from setuptools, but setuptools 73+ removed this module. The constraint was already in requirements-webapp.txt for the client, but requirements.txt (used by API/worker containers) was missing it, causing the API container to fail on startup. Root cause: docker/app/Dockerfile installs both requirements-webapp.txt AND requirements.txt, but the latter lacked the setuptools constraint, allowing pip to install setuptools 73+ which doesn't provide pkg_resources. Fix: Add setuptools>=65.5.0,<73.0.0 to requirements.txt to ensure pkg_resources is available for gunicorn in Python 3.9 API/worker containers. Fixes: Integration test failures where API container exits with code 1
1 parent c3e892e commit 27ed239

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Trigger Integration Tests
2+
3+
on:
4+
# Use pull_request_target for fork PRs to access secrets when labeled by maintainers
5+
# This is safe because:
6+
# 1. We don't checkout or execute any code from the PR
7+
# 2. We only read PR metadata and dispatch to another repo
8+
# 3. The label must be manually added by someone with write access
9+
pull_request_target:
10+
types: [labeled]
11+
push:
12+
branches:
13+
- master
14+
15+
jobs:
16+
trigger-on-label:
17+
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'test-iiab-integration')
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Trigger integration tests
22+
uses: peter-evans/repository-dispatch@v2
23+
with:
24+
token: ${{ secrets.INTEGRATION_TEST_PAT }}
25+
repository: ascoderu/iiab-lokole-tests
26+
event-type: test-integration-lokole
27+
client-payload: |
28+
{
29+
"pr_number": ${{ github.event.pull_request.number }},
30+
"ref": "${{ github.event.pull_request.head.ref }}",
31+
"sha": "${{ github.event.pull_request.head.sha }}",
32+
"repo": "${{ github.repository }}"
33+
}
34+
35+
trigger-on-merge:
36+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Trigger post-merge tests
41+
uses: peter-evans/repository-dispatch@v2
42+
with:
43+
token: ${{ secrets.INTEGRATION_TEST_PAT }}
44+
repository: ascoderu/iiab-lokole-tests
45+
event-type: lokole-merged
46+
client-payload: |
47+
{
48+
"branch": "${{ github.ref_name }}",
49+
"sha": "${{ github.sha }}",
50+
"repo": "${{ github.repository }}"
51+
}

requirements-webapp.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
setuptools>=65.5.0,<73.0.0 # Required for pkg_resources in Python 3.12+ (no longer included by default). Upper bound because setuptools 73+ removed pkg_resources
12
Babel==2.14.0 # 2.14.0+ required for Python 3.13 (removed cgi module dependency)
23
Flask-BabelEx==0.9.4
34
pytz # Required by Flask-BabelEx (no longer a transitive dep of Babel 2.14+)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Flask==2.2.1
22
Flask-Cors==3.0.10
33
Pillow==10.4.0 # 10.1.0+ required for Python 3.13 support
4+
setuptools>=65.5.0,<73.0.0 # Required for pkg_resources (gunicorn dependency). setuptools 73+ removed pkg_resources
45
apache-libcloud==3.6.0
56
applicationinsights==0.11.10
67
beautifulsoup4==4.11.1

0 commit comments

Comments
 (0)