From 7fe989693c7d6527963a944f9f4db6767b76cf09 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sat, 8 Aug 2020 18:03:16 +0100 Subject: [PATCH] Move fmt and clippy to actions --- .github/workflows/test.yml | 25 ++++++++++++++++++++++++- .travis.yml | 2 -- Makefile | 6 +----- build.rs | 2 +- ci/travis/test.sh | 5 ----- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ce79462..5ec1393f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,31 @@ name: Test on: [push, pull_request] 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: + 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 }} runs-on: ${{ matrix.platform.os }} strategy: @@ -20,7 +44,6 @@ jobs: - python-version: pypy3 platform: { os: "windows-latest", python-architecture: "x64" } - steps: - uses: actions/checkout@v2 diff --git a/.travis.yml b/.travis.yml index da1bd015..0a145ff8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ jobs: python: "3.7" - name: Python 3.8 python: "3.8" - # Run clippy and rustfmt - env: RUN_LINT=1 - name: Python 3.9-dev python: "3.9-dev" - name: Nightly diff --git a/Makefile b/Makefile index 682f4a39..87b67ea8 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ .PHONY: test test_py publish clippy lint fmt -# Constant used in clippy target -CLIPPY_LINTS_TO_DENY := warnings - test: lint test_py cargo test @@ -15,8 +12,7 @@ fmt: clippy: @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 -- \ - $(addprefix -D ,${CLIPPY_LINTS_TO_DENY}) + cargo clippy --features="default num-bigint num-complex" --tests -- -Dwarnings for example in examples/*; do (cd $$example/; cargo clippy) || exit 1; done lint: fmt clippy diff --git a/build.rs b/build.rs index b431afc3..2426fedf 100644 --- a/build.rs +++ b/build.rs @@ -392,7 +392,7 @@ fn find_interpreter() -> Result { } }) .map(PathBuf::from) - .ok_or("Python 3.x interpreter not found".into()) + .ok_or_else(|| "Python 3.x interpreter not found".into()) } } diff --git a/ci/travis/test.sh b/ci/travis/test.sh index b10e55c4..62b6db75 100755 --- a/ci/travis/test.sh +++ b/ci/travis/test.sh @@ -10,11 +10,6 @@ else cargo build; fi -if [[ $RUN_LINT == 1 ]]; then - pip install --pre black==19.3b0 - make lint -fi - for example_dir in examples/*; do cd $example_dir if [[ $FEATURES == *"pypy"* ]]; then