diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a9afcd6..e68998e 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: @@ -38,23 +36,18 @@ 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 + permissions: + contents: read + 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..0f5e0de --- /dev/null +++ b/.github/workflows/test-runner.yml @@ -0,0 +1,86 @@ +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 + permissions: + contents: read + 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=$(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 + + - 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