From 683c11440d0ddc4dcb299d9e0a7676fc8b8879da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:21:44 +0000 Subject: [PATCH 1/5] Initial plan From b2ce908ef57cb7e45455ab0e880da438c718c2e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:25:14 +0000 Subject: [PATCH 2/5] Add Chrome/chromedriver and XVFB setup to build.yml workflow Co-authored-by: BSd3v <82055130+BSd3v@users.noreply.github.com> --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a9afcd6..3805591 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,14 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ inputs.python-version }} + - name: 'Setup Chrome and chromedriver' + uses: nanasess/setup-chromedriver@v2 + - name: 'Setup chromedriver environment' + run: | + export DISPLAY=:99 + chromedriver --url-base=/wd/hub & + - name: Start XVFB + run: Xvfb :99 & - name: Setup dependencies run: | curl -LsSf https://astral.sh/uv/install.sh | sh From 753dc2c9964c40a4936752e7ce8d026f6a4edf03 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:29:26 +0000 Subject: [PATCH 3/5] Refactor workflows to use DRY methodology with reusable test-runner Co-authored-by: BSd3v <82055130+BSd3v@users.noreply.github.com> --- .github/workflows/build.yml | 37 ++++---------- .github/workflows/python-test.yml | 55 +++++++-------------- .github/workflows/test-runner.yml | 80 +++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/test-runner.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3805591..0140cc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,8 @@ on: type: string jobs: - build-and-validate: + build: runs-on: ubuntu-latest - environment: - name: test permissions: contents: write steps: @@ -25,14 +23,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ inputs.python-version }} - - name: 'Setup Chrome and chromedriver' - uses: nanasess/setup-chromedriver@v2 - - name: 'Setup chromedriver environment' - run: | - export DISPLAY=:99 - chromedriver --url-base=/wd/hub & - - name: Start XVFB - run: Xvfb :99 & - name: Setup dependencies run: | curl -LsSf https://astral.sh/uv/install.sh | sh @@ -46,23 +36,16 @@ jobs: source .venv/bin/activate npm run dist shell: bash - - name: Validate distribution - env: - CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} - CLERK_DOMAIN: ${{ secrets.CLERK_DOMAIN }} - CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }} - CLERK_TEST_USER: ${{ secrets.CLERK_TEST_USER }} - CLERK_TEST_PASSWORD: ${{ secrets.CLERK_TEST_PASSWORD }} - run: | - uv venv test-dist - source test-dist/bin/activate - WHL_FILE=$(ls dist/*.whl) - uv pip install "${WHL_FILE}" - uv pip install -r dev-requirements.txt - pytest --headless - shell: bash - name: Upload Python distributions uses: actions/upload-artifact@v4 with: name: python-distributions - path: dist/ \ No newline at end of file + path: dist/ + + validate: + needs: build + uses: ./.github/workflows/test-runner.yml + with: + python-version: ${{ inputs.python-version }} + test-distribution: true + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 78c7260..5e2ac14 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -12,57 +12,38 @@ on: branches: [main] jobs: - test: + test-python-310: + uses: ./.github/workflows/test-runner.yml + with: + python-version: "3.10" + secrets: inherit + + test-python-312: + uses: ./.github/workflows/test-runner.yml + with: + python-version: "3.12" + secrets: inherit + + lint: runs-on: ubuntu-latest - - environment: - name: test - strategy: - matrix: - python-version: ["3.10", "3.12"] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} - - - name: 'Setup Chrome and chromedriver' - uses: nanasess/setup-chromedriver@v2 - - name: 'Setup chromedriver environment' - run: | - export DISPLAY=:99 - chromedriver --url-base=/wd/hub & - - name: Start XVFB - run: Xvfb :99 & + python-version: "3.10" - - name: Setup uv + - name: Setup uv and dependencies run: | curl -LsSf https://astral.sh/uv/install.sh | sh uv venv - - - name: Install dependencies - run: | - npm ci source .venv/bin/activate - uv pip install --upgrade pip - uv pip install wheel uv pip install -r dev-requirements.txt + npm ci - name: Lint run: | source .venv/bin/activate npm run lint - - - name: Run tests - env: - CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} - CLERK_DOMAIN: ${{ secrets.CLERK_DOMAIN }} - CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }} - CLERK_TEST_USER: ${{ secrets.CLERK_TEST_USER }} - CLERK_TEST_PASSWORD: ${{ secrets.CLERK_TEST_PASSWORD }} - run: | - source .venv/bin/activate - pytest --headless \ No newline at end of file diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml new file mode 100644 index 0000000..5302c08 --- /dev/null +++ b/.github/workflows/test-runner.yml @@ -0,0 +1,80 @@ +name: Test Runner + +on: + workflow_call: + inputs: + python-version: + required: true + type: string + test-distribution: + required: false + type: boolean + default: false + distribution-artifact: + required: false + type: string + default: 'python-distributions' + +jobs: + test: + runs-on: ubuntu-latest + environment: + name: test + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + - name: 'Setup Chrome and chromedriver' + uses: nanasess/setup-chromedriver@v2 + + - name: 'Setup chromedriver environment' + run: | + export DISPLAY=:99 + chromedriver --url-base=/wd/hub & + + - name: Start XVFB + run: Xvfb :99 & + + - name: Setup uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + uv venv + + - name: Download distribution (if testing built package) + if: ${{ inputs.test-distribution }} + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.distribution-artifact }} + path: dist/ + + - name: Install dependencies from source + if: ${{ !inputs.test-distribution }} + run: | + source .venv/bin/activate + uv pip install --upgrade pip + uv pip install wheel + uv pip install -r dev-requirements.txt + + - name: Install dependencies from distribution + if: ${{ inputs.test-distribution }} + run: | + source .venv/bin/activate + WHL_FILE=$(ls dist/*.whl) + uv pip install "${WHL_FILE}" + uv pip install -r dev-requirements.txt + + - name: Run tests + env: + CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} + CLERK_DOMAIN: ${{ secrets.CLERK_DOMAIN }} + CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }} + CLERK_TEST_USER: ${{ secrets.CLERK_TEST_USER }} + CLERK_TEST_PASSWORD: ${{ secrets.CLERK_TEST_PASSWORD }} + run: | + source .venv/bin/activate + pytest --headless From 77fbf88131a0b3efd650fa19f6034dda4ccd5c00 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:30:56 +0000 Subject: [PATCH 4/5] Improve wheel file selection robustness in test-runner Co-authored-by: BSd3v <82055130+BSd3v@users.noreply.github.com> --- .github/workflows/test-runner.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml index 5302c08..41bffd0 100644 --- a/.github/workflows/test-runner.yml +++ b/.github/workflows/test-runner.yml @@ -64,7 +64,11 @@ jobs: if: ${{ inputs.test-distribution }} run: | source .venv/bin/activate - WHL_FILE=$(ls dist/*.whl) + WHL_FILE=$(find dist -name '*.whl' -type f | head -1) + if [ -z "$WHL_FILE" ]; then + echo "Error: No wheel file found in dist/" + exit 1 + fi uv pip install "${WHL_FILE}" uv pip install -r dev-requirements.txt From 7fa8d48eb7fb8550e52e33f0d26fad6013d7a2fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:32:30 +0000 Subject: [PATCH 5/5] Add explicit permissions to workflows for security Co-authored-by: BSd3v <82055130+BSd3v@users.noreply.github.com> --- .github/workflows/build.yml | 2 ++ .github/workflows/test-runner.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0140cc9..e68998e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,8 @@ jobs: validate: needs: build + permissions: + contents: read uses: ./.github/workflows/test-runner.yml with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/test-runner.yml b/.github/workflows/test-runner.yml index 41bffd0..0f5e0de 100644 --- a/.github/workflows/test-runner.yml +++ b/.github/workflows/test-runner.yml @@ -18,6 +18,8 @@ on: jobs: test: runs-on: ubuntu-latest + permissions: + contents: read environment: name: test steps: