allow use of is_integrated_over_time #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI, Test, and Tag-Based Release with Dev TestPyPI | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger for pushes to main | |
| tags: | |
| - 'v*' # Trigger for pushes of tags like v1.0, v2.3.4 | |
| pull_request: | |
| branches: [ main ] # Trigger for PRs targeting main | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| # --- Test Job (Remains the same) --- | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image with Cache | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| target: dev | |
| tags: my-test-image:latest | |
| load: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Run tests with dFBA extra | |
| run: | | |
| docker run --rm \ | |
| -v "$(pwd):/app" \ | |
| -w /app \ | |
| my-test-image:latest \ | |
| uv run --with dfba --with pytest --with pytest-cov coverage run --parallel-mode -m pytest ./tests/extras --junitxml=test-report-dfba.xml | |
| - name: Run tests without dFBA extra | |
| run: | | |
| docker run --rm \ | |
| -v "$(pwd):/app" \ | |
| -w /app \ | |
| my-test-image:latest \ | |
| uv run --with pytest --with pytest-cov coverage run --parallel-mode -m pytest ./tests/core --junitxml=test-report-core.xml | |
| - name: Combine and Report Coverage | |
| if: success() | |
| run: | | |
| docker run --rm \ | |
| -v "$(pwd):/app" \ | |
| -w /app \ | |
| my-test-image:latest \ | |
| sh -c '\ | |
| echo "Combining coverage data..." && \ | |
| uv run --with pytest --with pytest-cov coverage combine && \ | |
| echo "Generating coverage summary..." && \ | |
| uv run --with pytest --with pytest-cov coverage report -m > /app/coverage_summary.txt && \ | |
| echo "Generating HTML coverage report..." && \ | |
| uv run --with pytest --with pytest-cov coverage html -d htmlcov \ | |
| ' | |
| echo "--- Coverage Summary ---" | |
| cat coverage_summary.txt | |
| echo "------------------------" | |
| - name: Format Coverage Comment Body | |
| if: success() && github.event_name == 'pull_request' | |
| run: | | |
| echo '### :test_tube: Coverage Report' > coverage_comment.md | |
| echo '' >> coverage_comment.md | |
| echo '```text' >> coverage_comment.md | |
| cat coverage_summary.txt >> coverage_comment.md | |
| echo '' >> coverage_comment.md | |
| echo '```' >> coverage_comment.md | |
| - name: Post or Update Coverage Comment | |
| if: success() && github.event_name == 'pull_request' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| path: coverage_comment.md | |
| # --- Job: Publish DEV version to TestPyPI (Runs ONLY on tag pushes) --- | |
| publish-testpypi: | |
| name: Publish Dev Version to TestPyPI | |
| needs: test | |
| # Run ONLY when a tag is pushed, AFTER tests pass | |
| if: success() | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/pypi | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install build dependencies | |
| run: python -m pip install build twine | |
| # --- Add step to generate dev suffix --- | |
| - name: Generate development version suffix | |
| id: version_suffix | |
| # Using timestamp for uniqueness on TestPyPI for potentially repeated tag tests | |
| run: echo "suffix=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | |
| # --- Add step to update version --- | |
| - name: Update version in pyproject.toml for TestPyPI | |
| run: | | |
| # Add .dev<timestamp> suffix to the version line | |
| # This assumes version = "X.Y.Z" format in pyproject.toml | |
| VERSION_SUFFIX="${{ steps.version_suffix.outputs.suffix }}" | |
| # Use temp file for sed compatibility | |
| sed -i.bak "s/^\(version\s*=\s*\"\)\([^\"]*\)\"/\1\2.dev${VERSION_SUFFIX}\"/" pyproject.toml | |
| rm pyproject.toml.bak # Remove backup | |
| echo "Updated pyproject.toml with dev version suffix for TestPyPI build:" | |
| grep "^version" pyproject.toml | |
| - name: Build package with dev version | |
| run: | | |
| echo "Building package for tag ${{ github.ref_name }} with dev suffix..." | |
| python -m build | |
| - name: Publish package distributions to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| # skip-existing: true # Recommended for dev builds | |
| # --- Job: Publish CLEAN version to PyPI (Runs ONLY on tag pushes, after TestPyPI) --- | |
| publish-pypi: | |
| name: Publish Clean Version to PyPI | |
| needs: publish-testpypi # Depends on the TestPyPI dev publish job | |
| # Run ONLY when a tag is pushed, AFTER TestPyPI publish succeeds | |
| if: success() && startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/pypi | |
| permissions: | |
| id-token: write | |
| steps: | |
| # --- Checkout code AGAIN to get the original version --- | |
| - name: Checkout ORIGINAL code for tag | |
| uses: actions/checkout@v4 | |
| with: | |
| # Make sure we're checking out the code corresponding to the tag | |
| # This ensures we get the pyproject.toml WITHOUT the .dev suffix | |
| ref: ${{ github.ref }} | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install build dependencies | |
| run: python -m pip install build twine | |
| - name: Build package with CLEAN version | |
| run: | | |
| echo "Building package for tag ${{ github.ref_name }} for PyPI release (using original version)..." | |
| grep "^version" pyproject.toml | |
| # Builds the package using the version defined in the tagged commit's source | |
| # because we checked out the original code again. | |
| python -m build | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| # Defaults to PyPI, uses trusted publishing via OIDC |