Skip to content

Commit

Permalink
Switch to use uv.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Feb 13, 2025
1 parent 209ca19 commit eb30fea
Show file tree
Hide file tree
Showing 12 changed files with 1,418 additions and 402 deletions.
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: false
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/statusbot

- 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
180 changes: 93 additions & 87 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,56 +13,56 @@ 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.9', '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:
python: ['3.10', '3.11', '3.12', '3.13']
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
check_formatting: ['0']
extra_name: ['']
include:
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.9', '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) }}
26 changes: 11 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ci:
autofix_prs: true
autoupdate_schedule: weekly
autoupdate_schedule: quarterly
submodules: false
skip: [badgie]

Expand All @@ -18,13 +18,6 @@ repos:
- id: check-case-conflict
- id: sort-simple-yaml
files: .pre-commit-config.yaml
- repo: /~https://github.com/hadialqattan/pycln
rev: v2.5.0
hooks:
- id: pycln
args: [--config=pyproject.toml, src]
types: [file]
types_or: [python, pyi]
- repo: /~https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
hooks:
Expand All @@ -35,6 +28,7 @@ repos:
- id: ruff
types: [file]
types_or: [python, pyi, toml]
args: ["--show-fixes"]
- repo: /~https://github.com/CoolCat467/badgie
rev: v0.9.6
hooks:
Expand All @@ -43,11 +37,13 @@ repos:
rev: v2.4.1
hooks:
- id: codespell
- repo: local
additional_dependencies:
- tomli
- repo: /~https://github.com/crate-ci/typos
rev: typos-dict-v0.12.5
hooks:
- id: typos
- repo: /~https://github.com/woodruffw/zizmor-pre-commit
rev: v1.3.1
hooks:
- id: project-requirements
name: regenerate requirements.in
language: system
entry: python tools/project_requirements.py
pass_filenames: false
files: ^(test-requirements.in)|(pyproject.toml)$
- id: zizmor
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# StatusBot
StatusBot is a discord bot that will post information about a given Java Editon minecraft server in a given channel once configured.
StatusBot is a discord bot that will post information about a given Java Edition minecraft server in a given channel once configured.

<!-- BADGIE TIME -->

Expand Down Expand Up @@ -76,7 +76,7 @@ As of version 0.5.0, the following describes StatusBot's commands.
If you are StatusBot's owner, you are the guild owner, or you are in the
`set-option-users` list, the following settings can be modified:

`address` - Address of the java editon minecraft server StatusBot should monitor
`address` - Address of the java edition minecraft server StatusBot should monitor

`channel` - Name of the discord channel StatusBot should post player leave-join messages in.

Expand Down
15 changes: 8 additions & 7 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,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 +97,10 @@ 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
uv sync --extra tools
black src/$PROJECT
ruff check src/$PROJECT
mypy
./check.sh
in your local checkout.
Expand Down
Loading

0 comments on commit eb30fea

Please sign in to comment.