From c86b5806e81a0b7bc5e099f5f131c1c8d879f96b Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:07:52 +0000 Subject: [PATCH 01/10] Upload coverage to codecov.io --- .github/workflows/main.yaml | 18 ++++++++++++++++++ .gitignore | 2 ++ tox.ini | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d655819a..cc3b910d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -35,6 +35,12 @@ jobs: - run: tox -e tests-api-mock - run: tox -e coverage-report - run: tox -e tests-server + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: ${{ github.repository }} + flags: unittests,server,api-mock tests-noqueue: runs-on: ubuntu-20.04 @@ -51,6 +57,12 @@ jobs: - name: Install tox run: pip install tox - run: tox -e tests-noqueue + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: ${{ github.repository }} + flags: tests-noqueue all-tests: runs-on: ubuntu-20.04 @@ -67,6 +79,12 @@ jobs: - name: Install tox run: pip install tox - run: tox -e tests + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: ${{ github.repository }} + flags: all-tests lint: runs-on: ubuntu-20.04 diff --git a/.gitignore b/.gitignore index a9d650db..4b248b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ settings.yml .coverage .pytest_cache/ build/ +.env +coverage.xml diff --git a/tox.ini b/tox.ini index fe883985..936eccbb 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,8 @@ commands = flake8 bert_e/ [testenv:utests] deps = pip==22.3.1 -commands = pytest bert_e/tests/unit/ {posargs} + pytest-cov==5.0.0 +commands = pytest bert_e/tests/unit/ --cov=bert_e --cov-report=xml {posargs} [testenv:tests-api-mock] deps = From 6aabfef5625c5bf8a2a5f9ae425e71935286b5f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:10:10 -0700 Subject: [PATCH 02/10] github-actions(deps): bump actions/setup-python from 4 to 5 (#154) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/main.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d655819a..82618fdf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -20,7 +20,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' cache: pip @@ -42,7 +42,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' cache: pip @@ -58,7 +58,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' cache: pip @@ -74,7 +74,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' cache: pip From ddbdfa1b346b8948e2ff7e250949caff25f0ff30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:10:31 -0700 Subject: [PATCH 03/10] Bump requests-mock from 1.10.0 to 1.12.1 (#172) Bumps [requests-mock](https://github.com/jamielennox/requests-mock) from 1.10.0 to 1.12.1. - [Release notes](https://github.com/jamielennox/requests-mock/releases) - [Commits](https://github.com/jamielennox/requests-mock/compare/1.10.0...1.12.1) --- updated-dependencies: - dependency-name: requests-mock dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 11b836ff..861c9a3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ py-gfm==0.1.4 pytest==7.4.2 PyYAML==6.0 requests==2.28.2 -requests-mock==1.10.0 +requests-mock==1.12.1 werkzeug==2.2.3 WTForms==3.0.1 jwt==1.3.1 From 68afcf31266116ec63b701ff2f9eea3b8adc49d6 Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:16:55 -0700 Subject: [PATCH 04/10] Update basic tests workflow triggers --- .github/workflows/main.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b0324352..7696c0bf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,15 +1,12 @@ name: basic tests on: + pull_request: + branches: + - main push: branches: - - 'user/**' - - 'feature/**' - - 'improvement/**' - - 'bugfix/**' - - 'dependabot/**' - - 'w/**' - - 'q/**' + - main permissions: write-all From af08272ed40b086cf62c9f3cda1553b8f79ec846 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:18:42 +0000 Subject: [PATCH 05/10] Bump pyyaml from 6.0 to 6.0.1 (#130) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 861c9a3d..94635672 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ marshmallow==3.20.1 MarkupSafe==2.1.2 py-gfm==0.1.4 pytest==7.4.2 -PyYAML==6.0 +PyYAML==6.0.1 requests==2.28.2 requests-mock==1.12.1 werkzeug==2.2.3 From a1288a64ff28c6adfc47baf4f5f10fb8947286c7 Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:21:45 -0700 Subject: [PATCH 06/10] Add codecov.io badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bb49c5c7..29386836 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # README +[![codecov](https://codecov.io/gh/scality/bert-e/graph/badge.svg?token=VWEQLKMUN5)](https://codecov.io/gh/scality/bert-e) + Scality's automated branch merging tool. ## User documentation From 43240e3a8ed23ed90d60f817d3343f1870e24614 Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:25:11 +0200 Subject: [PATCH 07/10] PTFE-1481 fixes for check run interactions (#175) --- bert_e/exceptions.py | 9 ++++--- bert_e/git_host/github/__init__.py | 30 +++++++++++++---------- bert_e/git_host/github/schema.py | 2 +- bert_e/tests/test_bert_e.py | 2 +- bert_e/tests/unit/test_github_app_auth.py | 2 +- bert_e/workflow/pr_utils.py | 4 +-- tox.ini | 2 +- 7 files changed, 28 insertions(+), 23 deletions(-) diff --git a/bert_e/exceptions.py b/bert_e/exceptions.py index 43a3441f..9a66e802 100644 --- a/bert_e/exceptions.py +++ b/bert_e/exceptions.py @@ -22,13 +22,13 @@ class BertE_Exception(Exception): code = -1 + status: Literal[None, "in_progress", "queued", "success", "failure"] = None # base exceptions class TemplateException(BertE_Exception): code = -2 template = None - status: Literal[None, "in_progress", "success", "failure"] = None # whether to re-publish if the message is already in the history dont_repeat_if_in_history = -1 @@ -148,7 +148,7 @@ class Conflict(TemplateException): class ApprovalRequired(TemplateException): code = 115 template = 'need_approval.md' - status = "in_progress" + status = "queued" class BuildFailed(TemplateException): @@ -160,7 +160,7 @@ class BuildFailed(TemplateException): class AfterPullRequest(TemplateException): code = 120 template = 'after_pull_request.md' - status = "in_progress" + status = "queued" class IntegrationDataCreated(InformationException): @@ -265,7 +265,7 @@ class RequestIntegrationBranches(TemplateException): code = 135 template = "request_integration_branches.md" # TODO: review if it should be failure. - status = "in_progress" + status = "queued" class QueueBuildFailedMessage(TemplateException): @@ -568,6 +568,7 @@ class NothingToDo(SilentException): class BuildInProgress(SilentException): code = 303 + status = "in_progress" class BuildNotStarted(SilentException): diff --git a/bert_e/git_host/github/__init__.py b/bert_e/git_host/github/__init__.py index e8f52d4b..12d5bbb1 100644 --- a/bert_e/git_host/github/__init__.py +++ b/bert_e/git_host/github/__init__.py @@ -53,7 +53,8 @@ def __init__(self, login: str, password: str, email: str, self.password = password self.app_id = app_id self.installation_id = installation_id - self.private_key = jwk_from_pem(private_key) + self.private_key = jwk_from_pem(private_key.encode('utf-8')) \ + if private_key else None self.email = email self.org = org self.base_url = base_url.rstrip('/') @@ -832,11 +833,11 @@ def set_bot_status(self, status: str | None, title: str, summary: str): if status == "success": conclusion = "success" status = "completed" - elif status == "in_progress": - conclusion = None elif status == "failure": conclusion = "failure" status = "completed" + else: + conclusion = None self._add_checkrun( name='bert-e', status=status, conclusion=conclusion, @@ -846,18 +847,21 @@ def set_bot_status(self, status: str | None, title: str, summary: str): def _add_checkrun( self, name: str, status: str, conclusion: str | None, title: str, summary: str): + data = { + 'name': name, + 'head_sha': self.src_commit, + 'status': status, + 'output': { + 'title': title, + 'summary': summary, + }, + } + if conclusion is not None: + data['conclusion'] = conclusion + LOG.debug(data) return CheckRun.create( client=self.client, - data={ - 'name': name, - 'head_sha': self.src_commit, - 'status': status, - 'conclusion': conclusion, - 'output': { - 'title': title, - 'summary': summary, - }, - }, + data=data, owner=self.repo.owner, repo=self.repo.slug ) diff --git a/bert_e/git_host/github/schema.py b/bert_e/git_host/github/schema.py index 591a2db2..81e287ca 100644 --- a/bert_e/git_host/github/schema.py +++ b/bert_e/git_host/github/schema.py @@ -111,7 +111,7 @@ class AggregateCheckSuites(GitHubSchema): class Output(GitHubSchema): title = fields.Str() summary = fields.Str() - text = fields.Str() + text = fields.Str(allow_none=True) class CheckRun(GitHubSchema): diff --git a/bert_e/tests/test_bert_e.py b/bert_e/tests/test_bert_e.py index 68c80769..26721d4a 100644 --- a/bert_e/tests/test_bert_e.py +++ b/bert_e/tests/test_bert_e.py @@ -4797,7 +4797,7 @@ def test_set_bot_status(self): pr.src_commit, key="bert-e") == "failure" self.handle(pr.id, settings=settings, options=["bypass_jira_check"]) assert self.get_build_status( - pr.src_commit, key="bert-e") == "in_progress" + pr.src_commit, key="bert-e") == "queued" self.handle(pr.id, settings=settings, options=self.bypass_all) diff --git a/bert_e/tests/unit/test_github_app_auth.py b/bert_e/tests/unit/test_github_app_auth.py index f4ad7110..a1023cce 100644 --- a/bert_e/tests/unit/test_github_app_auth.py +++ b/bert_e/tests/unit/test_github_app_auth.py @@ -22,7 +22,7 @@ def client_app(): serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption() - ), + ).decode('utf-8'), base_url="http://localhost:4010", accept_header="application/json" ) diff --git a/bert_e/workflow/pr_utils.py b/bert_e/workflow/pr_utils.py index e8b69fb7..0f66ce17 100644 --- a/bert_e/workflow/pr_utils.py +++ b/bert_e/workflow/pr_utils.py @@ -87,8 +87,8 @@ def _send_comment(settings, pull_request: AbstractPullRequest, msg: str, def _send_bot_status(settings, pull_request: AbstractPullRequest, comment: exceptions.TemplateException): """Post the bot status in a pull request.""" - if settings.send_bot_status is False: - LOG.debug("Not sending bot status (send_bot_status==False)") + if settings.send_bot_status is False or comment.status is None: + LOG.debug("No need to send bot status") return LOG.info(f"Setting bot status to {comment.status} as {comment.title}") pull_request.set_bot_status( diff --git a/tox.ini b/tox.ini index 936eccbb..5636c105 100644 --- a/tox.ini +++ b/tox.ini @@ -81,7 +81,7 @@ setenv = WEBHOOK_LOGIN = {env:WEBHOOK_LOGIN:'webhook'} WEBHOOK_PWD = {env:WEBHOOK_PWD:'webhook'} -commands = bert-e-serve -v -f {env:BERT_E_SETTINGS:'settings.yml'} +commands = bert-e-serve -v -f {env:BERT_E_SETTINGS:'settings.yml'} -p 8000 [testenv:tests-githost] passenv = BERT_E_* From 84808f96cf1b4d704176d66a450cd909af9b602e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:45:34 +0000 Subject: [PATCH 08/10] github-actions(deps): bump codecov/codecov-action from 4.0.1 to 4.3.0 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.0.1 to 4.3.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.0.1...v4.3.0) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/main.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7696c0bf..fcb28f99 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -33,7 +33,7 @@ jobs: - run: tox -e coverage-report - run: tox -e tests-server - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v4.3.0 with: token: ${{ secrets.CODECOV_TOKEN }} slug: ${{ github.repository }} @@ -55,7 +55,7 @@ jobs: run: pip install tox - run: tox -e tests-noqueue - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v4.3.0 with: token: ${{ secrets.CODECOV_TOKEN }} slug: ${{ github.repository }} @@ -77,7 +77,7 @@ jobs: run: pip install tox - run: tox -e tests - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v4.3.0 with: token: ${{ secrets.CODECOV_TOKEN }} slug: ${{ github.repository }} From c2ba767e7ec25fd6a86845ec667349d569d3bda4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 11:27:08 -0700 Subject: [PATCH 09/10] github-actions(deps): bump codecov/codecov-action from 4.3.0 to 4.3.1 (#181) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.3.0...v4.3.1) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/main.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fcb28f99..a7fe46fd 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -33,7 +33,7 @@ jobs: - run: tox -e coverage-report - run: tox -e tests-server - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.3.1 with: token: ${{ secrets.CODECOV_TOKEN }} slug: ${{ github.repository }} @@ -55,7 +55,7 @@ jobs: run: pip install tox - run: tox -e tests-noqueue - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.3.1 with: token: ${{ secrets.CODECOV_TOKEN }} slug: ${{ github.repository }} @@ -77,7 +77,7 @@ jobs: run: pip install tox - run: tox -e tests - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.3.1 with: token: ${{ secrets.CODECOV_TOKEN }} slug: ${{ github.repository }} From b908588866033f4e76625893c7374f6596d9fe56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 11:27:25 -0700 Subject: [PATCH 10/10] Bump jinja2 from 3.1.2 to 3.1.4 (#180) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.4. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.4) --- updated-dependencies: - dependency-name: jinja2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 94635672..42d25672 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ Flask==2.2.3 Flask-Markdown==0.3 Flask-WTF==1.0.1 ItsDangerous==2.1.2 -Jinja2==3.1.2 +Jinja2==3.1.4 jira==2.0.0 Markdown==2.6.11 marshmallow==3.20.1