From 1e4beb59e3e0507f3d046c22cfc6118e96e07db6 Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 22:24:11 +0100 Subject: [PATCH 1/8] chore: Add GitHub Action to run pytest This is so we can run pytest automatically without having to do so locally. --- .github/workflows/pytest.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..573320c --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,35 @@ +name: pytesting + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry shell + poetry install + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest tests/unit + pytest tests/integration From c8358dbb06e3e7b27a3cf1427b6199b74369b8eb Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 22:27:49 +0100 Subject: [PATCH 2/8] style: Add GitHub Action badge to README.md This is so you can immediately see from the outset the status of the tests. --- .github/workflows/{pytest.yml => pytesting.yml} | 0 README.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{pytest.yml => pytesting.yml} (100%) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytesting.yml similarity index 100% rename from .github/workflows/pytest.yml rename to .github/workflows/pytesting.yml diff --git a/README.md b/README.md index 3089dd8..dd4e328 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # sqlquerygraph -[![CodeFactor](https://www.codefactor.io/repository/github/avisionh/sqlquerygraph/badge)](https://www.codefactor.io/repository/github/avisionh/sqlquerygraph) [![License: MIT](https://img.shields.io/badge/License-MIT-informational.svg)](https://opensource.org/licenses/MIT) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![build status](https://github.com/avisionh/sqlquerygraph/workflows/pytesting/badge.svg)](https://github.com/avisionh/sqlqueryraph/actions) [![CodeFactor](https://www.codefactor.io/repository/github/avisionh/sqlquerygraph/badge)](https://www.codefactor.io/repository/github/avisionh/sqlquerygraph) [![License: MIT](https://img.shields.io/badge/License-MIT-informational.svg)](https://opensource.org/licenses/MIT) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) Parse your SQL queries and represent their structure as a graph. From cbb7a59af6914343256c1d9f05dea6e66d13e0a3 Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 22:37:11 +0100 Subject: [PATCH 3/8] fix: Specify use of poetry GitHub Action This is so the GitHub action knows where to get poetry from. Also specify multiple OSes so we can increase the coverage to different machines. --- .github/workflows/pytesting.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pytesting.yml b/.github/workflows/pytesting.yml index 573320c..074c040 100644 --- a/.github/workflows/pytesting.yml +++ b/.github/workflows/pytesting.yml @@ -3,12 +3,14 @@ name: pytesting on: [push, pull_request] jobs: - build: - runs-on: ubuntu-latest + ci: strategy: + fail-fast: false matrix: python-version: [3.6, 3.7, 3.8] - + poetry-version: [1.0, 1.1.6] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -17,6 +19,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" + - name: Run python poetry action + uses: abatilo/actions-poetry@v2.1.0 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies run: | python -m pip install --upgrade pip From f1731856b692de9c829d23c6bb5d0b927da4d115 Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 22:49:32 +0100 Subject: [PATCH 4/8] fix: Remove manual call of poetry This is assuming that the poetry GitHub Action handles this. --- .github/workflows/pytesting.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pytesting.yml b/.github/workflows/pytesting.yml index 074c040..fcf7fab 100644 --- a/.github/workflows/pytesting.yml +++ b/.github/workflows/pytesting.yml @@ -7,8 +7,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8] - poetry-version: [1.0, 1.1.6] + python-version: [3.7, 3.8] + poetry-version: [1.1.6] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: @@ -23,12 +23,6 @@ jobs: uses: abatilo/actions-poetry@v2.1.0 with: poetry-version: ${{ matrix.poetry-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install poetry - poetry shell - poetry install - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From d583a62f3acd294568584379974ad46618051563 Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 22:54:43 +0100 Subject: [PATCH 5/8] fix: Re-include install of packages in poetry.lock This is to get the GitHub Action to work. --- .github/workflows/pytesting.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pytesting.yml b/.github/workflows/pytesting.yml index fcf7fab..43620c8 100644 --- a/.github/workflows/pytesting.yml +++ b/.github/workflows/pytesting.yml @@ -23,6 +23,9 @@ jobs: uses: abatilo/actions-poetry@v2.1.0 with: poetry-version: ${{ matrix.poetry-version }} + - name: Install dependencies + run: | + poetry install - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 1a6095afde9ef891fec6256d6a3a44241aaa5cb9 Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 22:58:00 +0100 Subject: [PATCH 6/8] fix: Add flake8 to poetry.lock This is so it gets installed in CI. --- poetry.lock | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 0f9cabf..7ae4cb6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -84,6 +84,19 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "flake8" +version = "3.9.2" +description = "the modular source code checker: pep8 pyflakes and co" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" + +[package.dependencies] +mccabe = ">=0.6.0,<0.7.0" +pycodestyle = ">=2.7.0,<2.8.0" +pyflakes = ">=2.3.0,<2.4.0" + [[package]] name = "identify" version = "2.2.4" @@ -103,6 +116,14 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +[[package]] +name = "mccabe" +version = "0.6.1" +description = "McCabe checker, plugin for flake8" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "nodeenv" version = "1.6.0" @@ -127,6 +148,22 @@ pyyaml = ">=5.1" toml = "*" virtualenv = ">=20.0.8" +[[package]] +name = "pycodestyle" +version = "2.7.0" +description = "Python style guide checker" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "pyflakes" +version = "2.3.1" +description = "passive checker of Python programs" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + [[package]] name = "pyyaml" version = "5.4.1" @@ -211,7 +248,7 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "6af24c5d464b31db8da12ad76f19a7261fe8f08ec7563a51a78335f77983c711" +content-hash = "09173b5e497218e0d74966bdf08a78ebbfbc7322863b44a255d4e01538efec91" [metadata.files] appdirs = [ @@ -248,6 +285,10 @@ filelock = [ {file = "filelock-3.0.12-py3-none-any.whl", hash = "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836"}, {file = "filelock-3.0.12.tar.gz", hash = "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59"}, ] +flake8 = [ + {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"}, + {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"}, +] identify = [ {file = "identify-2.2.4-py2.py3-none-any.whl", hash = "sha256:ad9f3fa0c2316618dc4d840f627d474ab6de106392a4f00221820200f490f5a8"}, {file = "identify-2.2.4.tar.gz", hash = "sha256:9bcc312d4e2fa96c7abebcdfb1119563b511b5e3985ac52f60d9116277865b2e"}, @@ -256,6 +297,10 @@ idna = [ {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, ] +mccabe = [ + {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, + {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, +] nodeenv = [ {file = "nodeenv-1.6.0-py2.py3-none-any.whl", hash = "sha256:621e6b7076565ddcacd2db0294c0381e01fd28945ab36bcf00f41c5daf63bef7"}, {file = "nodeenv-1.6.0.tar.gz", hash = "sha256:3ef13ff90291ba2a4a7a4ff9a979b63ffdd00a464dbe04acf0ea6471517a4c2b"}, @@ -264,6 +309,14 @@ pre-commit = [ {file = "pre_commit-2.12.1-py2.py3-none-any.whl", hash = "sha256:70c5ec1f30406250b706eda35e868b87e3e4ba099af8787e3e8b4b01e84f4712"}, {file = "pre_commit-2.12.1.tar.gz", hash = "sha256:900d3c7e1bf4cf0374bb2893c24c23304952181405b4d88c9c40b72bda1bb8a9"}, ] +pycodestyle = [ + {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"}, + {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, +] +pyflakes = [ + {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"}, + {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"}, +] pyyaml = [ {file = "PyYAML-5.4.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:3b2b1824fe7112845700f815ff6a489360226a5609b96ec2190a45e62a9fc922"}, {file = "PyYAML-5.4.1-cp27-cp27m-win32.whl", hash = "sha256:129def1b7c1bf22faffd67b8f3724645203b79d8f4cc81f674654d9902cb4393"}, diff --git a/pyproject.toml b/pyproject.toml index 39eb96c..d59f726 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ python = "^3.8" pre-commit = "^2.12.1" detect-secrets = "^1.1.0" direnv = "^2020.12.3" +flake8 = "^3.9.2" [tool.poetry.dev-dependencies] From 25f08e990053d4dc6c11390420af0bea3c9f207e Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 23:04:29 +0100 Subject: [PATCH 7/8] perf: Remove python version 3.7 This is because poetry only works for 3.8 and above. Thus, include 3.9 instead. --- .github/workflows/pytesting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytesting.yml b/.github/workflows/pytesting.yml index 43620c8..6b43b7e 100644 --- a/.github/workflows/pytesting.yml +++ b/.github/workflows/pytesting.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8] + python-version: [3.8, 3.9] poetry-version: [1.1.6] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} From 7aa243141bfe7deb7853808b7f71cc03c6795d31 Mon Sep 17 00:00:00 2001 From: avisionh Date: Thu, 20 May 2021 23:22:34 +0100 Subject: [PATCH 8/8] fix: Use poetry run to execute commands within poetry venv This is because poetry shell does not make sense in a CI where an interactive shell does not work. --- .github/workflows/pytesting.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pytesting.yml b/.github/workflows/pytesting.yml index 6b43b7e..81bc57a 100644 --- a/.github/workflows/pytesting.yml +++ b/.github/workflows/pytesting.yml @@ -29,10 +29,6 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest tests/unit - pytest tests/integration + poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics