|
| 1 | +name: CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +env: |
| 9 | + UV_LINK_MODE: "copy" |
| 10 | + UV_FROZEN: "1" |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + linting: |
| 17 | + name: "Code Linting" |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: |
| 20 | + image: ghcr.io/astral-sh/uv:0.6-python3.11-bookworm-slim |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install lint dependencies |
| 26 | + run: uv sync --group linting |
| 27 | + |
| 28 | + - name: Check code style with Ruff |
| 29 | + run: uv run ruff check . |
| 30 | + |
| 31 | + - name: Check code formatting with Ruff |
| 32 | + run: uv run ruff format --check . |
| 33 | + |
| 34 | + - name: Check type hints with mypy |
| 35 | + run: uv run mypy . |
| 36 | + |
| 37 | + tests: |
| 38 | + name: "Run Tests" |
| 39 | + needs: linting |
| 40 | + |
| 41 | + runs-on: ubuntu-latest |
| 42 | + container: |
| 43 | + image: jupyter/pyspark-notebook |
| 44 | + options: --user root |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Install git (needed for checkout) |
| 48 | + run: | |
| 49 | + apt-get update && apt-get install -y git |
| 50 | +
|
| 51 | + - uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Install uv |
| 54 | + run: pip install uv |
| 55 | + |
| 56 | + - name: Install test dependencies |
| 57 | + run: uv sync --group test |
| 58 | + |
| 59 | + - name: Run unit tests |
| 60 | + run: uv run pytest --cov -v --cov-report=term --cov-report=xml |
| 61 | + |
| 62 | + - name: Upload coverage reports to Codecov |
| 63 | + uses: codecov/codecov-action@v5 |
| 64 | + with: |
| 65 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 66 | + slug: sparkdq-community/sparkdq |
| 67 | + |
| 68 | + release: |
| 69 | + name: "Publish Package" |
| 70 | + if: github.ref == 'refs/heads/main' |
| 71 | + needs: tests |
| 72 | + |
| 73 | + runs-on: ubuntu-latest |
| 74 | + container: |
| 75 | + image: ghcr.io/astral-sh/uv:0.6-python3.11-bookworm |
| 76 | + |
| 77 | + permissions: |
| 78 | + id-token: write |
| 79 | + contents: write |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Setup | Checkout Repository on Release Branch |
| 83 | + uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + ref: ${{ github.ref_name }} |
| 86 | + fetch-depth: 0 |
| 87 | + |
| 88 | + - name: Action | Semantic Version Release |
| 89 | + id: release |
| 90 | + uses: python-semantic-release/python-semantic-release@v9.21.1 |
| 91 | + with: |
| 92 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + git_committer_name: "github-actions" |
| 94 | + git_committer_email: "actions@users.noreply.github.com" |
| 95 | + |
| 96 | + - name: Publish | Upload to GitHub Release Assets |
| 97 | + uses: python-semantic-release/publish-action@v9.21.0 |
| 98 | + if: steps.release.outputs.released == 'true' |
| 99 | + with: |
| 100 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + tag: ${{ steps.release.outputs.tag }} |
| 102 | + |
| 103 | + - name: Publish | Upload package to PyPI |
| 104 | + if: steps.release.outputs.released == 'true' |
| 105 | + run: | |
| 106 | + export UV_PUBLISH_TOKEN=${{ secrets.UV_PUBLISH_TOKEN }} |
| 107 | + uv build |
| 108 | + uv publish |
0 commit comments