Update black requirement from ==24.* to ==25.* #588
This file contains 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: Check | |
on: | |
pull_request: | |
branches: | |
- "*" | |
push: | |
branches: | |
- "main" | |
env: | |
PIP_DISABLE_PIP_VERSION_CHECK: yes | |
jobs: | |
fix_stupid_mistakes: | |
name: Fix stupid mistakes | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
if: github.ref_type == 'branch' | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install requirements | |
run: pip install -r requirements-dev.txt | |
- name: Run autoflake | |
run: autoflake --recursive --in-place --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys . | |
- name: Run isort | |
run: isort . | |
- name: Run Black | |
run: black . | |
- name: Update README | |
run: | | |
export TMP_FILE="$(mktemp)" | |
python3 -m typed_stream take_while '"<!--- BEGIN EXAMPLE --->".__ne__' < README.md > "${TMP_FILE}" | |
echo '<!--- BEGIN EXAMPLE --->' >> "${TMP_FILE}" | |
echo '```py' >> "${TMP_FILE}" | |
python3 -c 'import typed_stream;print(typed_stream.__doc__.strip())' | python3 -m typed_stream drop_while 'lambda x: not x.startswith(">>>")' >> "${TMP_FILE}" | |
echo '```' >> "${TMP_FILE}" | |
python3 -m typed_stream drop_while '"<!--- END EXAMPLE --->".__ne__' < README.md >> "${TMP_FILE}" | |
cat "${TMP_FILE}" > README.md | |
rm "${TMP_FILE}" | |
- name: Push changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "🤦" | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
- "3.13" | |
- "3.14-dev" | |
- "pypy3.10" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Coverage.py | |
run: grep "^coverage" requirements-dev.txt | xargs pip install | |
- name: Run tests | |
run: | | |
python3 -m examples.test | |
coverage run -m tests | |
- name: Upload coverage as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: .coverage | |
if-no-files-found: error | |
include-hidden-files: true | |
name: coverage-${{ matrix.python-version }} | |
test-rustpython: | |
name: Test RustPython | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup RustPython | |
run: | | |
rustup update stable && rustup default stable | |
cargo install --features "bz2,encodings,ssl" --git https://github.com/RustPython/RustPython.git rustpython | |
rustpython -m ensurepip | |
- name: Run tests | |
run: | | |
rustpython -m examples.test | |
rustpython -m tests | |
mypy: | |
name: mypy | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- "3.10" | |
- "3.12" | |
- "3.13" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install requirements | |
run: grep -E "^(mypy|typing-extensions)" requirements-dev.txt | xargs pip install | |
- name: Run mypy | |
run: mypy --python-version ${{ matrix.python-version }} | |
pytype: | |
name: pytype | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install requirements | |
run: pip install -r requirements-dev.txt | |
- name: Run pytype | |
run: pytype | |
flake8: | |
name: Flake8 | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install requirements | |
run: pip install -r requirements-dev.txt | |
- name: Run Flake8 | |
run: flake8 | |
pylint: | |
name: Pylint | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install requirements | |
run: pip install -r requirements-dev.txt | |
- name: Run Pylint | |
run: pylint . | |
bandit: | |
name: Bandit | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install requirements | |
run: pip install -r requirements-dev.txt | |
- name: Run Bandit | |
run: bandit -c pyproject.toml -r typed_stream examples | |
is_on_main: | |
name: Run this if on main | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "Registered a push event on main" | |
github-pages: | |
name: GitHub Pages | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
needs: | |
- test | |
- is_on_main | |
permissions: | |
contents: read | |
id-token: write | |
pages: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Download coverage | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-3.13 | |
- name: Install Coverage.py | |
run: grep "^coverage" requirements-dev.txt | xargs pip install | |
- name: Create directory | |
run: mkdir github-pages | |
- name: Create coverage files | |
run: | | |
coverage report --precision=3 --sort=-miss --skip-covered | |
coverage html -d github-pages/coverage | |
coverage json -o github-pages/coverage.json | |
./generate-badge.sh > github-pages/coverage/badge.svg | |
rm github-pages/coverage/.gitignore | |
- name: Upload GitHub Pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: github-pages | |
- name: Deploy GitHub Pages site | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
get_version: | |
name: Get version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
latest_version: ${{ steps.latest_version.outputs.latest_version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
filter: blob:none | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Get current version | |
id: version | |
run: | | |
echo -n "version=" >> $GITHUB_OUTPUT | |
./typed_stream/version.py >> $GITHUB_OUTPUT | |
- name: Get latest version | |
id: latest_version | |
run: | | |
echo -n "latest_version=" >> $GITHUB_OUTPUT | |
git describe --tags --abbrev=0 >> $GITHUB_OUTPUT | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install build frontend | |
run: grep "^build==" requirements-dev.txt | xargs pip install | |
- name: Build | |
run: make build | |
- name: Upload as build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: dist | |
release: | |
name: Release a new version | |
if: needs.get_version.outputs.version != needs.get_version.outputs.latest_version | |
runs-on: ubuntu-latest | |
needs: | |
- fix_stupid_mistakes | |
- test | |
- test-rustpython | |
- mypy | |
- pytype | |
- flake8 | |
- pylint | |
- bandit | |
- is_on_main | |
- get_version | |
- build | |
steps: | |
- run: echo "Preparing to release version ${{ needs.get_version.outputs.version }}" | |
pypi: | |
name: Upload to PyPI | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
permissions: {} | |
steps: | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
- name: Install Twine | |
run: pip install twine | |
- name: Run Twine | |
run: | | |
twine check --strict *.tar.gz *.whl | |
twine upload --verbose --disable-progress-bar *.tar.gz *.whl | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
github_release: | |
name: Create release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: | |
- release | |
- get_version | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.get_version.outputs.version }} | |
generate_release_notes: true | |
files: | | |
*.tar.gz | |
*.whl |