Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .github/workflows/autodeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:

steps:
- name: Checkout
with:
persist-credentials: true # credentials are needed to push commits
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
Expand All @@ -28,21 +30,17 @@ jobs:

- name: Bump dependencies
run: |
python -m pip install -U pip pre-commit
python -m pip install -r test-requirements.txt
uv pip compile --universal --python-version=3.10 --upgrade test-requirements.in -o test-requirements.txt
pre-commit autoupdate --jobs 0
python -m pip install -U uv
uv lock --upgrade
uv tool install pre-commit
uv run pre-commit autoupdate --jobs 0

- name: Install new requirements
run: python -m pip install -r test-requirements.txt
run: uv sync

# apply newer versions' formatting
- name: Black
run: black src/azul

- name: uv
run: |
uv pip compile --universal --python-version=3.10 test-requirements.in -o test-requirements.txt
- name: Pre-commit updates
run: uv run pre-commit run -a || true

- name: Commit changes and create automerge PR
env:
Expand Down
178 changes: 92 additions & 86 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: CI

permissions: {}

on:
push:
branches-ignore:
Expand All @@ -11,52 +13,52 @@ concurrency:
cancel-in-progress: true

jobs:
## Windows:
## name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
## timeout-minutes: 20
## runs-on: 'windows-latest'
## strategy:
## fail-fast: false
## matrix:
## python: ['3.10', '3.11', '3.12']
## arch: ['x86', 'x64']
## continue-on-error: >-
## ${{
## (
## endsWith(matrix.python, '-dev')
## || endsWith(matrix.python, '-nightly')
## )
## && true
## || false
## }}
## steps:
## - name: Checkout
## uses: actions/checkout@v4
## - name: Setup python
## uses: actions/setup-python@v5
## with:
## # This allows the matrix to specify just the major.minor version while still
## # expanding it to get the latest patch version including alpha releases.
## # This avoids the need to update for each new alpha, beta, release candidate,
## # and then finally an actual release version. actions/setup-python doesn't
## # support this for PyPy presently so we get no help there.
## #
## # 'CPython' -> '3.9.0-alpha - 3.9.X'
## # 'PyPy' -> 'pypy-3.9'
## python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
## architecture: '${{ matrix.arch }}'
## cache: pip
## cache-dependency-path: test-requirements.txt
## - name: Run tests
## run: ./ci.sh
## shell: bash
Windows:
name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
timeout-minutes: 20
runs-on: 'windows-latest'
strategy:
fail-fast: false
matrix:
python: ['3.10', '3.11', '3.12', '3.13']
arch: ['x86', 'x64']
continue-on-error: >-
${{
(
endsWith(matrix.python, '-dev')
|| endsWith(matrix.python, '-nightly')
)
&& true
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup python
uses: actions/setup-python@v5
with:
# This allows the matrix to specify just the major.minor version while still
# expanding it to get the latest patch version including alpha releases.
# This avoids the need to update for each new alpha, beta, release candidate,
# and then finally an actual release version. actions/setup-python doesn't
# support this for PyPy presently so we get no help there.
#
# 'CPython' -> '3.9.0-alpha - 3.9.X'
# 'PyPy' -> 'pypy-3.9'
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
architecture: '${{ matrix.arch }}'
cache: pip
cache-dependency-path: test-requirements.txt
- name: Run tests
run: ./ci.sh
shell: bash

Ubuntu:
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
timeout-minutes: 10
runs-on: 'ubuntu-latest'
# Only run for PRs or pushes to main
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
strategy:
fail-fast: false
matrix:
Expand All @@ -78,6 +80,8 @@ jobs:
}}
steps:
- name: Checkout
with:
persist-credentials: false
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
Expand All @@ -96,49 +100,51 @@ jobs:
env:
CHECK_FORMATTING: '${{ matrix.check_formatting }}'

