mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
With the latest setup-python actions, there is a better caching mechanism available that also requires less setup, and provides better fallback behavior that should help avoid the random CI failures that have been happening on 3.11 for setuptools-rust. This ensures that we install the necessary dependencies before attempting to build the package or run tests, while still enabling speedups in best case scenario when requirements files haven't changed. See the upstream readme for details: https://github.com/actions/setup-python#caching-packages-dependencies
189 lines
5.5 KiB
YAML
189 lines
5.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
jobs:
|
|
# Run unittests
|
|
test:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
|
|
parser: [pure, native]
|
|
exclude:
|
|
# skip these builds until https://bugs.launchpad.net/lxml/+bug/1977998 is resolved
|
|
- os: windows-latest
|
|
python-version: "3.11"
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
cache: pip
|
|
cache-dependency-path: "**/requirements*.txt"
|
|
python-version: ${{ matrix.python-version }}
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
|
|
- if: ${{ matrix.parser == 'native' }}
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
- if: ${{ matrix.parser == 'native' }}
|
|
name: Rust Cache
|
|
uses: Swatinem/rust-cache@v1.3.0
|
|
with:
|
|
working-directory: native
|
|
- run: >-
|
|
echo LIBCST_PARSER_TYPE=${{ matrix.parser }} >> $GITHUB_ENV
|
|
- name: Run Tests
|
|
run: python setup.py test
|
|
|
|
# Run linters
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
cache: pip
|
|
cache-dependency-path: "**/requirements*.txt"
|
|
python-version: "3.10"
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
|
|
- run: flake8
|
|
- run: ufmt check .
|
|
- run: python3 -m fixit.cli.run_rules
|
|
- run: python -m slotscheck libcst
|
|
- run: ./check_copyright.sh
|
|
|
|
# Run pyre typechecker
|
|
typecheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
cache: pip
|
|
cache-dependency-path: "**/requirements*.txt"
|
|
python-version: "3.10"
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
|
|
- name: Make sure Pyre uses the working copy
|
|
run: pip install -e .
|
|
- run: pyre --version
|
|
- run: pyre -n check
|
|
- run: python scripts/regenerate-fixtures.py
|
|
- run: git diff --exit-code
|
|
|
|
# Upload test coverage
|
|
coverage:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
cache: pip
|
|
cache-dependency-path: "**/requirements*.txt"
|
|
python-version: "3.10"
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
|
|
- name: Generate Coverage
|
|
run: |
|
|
coverage run setup.py test
|
|
coverage xml -i
|
|
- uses: codecov/codecov-action@v3
|
|
with:
|
|
files: coverage.xml
|
|
fail_ci_if_error: true
|
|
verbose: true
|
|
- name: Archive Coverage
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: coverage
|
|
path: coverage.xml
|
|
|
|
# Build the docs
|
|
docs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
cache: pip
|
|
cache-dependency-path: "**/requirements*.txt"
|
|
python-version: "3.10"
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install --upgrade --upgrade-strategy eager build -r requirements.txt -r requirements-dev.txt
|
|
- uses: ts-graphviz/setup-graphviz@v1
|
|
- run: sphinx-build docs/source/ docs/build/
|
|
- name: Archive Docs
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: sphinx-docs
|
|
path: docs/build
|
|
|
|
# Test rust parts
|
|
native:
|
|
name: Rust unit tests
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
components: rustfmt, clippy
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v1.3.0
|
|
with:
|
|
working-directory: native
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
cache: pip
|
|
cache-dependency-path: "**/requirements*.txt"
|
|
python-version: "3.10"
|
|
- name: test
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: --manifest-path=native/Cargo.toml --release
|
|
- name: test without python
|
|
if: matrix.os == 'ubuntu-latest'
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
args: --manifest-path=native/Cargo.toml --release --no-default-features
|
|
- name: clippy
|
|
uses: actions-rs/clippy-check@v1
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
args: --manifest-path=native/Cargo.toml --all-features
|
|
|
|
rustfmt:
|
|
name: Rustfmt
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
- run: rustup component add rustfmt
|
|
- uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: --all --manifest-path=native/Cargo.toml -- --check
|