Move fmt and clippy to actions

This commit is contained in:
David Hewitt 2020-08-08 18:03:16 +01:00
parent ff9cde46e1
commit 7fe989693c
5 changed files with 26 additions and 14 deletions

View File

@ -3,7 +3,31 @@ name: Test
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- run: pip install black==19.10b0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Check python formatting (black)
run: black --check .
- name: Check rust formatting (rustfmt)
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: make clippy
build: build:
needs: [fmt] # don't wait for clippy as fails rarely and takes longer
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
runs-on: ${{ matrix.platform.os }} runs-on: ${{ matrix.platform.os }}
strategy: strategy:
@ -20,7 +44,6 @@ jobs:
- python-version: pypy3 - python-version: pypy3
platform: { os: "windows-latest", python-architecture: "x64" } platform: { os: "windows-latest", python-architecture: "x64" }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@ -16,8 +16,6 @@ jobs:
python: "3.7" python: "3.7"
- name: Python 3.8 - name: Python 3.8
python: "3.8" python: "3.8"
# Run clippy and rustfmt
env: RUN_LINT=1
- name: Python 3.9-dev - name: Python 3.9-dev
python: "3.9-dev" python: "3.9-dev"
- name: Nightly - name: Nightly

View File

@ -1,8 +1,5 @@
.PHONY: test test_py publish clippy lint fmt .PHONY: test test_py publish clippy lint fmt
# Constant used in clippy target
CLIPPY_LINTS_TO_DENY := warnings
test: lint test_py test: lint test_py
cargo test cargo test
@ -15,8 +12,7 @@ fmt:
clippy: clippy:
@touch src/lib.rs # Touching file to ensure that cargo clippy will re-check the project @touch src/lib.rs # Touching file to ensure that cargo clippy will re-check the project
cargo clippy --features="default num-bigint num-complex" --tests -- \ cargo clippy --features="default num-bigint num-complex" --tests -- -Dwarnings
$(addprefix -D ,${CLIPPY_LINTS_TO_DENY})
for example in examples/*; do (cd $$example/; cargo clippy) || exit 1; done for example in examples/*; do (cd $$example/; cargo clippy) || exit 1; done
lint: fmt clippy lint: fmt clippy

View File

@ -392,7 +392,7 @@ fn find_interpreter() -> Result<PathBuf> {
} }
}) })
.map(PathBuf::from) .map(PathBuf::from)
.ok_or("Python 3.x interpreter not found".into()) .ok_or_else(|| "Python 3.x interpreter not found".into())
} }
} }

View File

@ -10,11 +10,6 @@ else
cargo build; cargo build;
fi fi
if [[ $RUN_LINT == 1 ]]; then
pip install --pre black==19.3b0
make lint
fi
for example_dir in examples/*; do for example_dir in examples/*; do
cd $example_dir cd $example_dir
if [[ $FEATURES == *"pypy"* ]]; then if [[ $FEATURES == *"pypy"* ]]; then