Skip to content

Enforce UTF-8 encoding for linter subprocess on Windows #135

Enforce UTF-8 encoding for linter subprocess on Windows

Enforce UTF-8 encoding for linter subprocess on Windows #135

---
name: Build and test
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
branches:
- main
env:
PY_IGNORE_IMPORTMISMATCH: 1
jobs:
build-wheel:
runs-on: ubuntu-latest
outputs:
wheel-path: ${{ steps.get-graylint-version.outputs.wheel-path }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install wheel
run: python -m pip install wheel
- name: Build wheel distribution
run: python setup.py bdist_wheel
- name: Upload wheel for other jobs
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
if-no-files-found: error
- name: Find out Graylint version and output it for test jobs
id: get-graylint-version
shell: python
run: |
from os import environ
from pathlib import Path
from runpy import run_path
version = run_path("src/graylint/version.py")["__version__"]
Path(environ["GITHUB_OUTPUT"]).open("a").write(
f"wheel-path=dist/graylint-{version}-py3-none-any.whl\n"
)
test-nixos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
needs:
- build-wheel
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v3
- name: Run tests in nix-shell
run: |
nix-shell \
--pure \
--run '
python -m venv venv
source venv/bin/activate
cert_file=/etc/ssl/certs/ca-certificates.crt
export NIX_SSL_CERT_FILE=$cert_file
pip install "${{needs.build-wheel.outputs.wheel-path}}[test]"
# Run tests in installed package to avoid plugin import issue:
pytest $(python -c "
import os, graylint
print(os.path.dirname(graylint.__file__))
")
' \
./default.nix
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13-dev'
constraints: ['']
post_install: ['']
exclude:
# C extension builds failing.
# Remove exclusions after Python 3.13 release.
- os: windows-latest
python-version: '3.13-dev'
- os: macos-latest
python-version: '3.13-dev'
include:
- os: ubuntu-latest
python-version: '3.8'
constraints: '--constraint constraints-oldest.txt'
- os: ubuntu-latest
python-version: '3.12'
post_install: pip install -r constraints-future.txt
--upgrade --upgrade-strategy=eager
needs:
- build-wheel
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# need full history since Pytest runs Graylint itself below
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v3
- name: Install Graylint and its dependencies from the wheel built earlier
run: pip install "${{needs.build-wheel.outputs.wheel-path}}[test]"
${{ matrix.upgrade }} ${{ matrix.constraints }}
- name: Upgrade Darkgraylib & toml from main if future constraints
# This can't be done in the same Pip invocation as installing
# Darkgraylib since Darkgraylib might place an upper limit on dependencies
# during compatibility fixing periods.
if: matrix.post_install
run: ${{ matrix.post_install }}
- name: Run Pytest
run: pytest
build-sdist-validate-dists:
runs-on: ubuntu-latest
needs:
- build-wheel
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install twine
run: python -m pip install twine
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v3
- name: Build source distribution
run: python setup.py sdist
- name: Validate distributions
run: twine check dist/*