From c58cf15565296148c2a4ca98c721561bf4c4f40d Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:27:19 -0500 Subject: [PATCH 1/9] hotfix: don't upload results on push --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ec7e851..f426e60c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,6 +75,7 @@ jobs: if: success() || failure() - name: Publish coverage report + if: ${{ github.event_name == 'pull_request' }} uses: orgoro/coverage@v3 with: coverageFile: coverage.xml From 7f99fa3da8afee007bd6714862493fab2889b0ab Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:30:39 -0500 Subject: [PATCH 2/9] Update ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f426e60c..ef3c5e56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,8 @@ jobs: permissions: issues: write pull-requests: write + statuses: write + checks: write runs-on: ubuntu-latest strategy: matrix: From c2f86f6934a76b6522d0350a5820c72d92547300 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:34:11 -0500 Subject: [PATCH 3/9] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef3c5e56..e22c6178 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,7 @@ jobs: pull-requests: write statuses: write checks: write + comments: write runs-on: ubuntu-latest strategy: matrix: From 185429287e768c74a8f1683e44506a314536d32c Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:35:46 -0500 Subject: [PATCH 4/9] Update ci.yml --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e22c6178..645a8160 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,8 @@ jobs: pull-requests: write statuses: write checks: write - comments: write + contents: write + actions: read runs-on: ubuntu-latest strategy: matrix: From 81de438569421ee26915b5be3fced995284c7ff9 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:41:44 -0500 Subject: [PATCH 5/9] try something new --- .github/workflows/ci.yml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 645a8160..98978970 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,12 +43,13 @@ jobs: test: permissions: - issues: write + # Gives the action the necessary permissions for publishing new + # comments in pull requests. pull-requests: write - statuses: write - checks: write + # Gives the action the necessary permissions for pushing data to the + # python-coverage-comment-action branch, and for editing existing + # comments (to avoid publishing multiple comments in the same PR) contents: write - actions: read runs-on: ubuntu-latest strategy: matrix: @@ -78,9 +79,17 @@ jobs: coverage xml if: success() || failure() - - name: Publish coverage report - if: ${{ github.event_name == 'pull_request' }} - uses: orgoro/coverage@v3 + - name: Coverage comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 with: - coverageFile: coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} + + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v3 + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + # If you use a different name, update COMMENT_ARTIFACT_NAME accordingly + name: python-coverage-comment-action + # If you use a different name, update COMMENT_FILENAME accordingly + path: python-coverage-comment-action.txt From 7a9c6a52fa6a3455e202e36d518af2350224fb33 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:49:07 -0500 Subject: [PATCH 6/9] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98978970..e6cb82c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: - name: Run unittest tests with coverage run: | - pytest --cov=autogpt --without-integration --without-slow-integration + pytest --cov=autogpt --without-integration --without-slow-integration --cov-report term-missing --cov-branch --cov-report xml --cov-report term - name: Generate coverage report run: | From a63fc643c8dce5d956682d087674d803d7688f08 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 00:55:52 -0500 Subject: [PATCH 7/9] fix:? --- .coveragerc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..05986577 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +relative_files = true \ No newline at end of file From 68803d559ce95e9d3b5662d7128d3dedc25b6555 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 01:00:02 -0500 Subject: [PATCH 8/9] comment the stuff --- .github/workflows/coverage.yml | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 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..b4ee5ea3 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,36 @@ +# .github/workflows/coverage.yml +name: Post coverage comment + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + test: + name: Run tests & display coverage + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + permissions: + # Gives the action the necessary permissions for publishing new + # comments in pull requests. + pull-requests: write + # Gives the action the necessary permissions for editing existing + # comments (to avoid publishing multiple comments in the same PR) + contents: write + # Gives the action the necessary permissions for looking up the + # workflow that launched this workflow, and download the related + # artifact that contains the comment to be published + actions: read + steps: + # DO NOT run actions/checkout here, for security reasons + # For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ + - name: Post comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} + # Update those if you changed the default values: + # COMMENT_ARTIFACT_NAME: python-coverage-comment-action + # COMMENT_FILENAME: python-coverage-comment-action.txt \ No newline at end of file From 3dd07d311997be5e142f4f948485c66fc8f0fe9c Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 21 Apr 2023 01:02:10 -0500 Subject: [PATCH 9/9] fix: workflow name --- .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b4ee5ea3..5dc9b7bd 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -3,7 +3,7 @@ name: Post coverage comment on: workflow_run: - workflows: ["CI"] + workflows: ["Python CI"] types: - completed @@ -33,4 +33,4 @@ jobs: GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} # Update those if you changed the default values: # COMMENT_ARTIFACT_NAME: python-coverage-comment-action - # COMMENT_FILENAME: python-coverage-comment-action.txt \ No newline at end of file + # COMMENT_FILENAME: python-coverage-comment-action.txt