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
This commit is contained in:
Dhruv Manilawala 2020-10-24 19:07:33 +05:30 committed by GitHub
parent 1cd8e68537
commit b97529dd88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 48 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -2,3 +2,4 @@
[pytest]
markers =
mat_ops: mark a test as utilizing matrix operations.
addopts = --durations=10

View File

@ -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: