From dd223c5dbadda824df61d867731bec06a9fa6079 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 10:45:04 +0000 Subject: [PATCH 01/10] #167: Add codecov dependency --- poetry.lock | 19 ++++++++++++++++++- pyproject.toml | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index b9d46a1d..e4ceab30 100644 --- a/poetry.lock +++ b/poetry.lock @@ -111,6 +111,18 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "codecov" +version = "2.1.11" +description = "Hosted coverage reports for GitHub, Bitbucket and Gitlab" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.dependencies] +coverage = "*" +requests = ">=2.7.9" + [[package]] name = "colorama" version = "0.4.4" @@ -829,7 +841,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake [metadata] lock-version = "1.1" python-versions = "^3.5" -content-hash = "db66f1e49ef4c5f9929c189d886b7c6b7d4306044a31e0eed7993d3ab6e9baab" +content-hash = "91a9b00a037123055e40ab4f183e1b702c414e6eaa02387738eefd5ade149785" [metadata.files] aniso8601 = [ @@ -872,6 +884,11 @@ click = [ {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, ] +codecov = [ + {file = "codecov-2.1.11-py2.py3-none-any.whl", hash = "sha256:ba8553a82942ce37d4da92b70ffd6d54cf635fc1793ab0a7dc3fecd6ebfb3df8"}, + {file = "codecov-2.1.11-py3.8.egg", hash = "sha256:e95901d4350e99fc39c8353efa450050d2446c55bac91d90fcfd2354e19a6aef"}, + {file = "codecov-2.1.11.tar.gz", hash = "sha256:6cde272454009d27355f9434f4e49f238c0273b216beda8472a65dc4957f473b"}, +] colorama = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, diff --git a/pyproject.toml b/pyproject.toml index c0f18722..c6676cac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,9 +40,9 @@ pytest = "^6.1.2" coverage = {extras = ["toml"], version = "^5.3"} pytest-cov = "^2.10.1" pytest-icdiff = "^0.5" +codecov = "^2.1.11" [tool.poetry.scripts] -datagateway-api = "datagateway_api.src.main:run_api" [build-system] requires = ["poetry-core>=1.0.0"] From a9380830a4543afede3752bb7541023d9078ae33 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 10:45:52 +0000 Subject: [PATCH 02/10] #167: Add coverage nox session --- noxfile.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/noxfile.py b/noxfile.py index 4a97e124..bf265268 100644 --- a/noxfile.py +++ b/noxfile.py @@ -87,3 +87,10 @@ def tests(session): args = session.posargs session.run("poetry", "install", external=True) session.run("pytest", *args) + + +@nox.session(reuse_venv=True) +def coverage(session): + install_with_constraints(session, "coverage[toml]", "codecov") + session.run("coverage", "xml", "--fail-under=0") + session.run("codecov", *session.posargs) From e43b39e7a27d16cfcf14987179105a237bdbd298 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 10:46:58 +0000 Subject: [PATCH 03/10] #167: Add status badge for codecov --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 092590d9..2fc4f4a8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ [![Build Status](https://github.com/ral-facilities/datagateway-api/workflows/CI/badge.svg?branch=master)](https://github.com/ral-facilities/datagateway-api/actions?query=workflow%3A%22CI%22) +[![Codecov](https://codecov.io/gh/ral-facilities/datagateway-api/branch/master/graph/badge.svg)](https://codecov.io/gh/ral-facilities/datagateway-api) + # DataGateway API From 55ecf7a2de6cf56e884a28eb7558c49f35437dc9 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 11:15:58 +0000 Subject: [PATCH 04/10] #167: Add coverage Actions workflow --- .github/workflows/coverage.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..4cfec4ac --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,28 @@ +name: Coverage +on: + pull_request: + push: + branches: + - master + - feature/code-coverage-#167 +jobs: + coverage: + runs-on: ubuntu-16.04 + name: Code Coverage + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.6' + architecture: x64 + - name: Checkout DataGateway API + uses: actions/checkout@v2 + with: + path: datagateway-api + + - name: Install Nox + run: pip install nox==2020.8.22 + - name: Install Poetry + run: pip install poetry==1.1.4 + - name: Get & upload code coverage data + run: nox -s coverage From 16e434b4ec40d14460a8d496222b4c0a24c29588 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 11:17:27 +0000 Subject: [PATCH 05/10] #167: Add arg for noxfile.py --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4cfec4ac..e8969ebe 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,4 +25,4 @@ jobs: - name: Install Poetry run: pip install poetry==1.1.4 - name: Get & upload code coverage data - run: nox -s coverage + run: nox -s coverage -f datagateway-api/noxfile.py From b5c22a26202a13b2811ed08a11ec7ae9c0215533 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 12:19:14 +0000 Subject: [PATCH 06/10] #167: Add coverage steps in build and test --- .github/workflows/ci-build.yml | 12 +++++++++--- .gitignore | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index f126991f..f1dff798 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - feature/code-coverage-#167 jobs: tests: runs-on: ubuntu-16.04 @@ -81,10 +82,15 @@ jobs: run: | cd datagateway-api && poetry run python -m util.icat_db_generator -s 4 -y 3 - # Run each Nox tests session + # Run Nox tests session, saves and uploads a coverage report to codecov - name: Run Nox tests session - if: always() - run: nox -s tests -f datagateway-api/noxfile.py + run: nox -s tests -f datagateway-api/noxfile.py -- --cov=datagateway_api --cov-report=xml + - name: Upload code coverage report + if: matrix.python-version == '3.6' + uses: codecov/codecov-action@v1 + with: + directory: ./datagateway-api + linting: runs-on: ubuntu-16.04 diff --git a/.gitignore b/.gitignore index bfcfa809..51b7483a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ config.json .nox/ .python-version .coverage +coverage.xml From 3c8ba505578eac996e216a789ff3d58b4ead2425 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 12:38:49 +0000 Subject: [PATCH 07/10] #167: Remove coverage workflow --- .github/workflows/ci-build.yml | 1 - .github/workflows/coverage.yml | 28 ---------------------------- 2 files changed, 29 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index f1dff798..c25ca6db 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -91,7 +91,6 @@ jobs: with: directory: ./datagateway-api - linting: runs-on: ubuntu-16.04 name: Linting diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index e8969ebe..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Coverage -on: - pull_request: - push: - branches: - - master - - feature/code-coverage-#167 -jobs: - coverage: - runs-on: ubuntu-16.04 - name: Code Coverage - steps: - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: '3.6' - architecture: x64 - - name: Checkout DataGateway API - uses: actions/checkout@v2 - with: - path: datagateway-api - - - name: Install Nox - run: pip install nox==2020.8.22 - - name: Install Poetry - run: pip install poetry==1.1.4 - - name: Get & upload code coverage data - run: nox -s coverage -f datagateway-api/noxfile.py From ce6f2fcab52eaa9462b7aa137b599141faade8f9 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 12:47:48 +0000 Subject: [PATCH 08/10] #167: Remove current branch to launch CI build --- .github/workflows/ci-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index c25ca6db..356c523d 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -5,7 +5,6 @@ on: push: branches: - master - - feature/code-coverage-#167 jobs: tests: runs-on: ubuntu-16.04 From 680a5e74ff68e5c0aeeb123712421a8f9ef4f18b Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 12:48:15 +0000 Subject: [PATCH 09/10] #167: Remove coverage nox session - This was not used, with the codecov GitHub Actions plugin used instead --- noxfile.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/noxfile.py b/noxfile.py index bf265268..4a97e124 100644 --- a/noxfile.py +++ b/noxfile.py @@ -87,10 +87,3 @@ def tests(session): args = session.posargs session.run("poetry", "install", external=True) session.run("pytest", *args) - - -@nox.session(reuse_venv=True) -def coverage(session): - install_with_constraints(session, "coverage[toml]", "codecov") - session.run("coverage", "xml", "--fail-under=0") - session.run("codecov", *session.posargs) From 9542fc808562d57b5070fa0f73c79b3830ead6f0 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 18 Jan 2021 13:03:18 +0000 Subject: [PATCH 10/10] #167: Remove codecov as a dependency - This is no longer needed, I've opted to use the GitHub Actions codecov plugin --- poetry.lock | 19 +------------------ pyproject.toml | 1 - 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/poetry.lock b/poetry.lock index e4ceab30..b9d46a1d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -111,18 +111,6 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -[[package]] -name = "codecov" -version = "2.1.11" -description = "Hosted coverage reports for GitHub, Bitbucket and Gitlab" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[package.dependencies] -coverage = "*" -requests = ">=2.7.9" - [[package]] name = "colorama" version = "0.4.4" @@ -841,7 +829,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake [metadata] lock-version = "1.1" python-versions = "^3.5" -content-hash = "91a9b00a037123055e40ab4f183e1b702c414e6eaa02387738eefd5ade149785" +content-hash = "db66f1e49ef4c5f9929c189d886b7c6b7d4306044a31e0eed7993d3ab6e9baab" [metadata.files] aniso8601 = [ @@ -884,11 +872,6 @@ click = [ {file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"}, {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, ] -codecov = [ - {file = "codecov-2.1.11-py2.py3-none-any.whl", hash = "sha256:ba8553a82942ce37d4da92b70ffd6d54cf635fc1793ab0a7dc3fecd6ebfb3df8"}, - {file = "codecov-2.1.11-py3.8.egg", hash = "sha256:e95901d4350e99fc39c8353efa450050d2446c55bac91d90fcfd2354e19a6aef"}, - {file = "codecov-2.1.11.tar.gz", hash = "sha256:6cde272454009d27355f9434f4e49f238c0273b216beda8472a65dc4957f473b"}, -] colorama = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, diff --git a/pyproject.toml b/pyproject.toml index c6676cac..1323ded7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,6 @@ pytest = "^6.1.2" coverage = {extras = ["toml"], version = "^5.3"} pytest-cov = "^2.10.1" pytest-icdiff = "^0.5" -codecov = "^2.1.11" [tool.poetry.scripts]