## macOS:
## name: 'macOS (${{ matrix.python }})'
## timeout-minutes: 15
## runs-on: 'macos-latest'
## strategy:
## fail-fast: false
## matrix:
## python: ['3.10', '3.11', '3.12']
## continue-on-error: >-
## ${{
## (
## endsWith(matrix.python, '-dev')
## || endsWith(matrix.python, '-nightly')
## )
## && true
## || false
## }}
## steps:
## - name: Checkout
## uses: actions/checkout@v4
## - name: Setup python
## uses: actions/setup-python@v5
## with:
## python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
## cache: pip
## cache-dependency-path: test-requirements.txt
## - name: Run tests
## run: ./ci.sh
macOS:
name: 'macOS (${{ matrix.python }})'
timeout-minutes: 15
runs-on: 'macos-latest'
strategy:
fail-fast: false
matrix:
python: ['3.10', '3.11', '3.12', '3.13']
continue-on-error: >-
${{
(
endsWith(matrix.python, '-dev')
|| endsWith(matrix.python, '-nightly')
)
&& true
|| false
}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
cache: pip
cache-dependency-path: test-requirements.txt
- name: Run tests
run: ./ci.sh

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection

if: always()

needs:
- Windows
- Ubuntu
- macOS

## # https://github.com/marketplace/actions/alls-green#why
## check: # This job does nothing and is only used for the branch protection
##
## if: always()
##
## needs:
## - Windows
## - Ubuntu
## - macOS
##
## runs-on: ubuntu-latest
##
## steps:
## - name: Decide whether the needed jobs succeeded or failed
## uses: re-actors/alls-green@release/v1
## with:
## jobs: ${{ toJSON(needs) }}
runs-on: ubuntu-latest

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
21 changes: 15 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ repos:
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-case-conflict
- id: check-added-large-files
- id: sort-simple-yaml
files: .pre-commit-config.yaml
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.9.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.2
rev: v0.14.0
hooks:
- id: ruff
- id: ruff-format
- id: ruff-check
types: [file]
types_or: [python, pyi, toml]
args: ["--show-fixes"]
- repo: https://github.com/CoolCat467/badgie
rev: v0.9.6
hooks:
Expand All @@ -36,6 +35,16 @@ repos:
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/adhtruong/mirrors-typos
rev: v1.38.0
hooks:
- id: typos
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.14.2
hooks:
- id: zizmor
- repo: local
hooks:
- id: project-requirements
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Graphical Azul Game with AI support

[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/CoolCat467/Azul/main.svg)](https://results.pre-commit.ci/latest/github/CoolCat467/Azul/main)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![code style: black](https://img.shields.io/badge/code_style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

<!-- END BADGIE TIME -->

Expand Down
33 changes: 14 additions & 19 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -ex

ON_GITHUB_CI=true
EXIT_STATUS=0
PROJECT='azul'

# If not running on Github's CI, discard the summaries
if [ -z "${GITHUB_STEP_SUMMARY+x}" ]; then
Expand All @@ -13,17 +12,13 @@ if [ -z "${GITHUB_STEP_SUMMARY+x}" ]; then
fi

# Autoformatter *first*, to avoid double-reporting errors
# (we'd like to run further autoformatters but *after* merging;
# see https://forum.bors.tech/t/pre-test-and-pre-merge-hooks/322)
# autoflake --recursive --in-place .
# pyupgrade --py3-plus $(find . -name "*.py")
echo "::group::Black"
if ! black --check src/$PROJECT; then
echo "* Black found issues" >> "$GITHUB_STEP_SUMMARY"
echo "::group::Ruff format"
if ! ruff format --check; then
echo "* Ruff formatting found issues" >> "$GITHUB_STEP_SUMMARY"
EXIT_STATUS=1
black --diff src/$PROJECT
ruff format --diff
echo "::endgroup::"
echo "::error:: Black found issues"
echo "::error:: Ruff formatting found issues"
else
echo "::endgroup::"
fi
Expand Down Expand Up @@ -73,15 +68,15 @@ fi

# Check pip compile is consistent
echo "::group::Pip Compile - Tests"
uv pip compile --universal --python-version=3.10 test-requirements.in -o test-requirements.txt
uv lock
echo "::endgroup::"

if git status --porcelain | grep -q "requirements.txt"; then
echo "::error::requirements.txt changed."
echo "::group::requirements.txt changed"
echo "* requirements.txt changed" >> "$GITHUB_STEP_SUMMARY"
if git status --porcelain | grep -q "uv.lock"; then
echo "::error::uv.lock changed."
echo "::group::uv.lock changed"
echo "* uv.lock changed" >> "$GITHUB_STEP_SUMMARY"
git status --porcelain
git --no-pager diff --color ./*requirements.txt
git --no-pager diff --color ./*uv.lock
EXIT_STATUS=1
echo "::endgroup::"
fi
Expand All @@ -97,9 +92,9 @@ if [ $EXIT_STATUS -ne 0 ]; then
Problems were found by static analysis (listed above).
To fix formatting and see remaining errors, run

uv pip install -r test-requirements.txt
black src/$PROJECT
ruff check src/$PROJECT
uv sync --extra tools
ruff check src
mypy
./check.sh

in your local checkout.
Expand Down
Loading
Loading