From b97529dd88b4b3668ad78ed1b8e35ea031face1c Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Sat, 24 Oct 2020 19:07:33 +0530 Subject: [PATCH] Move validate_solutions and add durations flag to pytest.ini (#3704) * Move PE validate_solutions to scripts/ directory * Update pytest.ini file with durations settings * Remove codespell and autoblack workflow file * Dependent changes to test config files * Update pytest.ini --- .github/workflows/autoblack.yml | 25 ------------------- .github/workflows/codespell.yml | 17 ------------- .github/workflows/project_euler.yml | 7 +++--- .travis.yml | 2 +- pytest.ini | 1 + .../project_euler_answers.json | 0 .../validate_solutions.py | 4 +-- 7 files changed, 8 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/autoblack.yml delete mode 100644 .github/workflows/codespell.yml rename {project_euler => scripts}/project_euler_answers.json (100%) rename {project_euler => scripts}/validate_solutions.py (94%) diff --git a/.github/workflows/autoblack.yml b/.github/workflows/autoblack.yml deleted file mode 100644 index ce34170d4..000000000 --- a/.github/workflows/autoblack.yml +++ /dev/null @@ -1,25 +0,0 @@ -# GitHub Action that uses Black to reformat Python code (if needed) when doing a git push. -# If all Python code in the repo is compliant with Black then this Action does nothing. -# Otherwise, Black is run and its changes are committed to the repo. -# https://github.com/cclauss/autoblack - -name: autoblack_push -on: [push] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 # Use v1, NOT v2 - - uses: actions/setup-python@v2 - - run: pip install black isort - - run: black --check . - - name: If needed, commit black changes to a new pull request - if: failure() - run: | - black . - isort --profile black . - git config --global user.name github-actions - git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git commit -am "fixup! Format Python code with psf/black push" - git push --force origin HEAD:$GITHUB_REF diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml deleted file mode 100644 index e336f6977..000000000 --- a/.github/workflows/codespell.yml +++ /dev/null @@ -1,17 +0,0 @@ -# GitHub Action to automate the identification of common misspellings in text files -# https://github.com/codespell-project/codespell -name: codespell -on: [push, pull_request] -jobs: - codespell: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - run: pip install codespell - - run: | - SKIP="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_022/p022_names.txt" - codespell --ignore-words-list=ans,fo,followings,hist,iff,secant,som,tim --skip=$SKIP --quiet-level=2 - - name: Codespell comment - if: ${{ failure() }} - uses: plettich/python_codespell_action@master diff --git a/.github/workflows/project_euler.yml b/.github/workflows/project_euler.yml index 852b0adbc..e8b011af2 100644 --- a/.github/workflows/project_euler.yml +++ b/.github/workflows/project_euler.yml @@ -1,9 +1,10 @@ on: pull_request: - # only check if a file is changed within the project_euler directory + # only check if a file is changed within the project_euler directory and related files paths: - 'project_euler/**' - '.github/workflows/project_euler.yml' + - 'scripts/validate_solutions.py' name: 'Project Euler' @@ -17,7 +18,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade pytest pytest-cov - - run: pytest --doctest-modules --durations=10 --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/ + - run: pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/ validate-solutions: runs-on: ubuntu-latest steps: @@ -27,4 +28,4 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --upgrade pytest - - run: pytest --durations=10 project_euler/validate_solutions.py + - run: pytest scripts/validate_solutions.py diff --git a/.travis.yml b/.travis.yml index 2a4a6392d..c74669ebc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ jobs: - name: Build install: pip install pytest-cov -r requirements.txt script: - - pytest --doctest-modules --ignore=project_euler/ --durations=10 --cov-report=term-missing:skip-covered --cov=. . + - pytest --doctest-modules --ignore=project_euler/ --cov-report=term-missing:skip-covered --cov=. . after_success: - scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md notifications: diff --git a/pytest.ini b/pytest.ini index a26de5e63..488379278 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,3 +2,4 @@ [pytest] markers = mat_ops: mark a test as utilizing matrix operations. +addopts = --durations=10 diff --git a/project_euler/project_euler_answers.json b/scripts/project_euler_answers.json similarity index 100% rename from project_euler/project_euler_answers.json rename to scripts/project_euler_answers.json diff --git a/project_euler/validate_solutions.py b/scripts/validate_solutions.py similarity index 94% rename from project_euler/validate_solutions.py rename to scripts/validate_solutions.py index 6cc1d6498..e1f68ff84 100755 --- a/project_euler/validate_solutions.py +++ b/scripts/validate_solutions.py @@ -8,8 +8,8 @@ from typing import Dict, List import pytest PROJECT_EULER_DIR_PATH = pathlib.Path.cwd().joinpath("project_euler") -PROJECT_EULER_ANSWERS_PATH = PROJECT_EULER_DIR_PATH.joinpath( - "project_euler_answers.json" +PROJECT_EULER_ANSWERS_PATH = pathlib.Path.cwd().joinpath( + "scripts", "project_euler_answers.json" ) with open(PROJECT_EULER_ANSWERS_PATH) as file_handle: