Skip to content

Unit tests + coverage reports, type checking, pre-commit, and requested fixes #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 77 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
35c25d6
integrate mypy type checking into CI
2bndy5 Jul 26, 2022
1374f8b
resolve #75
2bndy5 Jul 26, 2022
cf96533
resolve #73
2bndy5 Jul 26, 2022
4656598
run pylint workflow on changes to workflow file
2bndy5 Jul 27, 2022
fb5b09b
resolve #76
2bndy5 Jul 27, 2022
09034c3
add unit tests for ignored paths
2bndy5 Jul 27, 2022
cd60a49
run pytest in CI
2bndy5 Jul 27, 2022
1b9b31b
resolve #74 and add unit tests for it
2bndy5 Jul 28, 2022
a9d911a
improve and test CLI arg parsing
2bndy5 Jul 28, 2022
9e37e03
add unit test for database
2bndy5 Jul 28, 2022
b5c721f
switch to pre-commit; run pytest in a matrix
2bndy5 Jul 29, 2022
4b4e18a
parametrize unit tests
2bndy5 Jul 29, 2022
b48ac79
fix changes to dev-test yaml
2bndy5 Jul 29, 2022
b0c3ebb
make database path absolute
2bndy5 Jul 29, 2022
8c89f45
use pathlib to resolve() relative paths in test
2bndy5 Jul 29, 2022
6fe57ef
let db path be independent of repo-root w/o docker
2bndy5 Jul 29, 2022
c0b20bc
this fails locally
2bndy5 Jul 29, 2022
cf295d6
show me value for RUNNER_WORKSPACE
2bndy5 Jul 29, 2022
a656f05
use gh workspace if not in docker env
2bndy5 Jul 29, 2022
b2c751a
simplify the paths' concatenation
2bndy5 Jul 29, 2022
454e158
fix assignment of `Globals.FILES`
2bndy5 Jul 29, 2022
6911a49
treat unsupport events like a push
2bndy5 Jul 29, 2022
767417a
explicitly set a env var when using docker
2bndy5 Jul 29, 2022
9518985
ammend some logic
2bndy5 Jul 29, 2022
ccf8f33
show me some contents of folders on docker
2bndy5 Jul 29, 2022
903d351
hardcode the correct worspace dir
2bndy5 Jul 29, 2022
99bbfd9
remove unused import
2bndy5 Jul 29, 2022
8fa467e
try detecting the docker env better
2bndy5 Jul 29, 2022
400b615
set the docker env var w/ a str
2bndy5 Jul 29, 2022
0367cf4
assume that RUNNER_WORKSPACE is abs
2bndy5 Jul 29, 2022
37e3083
use only relativer path to db on docker
2bndy5 Jul 29, 2022
120919b
Revert "use only relativer path to db on docker"
2bndy5 Jul 29, 2022
0810b1a
better test coverage
2bndy5 Aug 5, 2022
d51d8c9
mkdocstring doesn't support `Tuple[x, x]` type
2bndy5 Aug 5, 2022
d5e3969
fix workflow
2bndy5 Aug 5, 2022
ae5bcae
revert changes to `get_line_cnt_from_cols()`
2bndy5 Aug 5, 2022
8851435
upload without codecov token??
2bndy5 Aug 5, 2022
20f0be0
ensure LF used on demo src
2bndy5 Aug 5, 2022
540a7d7
update workflow
2bndy5 Aug 5, 2022
f8d03ab
re-implement newer `get_line_cnt_from_cols()`
2bndy5 Aug 5, 2022
d88b54c
switch to pyproject.toml (setup.py is a dummy now)
2bndy5 Aug 7, 2022
11f44ac
resolve version exe path better
2bndy5 Aug 7, 2022
91aa28b
ammend make_annotations() (& its tests)
2bndy5 Aug 7, 2022
f35ea72
adjust for pypi releases
2bndy5 Aug 7, 2022
ac8b4f0
allow running locally & fix duplicate log cmds
2bndy5 Aug 8, 2022
d802afb
use pathlib.Path to open files
2bndy5 Aug 8, 2022
b670e9c
rely on pathlib, update pkg name & CI workflows
2bndy5 Aug 8, 2022
6af4794
`is_relative_to()` introduced in python v3.9
2bndy5 Aug 9, 2022
3787de4
`lstrip(".")` from file's extension
2bndy5 Aug 9, 2022
8867252
tidy v13 use abs path to std libs in output error
2bndy5 Aug 9, 2022
f7dad01
build/install wheel in test CI
2bndy5 Aug 9, 2022
2c8fb6d
oops, use correct artifact name
2bndy5 Aug 9, 2022
6a1f91d
remove identifying info from test's event payload
2bndy5 Aug 9, 2022
da9da35
make files list simpler for any event
2bndy5 Aug 9, 2022
269b22c
ammend walking the repo files/folders
2bndy5 Aug 9, 2022
8f48baa
replace os.walk() with pathlib's rglob()
2bndy5 Aug 9, 2022
97f48db
only upload coverage report once from test CI
2bndy5 Aug 9, 2022
b9aa4cc
use OS dependent path separators for DB path
2bndy5 Aug 10, 2022
0a8a7a4
resolve #82
2bndy5 Aug 11, 2022
7d8b850
ensure tidy fixit_lines end w/ a LF
2bndy5 Aug 12, 2022
6e781f1
workflow continue only if `latest` tag was added
2bndy5 Aug 15, 2022
25df187
include v7-9 for CI tests
2bndy5 Aug 17, 2022
6425065
fix docs about `parse_ignore_option()`
2bndy5 Aug 17, 2022
9e75bbe
fix `TidyNotification.__repr__()`
2bndy5 Aug 17, 2022
d8f9bff
Merge branch 'master' into backlogged-updates
2bndy5 Aug 17, 2022
31c332f
tell CI to download clang-tools v7-9
2bndy5 Aug 17, 2022
3925f76
support older versions of clang-tidy YML output
2bndy5 Aug 17, 2022
0608d9b
don't try to traverse a `None` obj
2bndy5 Aug 17, 2022
2a3240d
add common hooks to pre-commit config
2bndy5 Aug 18, 2022
ef5b6e8
add more configs to toml
2bndy5 Aug 18, 2022
2923972
update event triggers on dev-test CI workflow
2bndy5 Aug 18, 2022
23622e1
sort requirements.txt contents
2bndy5 Aug 18, 2022
02abc8f
split pre-commit step into its own CI workflow
2bndy5 Aug 18, 2022
e68e928
pleasing pre-commit hooks
2bndy5 Aug 18, 2022
a178730
fix run-test.yml (trailing whitespaces)
2bndy5 Aug 18, 2022
d3a8585
revise README & remove .ci-ignore file
2bndy5 Aug 18, 2022
b36ee44
add code coverage badge to README
2bndy5 Aug 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .ci-ignore

This file was deleted.

2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
*.py text eol=lf
*.rst text eol=lf
*.sh text eol=lf
*.cpp text eol=lf
*.hpp text eol=lf
4 changes: 2 additions & 2 deletions .github/workflows/mkdocs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install python action for doc extraction
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/pre-commit-hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Pre-commit

on:
push:
pull_request:
types: opened

jobs:
check-source-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: python3 -m pip install pre-commit
- run: pre-commit run --all-files
51 changes: 51 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
branches: [master]
types: [published]
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
# use fetch --all for setuptools_scm to work
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install --upgrade pip twine
- name: Build wheel
run: python -m pip wheel -w dist --no-deps .
- name: Check distribution
run: twine check dist/*
- name: Publish package (to TestPyPI)
if: github.event_name == 'workflow_dispatch' && github.repository == 'cpp-linter/cpp-linter-action'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: twine upload --repository testpypi dist/*
- name: Publish package (to PyPI)
if: github.event_name != 'workflow_dispatch' && github.repository == 'cpp-linter/cpp-linter-action'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
113 changes: 113 additions & 0 deletions .github/workflows/run-dev-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: "Check python code"

on:
push:
paths:
- "**.py"
- pyproject.toml
- pre-commit-config.yaml
- ".github/workflows/run-dev-tests.yml"
pull_request:
types: opened
paths:
- "**.py"
- "**requirements*.txt"
- pyproject.toml
- pre-commit-config.yaml
- ".github/workflows/run-dev-tests.yml"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Build wheel
run: python3 -m pip wheel --no-deps -w dist .
- name: Upload wheel as artifact
uses: actions/upload-artifact@v3
with:
name: cpp-linter-action_wheel
path: ${{ github.workspace }}/dist/*.whl

test:
needs: [build]
strategy:
fail-fast: false
matrix:
py: ['3.7', '3.8', '3.9', '3.10']
os: ['windows-latest', ubuntu-latest]
version: ['13', '12', '11', '10', '9', '8', '7']
include:
- tools_dir: 'N/A'
- os: 'windows-latest'
version: '10'
tools_dir: temp
- os: 'windows-latest'
version: '10'
tools_dir: temp
- os: 'windows-latest'
version: '11'
tools_dir: temp
- os: 'windows-latest'
version: '12'
tools_dir: temp
- os: 'ubuntu-latest'
version: '13'
tools_dir: temp
# - version: '14'
# tools_dir: temp
- version: '7'
tools_dir: temp
- version: '8'
tools_dir: temp
- version: '9'
tools_dir: temp

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}

- name: download wheel artifact
uses: actions/download-artifact@v3
with:
name: cpp-linter-action_wheel
path: dist

- name: Install workflow deps
# using a wildcard as filename on Windows requires a bash shell
shell: bash
run: python3 -m pip install pytest coverage[toml] dist/*.whl

- name: Install clang-tools
if: matrix.tools_dir == 'temp'
run: |
python -m pip install clang-tools
clang-tools --install ${{ matrix.version }} --directory ${{ runner.temp }}/clang-tools

- name: Collect Coverage (native clang install)
if: matrix.tools_dir == 'N/A'
env:
CLANG_VERSION: ${{ matrix.version }}
run: coverage run -m pytest

- name: Collect Coverage (non-native clang install)
if: matrix.tools_dir == 'temp'
env:
CLANG_VERSION: ${{ runner.temp }}/clang-tools
run: coverage run -m pytest

- run: coverage report && coverage xml

- uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest' && matrix.version == '12' && matrix.py == '3.10'
with:
files: ./coverage.xml
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
29 changes: 0 additions & 29 deletions .github/workflows/run-pylint.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ jobs:
git push origin latest

test-action:
needs: [add-tag]
runs-on: ubuntu-latest
steps:
- uses: convictional/[email protected]
with:
owner: cpp-linter
repo: test-cpp-linter-action
repo: test-cpp-linter-action
github_token: ${{ secrets.PAT_TOKEN }}
workflow_file_name: cpp-lint-action.yml
ref: master
Expand All @@ -38,12 +39,13 @@ jobs:
trigger_workflow: true
wait_workflow: true
test-package:
needs: [add-tag]
runs-on: ubuntu-latest
steps:
- uses: convictional/[email protected]
with:
owner: cpp-linter
repo: test-cpp-linter-action
repo: test-cpp-linter-action
github_token: ${{ secrets.PAT_TOKEN }}
workflow_file_name: cpp-lint-package.yml
ref: master
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
tests/*/test*.json
tests/**/*.c

# Translations
*.mo
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tasks:
- init: pip install -r requirements.txt
- init: pip install -r requirements.txt
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-added-large-files
- id: check-yaml
- id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/python/black
rev: '22.6.0'
hooks:
- id: black
args: ["--diff"]
- repo: https://github.com/pycqa/pylint
rev: v2.14.5
hooks:
- id: pylint
name: pylint (action code)
types: [python]
exclude: "^(docs/|tests/|setup.py$)"
additional_dependencies: [pyyaml, requests]
- repo: local
# this is a "local" hook to run mypy (see https://pre-commit.com/#repository-local-hooks)
# because the mypy project doesn't seem to be compatible with pre-commit hooks
hooks:
- id: mypy
name: mypy
description: type checking with mypy tool
language: python
types: [python]
entry: mypy
exclude: "^(docs/|setup.py$)"
additional_dependencies: [mypy, types-pyyaml, types-requests, rich, requests, pytest, pyyaml, '.']
Loading