From cd5f687139f9ad2b78dd6a66d0935c5d7caf7147 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 14 Apr 2020 22:20:03 -0400 Subject: [PATCH 1/2] ci: Move flake8 to GitHub Actions with reviewdog. --- .github/workflows/reviewdog.yml | 27 ++++++++++++++++++++++++++ .travis.yml | 26 ++++++------------------- requirements/testing/flake8.txt | 5 +++++ requirements/testing/travis_flake8.txt | 5 ----- 4 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/reviewdog.yml create mode 100644 requirements/testing/flake8.txt delete mode 100644 requirements/testing/travis_flake8.txt diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 000000000000..e886eee11017 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,27 @@ +name: Linting +on: [pull_request] + +jobs: + flake8: + name: run-flake8 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python 3 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install linters + run: pip3 install -r requirements/testing/flake8.txt + + - name: Set up reviewdog + run: | + mkdir -p $HOME/bin && curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b $HOME/bin + echo ::add-path::$HOME/bin + - name: Run reviewdog + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + flake8 | reviewdog -f=pep8 -name=flake8 -reporter=github-check diff --git a/.travis.yml b/.travis.yml index 09482b556202..f833e5ef88ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,17 +62,9 @@ env: - NO_AT_BRIDGE=1 # Necessary for GTK3 interactive test. - OPENBLAS_NUM_THREADS=1 - PYTHONFAULTHANDLER=1 - - RUN_PYTEST=1 - - RUN_FLAKE8= matrix: include: - - name: flake8 - python: 3.6 - env: - - RUN_PYTEST= - - RUN_FLAKE8=1 - - EXTRAREQS='-r requirements/testing/travis_flake8.txt' - python: 3.6 env: - PINNEDVERS='-c requirements/testing/travis36minver.txt' @@ -165,13 +157,13 @@ install: # Set flag in a delayed manner to avoid issues with installing other packages - | - if [[ $TRAVIS_OS_NAME != 'osx' ]] && [[ $RUN_PYTEST == 1 ]]; then + if [[ $TRAVIS_OS_NAME != 'osx' ]]; then export CPPFLAGS=--coverage fi - | python -mpip install -ve . # Install Matplotlib. - | - if [[ $TRAVIS_OS_NAME != 'osx' ]] && [[ $RUN_PYTEST == 1 ]]; then + if [[ $TRAVIS_OS_NAME != 'osx' ]]; then unset CPPFLAGS fi @@ -184,16 +176,10 @@ script: # Each script we want to run need to go in its own section and the program # you want to fail travis needs to be the last thing called. - | - if [[ $RUN_PYTEST == 1 ]]; then - # The number of processes is hardcoded (-n2), because using too many - # causes the Travis VM to run out of memory (since so many copies of - # inkscape and ghostscript are running at the same time). - python -mpytest -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n2 --log-level=DEBUG - fi - - | - if [[ $RUN_FLAKE8 == 1 ]]; then - flake8 --statistics && echo "Flake8 passed without any issues!" - fi + # The number of processes is hardcoded (-n2), because using too many + # causes the Travis VM to run out of memory (since so many copies of + # inkscape and ghostscript are running at the same time). + python -mpytest -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n2 --log-level=DEBUG before_cache: | rm -rf $HOME/.cache/matplotlib/tex.cache diff --git a/requirements/testing/flake8.txt b/requirements/testing/flake8.txt new file mode 100644 index 000000000000..9716a81c22c2 --- /dev/null +++ b/requirements/testing/flake8.txt @@ -0,0 +1,5 @@ +# Extra pip requirements for the GitHub Actions flake8 build + +flake8>=3.7 +pydocstyle<4.0 +flake8-docstrings diff --git a/requirements/testing/travis_flake8.txt b/requirements/testing/travis_flake8.txt deleted file mode 100644 index 553d8ffe555d..000000000000 --- a/requirements/testing/travis_flake8.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Extra pip requirements for the travis flake8 build - -flake8>=3.7 -pydocstyle<4.0 -flake8-docstrings From 14cb290625385ba60b391e8fe033b3a2497f87f6 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 15 Apr 2020 01:05:29 -0400 Subject: [PATCH 2/2] ci: Add a cppcheck run to test C/C++ code. Currently, `src` may return errors, but `extern` is only on warning level. --- .github/workflows/reviewdog.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index e886eee11017..109de4dd6e8d 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -25,3 +25,26 @@ jobs: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | flake8 | reviewdog -f=pep8 -name=flake8 -reporter=github-check + + cppcheck: + name: run-cppcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install linters + run: | + sudo apt update + sudo apt install -qq cppcheck + cppcheck --version + + - name: Set up reviewdog + run: | + mkdir -p $HOME/bin && curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b $HOME/bin + echo ::add-path::$HOME/bin + - name: Run reviewdog + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cppcheck --quiet --template="{file}:{line}:{column}: {id}: {message}" src/ |& reviewdog -f=pep8 -name=cppcheck -reporter=github-check -tee + # cppcheck --quiet --template="{file}:{line}:{column}: {id}: {message}" extern/ |& reviewdog -f=pep8 -name=cppcheck -reporter=github-check -level=warning