From 09c65a0831098f711c24bcd115d52b8c5119a0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bobot?= Date: Tue, 21 May 2024 14:08:12 +0200 Subject: [PATCH] [CI] Separate COMMENT from main --- .github/workflows/comment.yml | 37 +++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 20 +------------------ smtcomp/main.py | 6 ++---- 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/comment.yml diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml new file mode 100644 index 00000000..cf03411d --- /dev/null +++ b/.github/workflows/comment.yml @@ -0,0 +1,37 @@ +name: Comment + +on: + pull_request_target: + paths: + - submissions/*.json + + comment: + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Set up the environment + uses: ./.github/actions/setup-poetry-env + + - name: Compute changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + submissions/*.json + + - name: Show changed files + run: | + poetry run smtcomp show --into-comment-file comment.md ${{ steps.changed-files.outputs.all_changed_files }} + + - name: PR comment with file + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: comment.md + comment_tag: summary diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c13f701..2270c305 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,7 @@ on: push: branches: - main - pull_request_target: - types: [opened, synchronize, reopened] + pull_request: jobs: quality: @@ -22,23 +21,6 @@ jobs: - name: Set up the environment uses: ./.github/actions/setup-poetry-env - - name: Compute changed files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: | - submissions/*.json - - - name: Show changed files - run: | - poetry run smtcomp show --into-comment-file comment.md ${{ steps.changed-files.outputs.all_changed_files }} - - - name: PR comment with file - uses: thollander/actions-comment-pull-request@v2 - with: - filePath: comment.md - comment_tag: summary - - name: Run checks run: make check diff --git a/smtcomp/main.py b/smtcomp/main.py index ab5db1dd..7a588d7f 100644 --- a/smtcomp/main.py +++ b/smtcomp/main.py @@ -65,10 +65,8 @@ def read_submission(file: Path) -> defs.Submission: console.print("") if into_comment_file is not None: - if len(l) > 0: - into_comment_file.write_text(console.export_text()) - else: - into_comment_file.write_text("") + into_comment_file.write_text(console.export_text()) + @app.command() def validate(file: str) -> None: