mirror of
https://github.com/astral-sh/ty.git
synced 2025-12-23 05:36:53 +00:00
124 lines
4.3 KiB
YAML
124 lines
4.3 KiB
YAML
name: CI
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
CARGO_NET_RETRY: 10
|
|
CARGO_TERM_COLOR: always
|
|
RUSTUP_MAX_RETRIES: 10
|
|
PACKAGE_NAME: ty
|
|
|
|
jobs:
|
|
python-package:
|
|
name: "python package"
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
architecture: x64
|
|
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
|
|
- name: "Build wheels"
|
|
uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3
|
|
with:
|
|
args: --out dist
|
|
- name: "Test wheel"
|
|
run: |
|
|
pip install --force-reinstall --find-links dist "${PACKAGE_NAME}" --pre
|
|
ty --help
|
|
python -m ty --help
|
|
- name: "Remove wheels from cache"
|
|
run: rm -rf target/wheels
|
|
|
|
pre-commit:
|
|
name: "pre-commit"
|
|
runs-on: depot-ubuntu-22.04-16
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
persist-credentials: false
|
|
- uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v6.4.3
|
|
- name: "Cache pre-commit"
|
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
|
|
with:
|
|
path: ~/.cache/pre-commit
|
|
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
|
- name: "Run pre-commit"
|
|
run: |
|
|
echo '```console' > "$GITHUB_STEP_SUMMARY"
|
|
# Enable color output for pre-commit and remove it for the summary
|
|
# Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default
|
|
SKIP=cargo-fmt,clippy,dev-generate-all uvx --python="${PYTHON_VERSION}" pre-commit run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \
|
|
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1
|
|
exit_code="${PIPESTATUS[0]}"
|
|
echo '```' >> "$GITHUB_STEP_SUMMARY"
|
|
exit "$exit_code"
|
|
|
|
generated-check:
|
|
name: "Check generated files unedited"
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v6.4.3
|
|
|
|
- name: "Run auto generation scripts"
|
|
run: |
|
|
./scripts/autogenerate_files.sh
|
|
|
|
- name: "Check for uncommitted changes"
|
|
run: |
|
|
if [[ -n "$(git status --porcelain)" ]]; then
|
|
echo "Error: Auto-generated files were manually edited."
|
|
echo "Files with changes:"
|
|
git status --porcelain
|
|
exit 1
|
|
fi
|
|
|
|
docs:
|
|
timeout-minutes: 10
|
|
name: "mkdocs"
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
MKDOCS_INSIDERS_SSH_KEY_EXISTS: ${{ secrets.MKDOCS_INSIDERS_SSH_KEY != '' }}
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v6.4.3
|
|
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
|
- name: "Add SSH key"
|
|
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }}
|
|
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1
|
|
with:
|
|
ssh-private-key: ${{ secrets.MKDOCS_INSIDERS_SSH_KEY }}
|
|
|
|
- name: "Build docs (public)"
|
|
run: uvx --with-requirements docs/requirements.txt mkdocs build --strict -f mkdocs.public.yml
|
|
|
|
- name: "Build docs (insiders)"
|
|
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }}
|
|
run: uvx --with-requirements docs/requirements-insiders.txt mkdocs build --strict -f mkdocs.insiders.yml
|