| 1 |
name: CI |
| 2 |
|
| 3 |
# Since this same workflow file is used for both PRs and pushes, |
| 4 |
# Zizmor wants to flag all uses of caches as potential cache poisoning vulnerabilities. |
| 5 |
# I don't see a way to easily split this workflow into two separate files since |
| 6 |
# we do want to build the package for PRs, and then publish it from that exact |
| 7 |
# built artifact, if we're pushing to tags. |
| 8 |
|
| 9 |
on: # zizmor: ignore[cache-poisoning] |
| 10 |
push: |
| 11 |
branches: |
| 12 |
- master |
| 13 |
- '*-maint' |
| 14 |
tags: |
| 15 |
- 'v*' |
| 16 |
pull_request: |
| 17 |
branches: |
| 18 |
- master |
| 19 |
- '*-maint' |
| 20 |
|
| 21 |
permissions: {} |
| 22 |
|
| 23 |
jobs: |
| 24 |
lint: |
| 25 |
name: lint |
| 26 |
permissions: |
| 27 |
contents: read |
| 28 |
runs-on: ubuntu-latest |
| 29 |
steps: |
| 30 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 31 |
with: |
| 32 |
persist-credentials: false |
| 33 |
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 34 |
with: |
| 35 |
cache-dependency-glob: ".github/workflows/*.yml" |
| 36 |
cache-suffix: pre-commit-uv |
| 37 |
- run: uv tool install pre-commit --with pre-commit-uv --force-reinstall |
| 38 |
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 39 |
with: |
| 40 |
path: ~/.cache/pre-commit |
| 41 |
key: pre-commit-uv-v1-${{ hashFiles('.pre-commit-config.yaml') }} |
| 42 |
- run: pre-commit run --all-files --show-diff-on-failure --color=always |
| 43 |
env: |
| 44 |
RUFF_OUTPUT_FORMAT: github |
| 45 |
test: |
| 46 |
name: test |
| 47 |
permissions: |
| 48 |
contents: read |
| 49 |
runs-on: ${{ matrix.os }} |
| 50 |
strategy: |
| 51 |
matrix: |
| 52 |
os: |
| 53 |
- "ubuntu-24.04" |
| 54 |
- "windows-2022" |
| 55 |
- "macos-14" |
| 56 |
python-version: |
| 57 |
- "3.8" |
| 58 |
- "3.9" |
| 59 |
- "3.10" |
| 60 |
- "3.11" |
| 61 |
- "3.12" |
| 62 |
- "3.13" |
| 63 |
- "3.14" |
| 64 |
- "3.15" |
| 65 |
- "pypy3.10" |
| 66 |
env: |
| 67 |
BABEL_CLDR_NO_DOWNLOAD_PROGRESS: "1" |
| 68 |
BABEL_CLDR_QUIET: "1" |
| 69 |
PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 70 |
steps: |
| 71 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 72 |
with: |
| 73 |
persist-credentials: false |
| 74 |
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 75 |
with: |
| 76 |
path: cldr |
| 77 |
key: cldr-${{ hashFiles('scripts/*cldr*') }} |
| 78 |
- name: Set up Python ${{ matrix.python-version }} |
| 79 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
| 80 |
with: |
| 81 |
python-version: ${{ matrix.python-version }} |
| 82 |
allow-prereleases: true |
| 83 |
cache: "pip" |
| 84 |
cache-dependency-path: "**/setup.py" |
| 85 |
- name: Install dependencies |
| 86 |
run: | |
| 87 |
python -m pip install --upgrade pip setuptools wheel |
| 88 |
python -m pip install 'tox~=4.0' 'tox-gh-actions~=3.0' |
| 89 |
- name: Run test via Tox |
| 90 |
run: tox --skip-missing-interpreters |
| 91 |
env: |
| 92 |
COVERAGE_XML_PATH: ${{ runner.temp }} |
| 93 |
BABEL_TOX_EXTRA_DEPS: pytest-github-actions-annotate-failures |
| 94 |
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 |
| 95 |
with: |
| 96 |
directory: ${{ runner.temp }} |
| 97 |
flags: ${{ matrix.os }}-${{ matrix.python-version }} |
| 98 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 99 |
verbose: true |
| 100 |
benchmark: |
| 101 |
name: benchmark |
| 102 |
permissions: |
| 103 |
contents: read |
| 104 |
runs-on: "ubuntu-24.04" |
| 105 |
env: |
| 106 |
BABEL_CLDR_NO_DOWNLOAD_PROGRESS: "1" |
| 107 |
BABEL_CLDR_QUIET: "1" |
| 108 |
PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 109 |
steps: |
| 110 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 111 |
with: |
| 112 |
persist-credentials: false |
| 113 |
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 114 |
with: |
| 115 |
path: cldr |
| 116 |
key: cldr-${{ hashFiles('scripts/*cldr*') }} |
| 117 |
- name: Set up Python 3.14 |
| 118 |
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 |
| 119 |
with: |
| 120 |
python-version: "3.14" |
| 121 |
activate-environment: 'true' |
| 122 |
- run: uv pip install -e .[dev] pytest-codspeed |
| 123 |
- run: make import-cldr |
| 124 |
- uses: CodSpeedHQ/action@88472375d0a4572cf70a9f1fe3a4e0ab8da1b924 # v5.0.1 |
| 125 |
with: |
| 126 |
mode: simulation |
| 127 |
run: uv run pytest --codspeed tests/benchmarks/benchmark*py |
| 128 |
build: |
| 129 |
name: build |
| 130 |
permissions: |
| 131 |
contents: read |
| 132 |
runs-on: ubuntu-24.04 |
| 133 |
needs: lint |
| 134 |
steps: |
| 135 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 136 |
with: |
| 137 |
persist-credentials: false |
| 138 |
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
| 139 |
with: |
| 140 |
python-version: "3.14" |
| 141 |
cache: "pip" |
| 142 |
cache-dependency-path: "**/setup.py" |
| 143 |
- run: pip install build -e . |
| 144 |
- run: make import-cldr |
| 145 |
- run: python -m build |
| 146 |
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 147 |
with: |
| 148 |
name: dist |
| 149 |
path: dist |
| 150 |
publish: |
| 151 |
name: publish |
| 152 |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 153 |
needs: |
| 154 |
- build |
| 155 |
runs-on: ubuntu-latest |
| 156 |
environment: |
| 157 |
name: release |
| 158 |
url: https://pypi.org/p/babel/ |
| 159 |
permissions: |
| 160 |
id-token: write # Required for Trusted Publishing action |
| 161 |
steps: |
| 162 |
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 163 |
with: |
| 164 |
name: dist |
| 165 |
path: dist/ |
| 166 |
- name: Publish package distributions to PyPI |
| 167 |
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1 |
| 168 |
with: |
| 169 |
verbose: true |
| 170 |
print-hash: true |