Skip to content

Commit

Permalink
Merge pull request #253 from xen0n/platform-baseline-ci
Browse files Browse the repository at this point in the history
Ensure compatibility with the platform support baseline in CI
  • Loading branch information
xen0n authored Dec 29, 2024
2 parents cd7dff2 + b7d6262 commit f40d19b
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 6 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:

jobs:
lint:
name: 'lint & typecheck & test (Python ${{ matrix.python }})'
name: "lint & typecheck & test (Python ${{ matrix.python }}${{ matrix.baseline && ', baseline deps' || '' }}${{ matrix.experimental && ', experimental' || '' }})"
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
Expand All @@ -33,24 +33,50 @@ jobs:
- '3.11'
- '3.12'
experimental: [false]
baseline: [false]
include:
- python: '3.13'
baseline: false
experimental: true
- python: '3.10'
baseline: true
experimental: false
steps:
- uses: actions/checkout@v4

- name: Install deps system-wide
if: success() && matrix.baseline
run: |
./scripts/install-baseline-deps.sh
# give the Poetry environment access to the system-wide deps
# this has to be done before virtualenv creation
export POETRY_VIRTUALENVS_OPTIONS_SYSTEM_SITE_PACKAGES=true
- name: Install Poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: poetry
- name: Install deps

- name: Install deps in the venv
if: success() && !matrix.baseline
run: poetry install --with=dev
- name: Install only the dev tools in the venv
if: success() && matrix.baseline
run: poetry install --only=dev

- name: Lint with ruff
run: poetry run ruff check
- name: Type-check with mypy
# it is rather cumbersome to work with ancient versions of deps that
# lack type annotations, so just rely on the CI job running with
# non-baseline deps
if: success() && !matrix.baseline
run: poetry run mypy
- name: Type-check with pyright
# same with pyright
if: success() && !matrix.baseline
run: poetry run -- pyright --pythonversion ${{ matrix.python }}
- name: Test with pytest
run: poetry run pytest
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mypy = "^1.9.0"
pyright = "^1.1.389"
pytest = "^8.2.2"
ruff = "^0.8.1"
typing-extensions = "^4.12.2"
typing-extensions = ">=3.10.0.2"

types-cffi = "^1.16.0.20240106"
types-pygit2 = "^1.14.0.20240317"
Expand Down
38 changes: 36 additions & 2 deletions ruyi/utils/ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class ArpyArchiveWrapper(arpy.Archive, AbstractContextManager["arpy.Archive"]):
"""Compatibility context manager shim for arpy.Archive, for working across
arpy 1.x and 2.x."""
"""Compatibility shim for arpy.Archive, for easy interop with both arpy 1.x
and 2.x."""

def __init__(
self,
Expand Down Expand Up @@ -38,3 +38,37 @@ def __exit__(

# backport of arpy 2.x __exit__ implementation
self.close()

def infolist(self) -> list[arpy.ArchiveFileHeader]:
if hasattr(super(), "infolist"):
return super().infolist()

# backport of arpy 2.x infolist()
self.read_all_headers()
return [
header
for header in self.headers
if header.type
in (
arpy.HEADER_BSD,
arpy.HEADER_NORMAL,
arpy.HEADER_GNU,
)
]

def open(self, name: bytes | arpy.ArchiveFileHeader) -> arpy.ArchiveFileData:
if hasattr(super(), "open"):
return super().open(name)

# backport of arpy 2.x open()
if isinstance(name, bytes):
ar_file = self.archived_files.get(name)
if ar_file is None:
raise KeyError("There is no item named %r in the archive" % (name,))

return ar_file

if name not in self.headers:
raise KeyError("Provided header does not match this archive")

return arpy.ArchiveFileData(ar_obj=self, header=name)
28 changes: 28 additions & 0 deletions scripts/install-baseline-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

main() {
local pkglist=(
# Package versions provided by Ubuntu 22.04 LTS.
python3-arpy # 1.1.1
python3-certifi # 2020.6.20
python3-jinja2 # 3.0.3
python3-packaging # 21.3
python3-pygit2 # 1.6.1
python3-yaml # 5.4.1 # https://github.com/yaml/pyyaml/issues/724
python3-requests # 2.25.1
python3-rich # 11.2.0
python3-semver # 2.10.2
python3-tomli # 1.2.2
python3-tomlkit # 0.9.2
python3-typing-extensions # 3.10.0.2
)

export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
sudo apt-get update -qqy
sudo apt-get install -y "${pkglist[@]}"
}

main "$@"

0 comments on commit f40d19b

Please sign in to comment.