Python Build and Test #458
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: Python Build and Test | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| pull_request: | |
| branches: [ "main", "develop" ] | |
| schedule: | |
| - cron: "0 15 * * *" | |
| permissions: | |
| contents: read | |
| security-events: read | |
| env: | |
| PYTHON_VERSION: "3.13" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.python-version }} | |
| cancel-in-progress: true | |
| env: | |
| UV_PYTHON: ${{ matrix.python-version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --all-extras --dev | |
| - name: Building | |
| run: | | |
| uv build | |
| - name: Linting | |
| run: | | |
| uv run black --check ./src | |
| - name: Testing | |
| run: | | |
| export PYTHONPATH=$PWD/src | |
| uv run python -m unittest discover -v -s ./tests -p 'test_*.py' | |
| - name: Documentation building | |
| run: | | |
| export PYTHONPATH=$PWD/src | |
| uv run sphinx-build -b html ./docs ./public | |
| # Only run examples on push to main branch | |
| # examples: | |
| # runs-on: ubuntu-latest | |
| # if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| # needs: build | |
| # steps: | |
| # - uses: actions/checkout@v6 | |
| # - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| # uses: actions/setup-python@v6 | |
| # with: | |
| # python-version: ${{ env.PYTHON_VERSION }} | |
| # - name: Install uv | |
| # uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 | |
| # - name: Install dependencies | |
| # run: | | |
| # uv sync --all-extras --dev | |
| # - name: Run Examples | |
| # env: | |
| # GITHUB_TOKEN: "${{ secrets.GHASTOOLKIT_PAT }}" | |
| # GHASTOOLKIT_ORG_PAT: "${{ secrets.GHASTOOLKIT_ORG_PAT }}" | |
| # run: | | |
| # set -e | |
| # export PYTHONPATH=$PWD/src | |
| # for f in examples/*.py; do | |
| # echo "[+] Running :: $f" | |
| # uv run python $f | |
| # done | |
| cli: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --all-extras --dev | |
| - name: Run CLI | |
| env: | |
| GITHUB_TOKEN: "${{ github.token }}" | |
| run: | | |
| set -e | |
| export PYTHONPATH=$PWD/src | |
| uv run python -m ghastoolkit --help |