From 53a00c06afd1f54e7781b26603a11efa08736f1b Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:09:42 +0100 Subject: [PATCH 01/18] make it always succeed --- .github/workflows/on_comment.yaml | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/on_comment.yaml diff --git a/.github/workflows/on_comment.yaml b/.github/workflows/on_comment.yaml new file mode 100644 index 000000000..dc9177474 --- /dev/null +++ b/.github/workflows/on_comment.yaml @@ -0,0 +1,35 @@ +name: Build PDF +run-name: Build PDF + +on: + pull_request_comment +permissions: + contents: write + +jobs: + build-pdf: + name: Format + runs-on: ubuntu-latest + if: github.event.issue.pull_request != '' && github.event.comment.body == 'format!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') + steps: + - uses: actions/checkout@v4 + + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt update + sudo apt install \ + pre-commit + pip install identify --upgrade + pre-commit install + + - name: Run pre-commit on all files + run: pre-commit run --all --color always --verbose || true + + - name: Add to PDF to repo + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m 'fix format' + git push origin ${{ github.ref }} From eaeaabdf45bbc41fc400994a160a06abe2b983f8 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:13:23 +0100 Subject: [PATCH 02/18] change workflow names --- .github/workflows/on_comment.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on_comment.yaml b/.github/workflows/on_comment.yaml index dc9177474..d3f15ff53 100644 --- a/.github/workflows/on_comment.yaml +++ b/.github/workflows/on_comment.yaml @@ -1,5 +1,5 @@ -name: Build PDF -run-name: Build PDF +name: On Comment +run-name: On Comment on: pull_request_comment @@ -7,7 +7,7 @@ permissions: contents: write jobs: - build-pdf: + Format: name: Format runs-on: ubuntu-latest if: github.event.issue.pull_request != '' && github.event.comment.body == 'format!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') From bf7cfc32f6a49a963f07121b94afe189b92f5371 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:15:43 +0100 Subject: [PATCH 03/18] change trigger --- .github/workflows/on_comment.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on_comment.yaml b/.github/workflows/on_comment.yaml index d3f15ff53..6b3cffeb4 100644 --- a/.github/workflows/on_comment.yaml +++ b/.github/workflows/on_comment.yaml @@ -2,7 +2,9 @@ name: On Comment run-name: On Comment on: - pull_request_comment + pull_request: + types: + - comment permissions: contents: write From af25b6739db955b79fc7988d0c015244df0d8c53 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:39:29 +0100 Subject: [PATCH 04/18] use label instead of comment --- .github/workflows/on_comment.yaml | 37 ----------------- .github/workflows/static_checks.yaml | 61 ++++++++++++++++++---------- 2 files changed, 39 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/on_comment.yaml diff --git a/.github/workflows/on_comment.yaml b/.github/workflows/on_comment.yaml deleted file mode 100644 index 6b3cffeb4..000000000 --- a/.github/workflows/on_comment.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: On Comment -run-name: On Comment - -on: - pull_request: - types: - - comment -permissions: - contents: write - -jobs: - Format: - name: Format - runs-on: ubuntu-latest - if: github.event.issue.pull_request != '' && github.event.comment.body == 'format!' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') - steps: - - uses: actions/checkout@v4 - - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt update - sudo apt install \ - pre-commit - pip install identify --upgrade - pre-commit install - - - name: Run pre-commit on all files - run: pre-commit run --all --color always --verbose || true - - - name: Add to PDF to repo - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git add . - git commit -m 'fix format' - git push origin ${{ github.ref }} diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 07f577624..8194788cd 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -1,12 +1,41 @@ name: Static checks run-name: Static checks - on: pull_request: types: [opened, synchronize] + +permissions: + contents: write jobs: + pre-commit-run: + name: Pre-commit run + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt update + sudo apt install \ + pre-commit + pip install identify --upgrade + pre-commit install + - name: Run pre-commit on all files + run: pre-commit run --all --color always --verbose + - name: Commit clang-tidy-fixes + if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix' && failure() )}} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m 'fix format' + git push origin ${{ github.ref }} + - name: check for todo fixme note + run: | + NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)" + echo "Found $NTODOS TODO DONT MERGE notes" + ! grep -q -r "TODO DONT MERGE" --exclude-dir=.github build-compilation-db: - if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-build')}} + if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-build') }} name: Build with IWYU runs-on: ubuntu-latest steps: @@ -88,7 +117,14 @@ jobs: | grep -F -f pattern - > files # run clang-tidy on all specified files clang-tidy-16 --fix --extra-arg=-w -p build/develop $(cat files) - + - name: Commit clang-tidy-fixes + if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix')}} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m 'fix format' + git push origin ${{ github.ref }} - name: Check for fixes run: | if [[ $(git ls-files -m | wc -l) -eq 0 ]]; then @@ -98,25 +134,6 @@ jobs: echo "Please use your local clang-tidy or apply the following patch:" git diff -p exit 1 - pre-commit-run: - name: Pre-commit run - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt update - sudo apt install \ - pre-commit - pip install identify --upgrade - pre-commit install - - name: Run pre-commit on all files - run: pre-commit run --all --color always --verbose - - name: check for todo fixme note - run: | - NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)" - echo "Found $NTODOS TODO DONT MERGE notes" - ! grep -q -r "TODO DONT MERGE" --exclude-dir=.github changelog: if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-Changelog')}} name: Changelog check From 7b34dec833e7d7ae29ae76f2cc71afd8fec2bacd Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:48:55 +0100 Subject: [PATCH 05/18] trigger if labeled --- .github/workflows/static_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 8194788cd..11dae18ee 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -2,7 +2,7 @@ name: Static checks run-name: Static checks on: pull_request: - types: [opened, synchronize] + types: [opened,synchronize,labeled] permissions: contents: write From 9319924c6c7c8511ce25fc52556f7272af3b4d96 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:53:55 +0100 Subject: [PATCH 06/18] move to end --- .github/workflows/static_checks.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 11dae18ee..36aae8c7f 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -117,14 +117,6 @@ jobs: | grep -F -f pattern - > files # run clang-tidy on all specified files clang-tidy-16 --fix --extra-arg=-w -p build/develop $(cat files) - - name: Commit clang-tidy-fixes - if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix')}} - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git add . - git commit -m 'fix format' - git push origin ${{ github.ref }} - name: Check for fixes run: | if [[ $(git ls-files -m | wc -l) -eq 0 ]]; then @@ -134,6 +126,14 @@ jobs: echo "Please use your local clang-tidy or apply the following patch:" git diff -p exit 1 + - name: Commit clang-tidy-fixes + if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure()}} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m 'fix format' + git push origin ${{ github.ref }} changelog: if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-Changelog')}} name: Changelog check From 58703be6edc243dac1ba5c7d8bc08c3fc9801c42 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 10:54:59 +0100 Subject: [PATCH 07/18] add format error for test --- .github/workflows/static_checks.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 36aae8c7f..380311164 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -3,7 +3,8 @@ run-name: Static checks on: pull_request: types: [opened,synchronize,labeled] - +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} permissions: contents: write jobs: @@ -12,6 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{env.BRANCH_NAME}} - name: Install dependencies run: | sudo apt update @@ -21,14 +24,14 @@ jobs: pre-commit install - name: Run pre-commit on all files run: pre-commit run --all --color always --verbose - - name: Commit clang-tidy-fixes - if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix' && failure() )}} + - name: Commit pre-commit fixes + if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure()}} run: | git config user.name github-actions git config user.email github-actions@github.com git add . git commit -m 'fix format' - git push origin ${{ github.ref }} + git push origin ${{env.BRANCH_NAME}} - name: check for todo fixme note run: | NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)" From 28699109b49ddbec88f19a93f004d56aad2e922b Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 11:27:47 +0100 Subject: [PATCH 08/18] change bot message --- .github/workflows/build_doc.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_doc.yaml b/.github/workflows/build_doc.yaml index b04147d2b..b741c309a 100644 --- a/.github/workflows/build_doc.yaml +++ b/.github/workflows/build_doc.yaml @@ -56,7 +56,9 @@ jobs: uses: thollander/actions-comment-pull-request@v2 with: message: | - Deployed test documentation to https://exasim-project.com/NeoFOAM/Build_PR_${{ env.PR_NUMBER }} + Thank you for your PR, here are some useful tips: + - Use labels to change the workflow behavior. Set `auto-fix` to automatically apply fixes, `full-ci` for a comprehensive set of tests and sanitizer runs, `ready-for-review` to show that you're done and need a review. + - I deployed a test documentation to https://exasim-project.com/NeoFOAM/Build_PR_${{ env.PR_NUMBER }} comment_tag: build_url - name: Echo Build PR URL From 7b8b0300b6548a039bd32b43615f28eb5e20356e Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 11:41:04 +0100 Subject: [PATCH 09/18] check if clang-tidy auto-fix works --- include/NeoFOAM/dsl/coeff.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/NeoFOAM/dsl/coeff.hpp b/include/NeoFOAM/dsl/coeff.hpp index a64175680..c249adb6d 100644 --- a/include/NeoFOAM/dsl/coeff.hpp +++ b/include/NeoFOAM/dsl/coeff.hpp @@ -56,9 +56,9 @@ class Coeff [[nodiscard]] inline Coeff operator*(const Coeff& lhs, const Coeff& rhs) { - Coeff result = lhs; - result *= rhs; - return result; + Coeff Result = lhs; + Result *= rhs; + return Result; } namespace detail From 0d109f02002a642bd17c777ac72cea86c088355c Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 11:43:26 +0100 Subject: [PATCH 10/18] add label to documentation --- doc/contributing.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/contributing.rst b/doc/contributing.rst index 8e3b55768..065a68552 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -67,7 +67,8 @@ The following labels and their meaning are discussed here: * ``Skip-Changelog``: Don't check whether the changelog has been updated. Use this label if the changes are not any new features or bug-fixes. * ``Skip-build``: Don't run any build steps, including building the compile commands database. * ``Skip-cache``: Don't cache the build folders. Forces to rebuild the build folder after every push to GitHub. - * ``full-ci``: Run tests on AWS. + * ``full-ci``: Run tests on AWS and enable sanitizer workflows. + * ``auto-fix``: Apply changes from pre-commit and clang-tidy. A full list of the labels can be found `here `_. From 43e7ac605c0e3b676a775bdafb82149683479b76 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 11:54:55 +0100 Subject: [PATCH 11/18] check if clang-tidy auto-fix works --- .github/workflows/static_checks.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 380311164..b17edb490 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -87,6 +87,8 @@ jobs: needs: [build-compilation-db] steps: - uses: actions/checkout@v4 + with: + ref: ${{env.BRANCH_NAME}} - name: Add clang repo run: | @@ -136,7 +138,7 @@ jobs: git config user.email github-actions@github.com git add . git commit -m 'fix format' - git push origin ${{ github.ref }} + git push origin ${{ github.BRANCH_NAME }} changelog: if: ${{!contains(github.event.pull_request.labels.*.name, 'Skip-Changelog')}} name: Changelog check From 70c191cd3983bf3a4cde94c8ee69e724d5033ee3 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 12:08:19 +0100 Subject: [PATCH 12/18] dont commit workflow files --- .github/workflows/build_doc.yaml | 1 + .github/workflows/static_checks.yaml | 1 + .gitignore | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/build_doc.yaml b/.github/workflows/build_doc.yaml index b741c309a..12aaa659c 100644 --- a/.github/workflows/build_doc.yaml +++ b/.github/workflows/build_doc.yaml @@ -59,6 +59,7 @@ jobs: Thank you for your PR, here are some useful tips: - Use labels to change the workflow behavior. Set `auto-fix` to automatically apply fixes, `full-ci` for a comprehensive set of tests and sanitizer runs, `ready-for-review` to show that you're done and need a review. - I deployed a test documentation to https://exasim-project.com/NeoFOAM/Build_PR_${{ env.PR_NUMBER }} + - If this is your first PR, please add yourself to the AUTHORS.md file comment_tag: build_url - name: Echo Build PR URL diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index b17edb490..116d0be0b 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -134,6 +134,7 @@ jobs: - name: Commit clang-tidy-fixes if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure()}} run: | + rm pattern files git config user.name github-actions git config user.email github-actions@github.com git add . diff --git a/.gitignore b/.gitignore index 0a27bc284..6d8804927 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ NeoFOAM/* _build .vs/ +*.key From 72b183ebc4dc739ed156c2d7bbb37dadf4d602d6 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 12:47:54 +0100 Subject: [PATCH 13/18] check for specific failure --- .github/workflows/static_checks.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 116d0be0b..30957d96e 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -23,9 +23,10 @@ jobs: pip install identify --upgrade pre-commit install - name: Run pre-commit on all files + id: pre-commit run: pre-commit run --all --color always --verbose - name: Commit pre-commit fixes - if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure()}} + if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure() && steps.pre-commit.conclusion == 'failure'}} run: | git config user.name github-actions git config user.email github-actions@github.com @@ -123,6 +124,7 @@ jobs: # run clang-tidy on all specified files clang-tidy-16 --fix --extra-arg=-w -p build/develop $(cat files) - name: Check for fixes + id: tidy-fixes run: | if [[ $(git ls-files -m | wc -l) -eq 0 ]]; then exit 0 @@ -132,7 +134,7 @@ jobs: git diff -p exit 1 - name: Commit clang-tidy-fixes - if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure()}} + if: ${{contains(github.event.pull_request.labels.*.name, 'auto-fix') && failure() && steps.tidy-fixes.conclusion == 'failure'}} run: | rm pattern files git config user.name github-actions From d437b4dd98ac2a7c2ecfa3aafa389e4d443297d6 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Mon, 13 Jan 2025 14:10:37 +0100 Subject: [PATCH 14/18] try to create if not existing comment --- .github/workflows/build_doc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_doc.yaml b/.github/workflows/build_doc.yaml index 12aaa659c..a8088170e 100644 --- a/.github/workflows/build_doc.yaml +++ b/.github/workflows/build_doc.yaml @@ -61,6 +61,7 @@ jobs: - I deployed a test documentation to https://exasim-project.com/NeoFOAM/Build_PR_${{ env.PR_NUMBER }} - If this is your first PR, please add yourself to the AUTHORS.md file comment_tag: build_url + mode: createIfNotExists - name: Echo Build PR URL run: | From 0907ce6c4ae831ef55244f69693aab2913d71070 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 13 Jan 2025 13:20:59 +0000 Subject: [PATCH 15/18] fix format --- include/NeoFOAM/dsl/coeff.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/NeoFOAM/dsl/coeff.hpp b/include/NeoFOAM/dsl/coeff.hpp index c249adb6d..a64175680 100644 --- a/include/NeoFOAM/dsl/coeff.hpp +++ b/include/NeoFOAM/dsl/coeff.hpp @@ -56,9 +56,9 @@ class Coeff [[nodiscard]] inline Coeff operator*(const Coeff& lhs, const Coeff& rhs) { - Coeff Result = lhs; - Result *= rhs; - return Result; + Coeff result = lhs; + result *= rhs; + return result; } namespace detail From a999de061cfa31bf86a8037c5f1f96e5dc8e60a9 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Tue, 14 Jan 2025 09:30:57 +0100 Subject: [PATCH 16/18] comment only if no previous comment exists --- .github/workflows/build_doc.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build_doc.yaml b/.github/workflows/build_doc.yaml index a8088170e..4bf529c0f 100644 --- a/.github/workflows/build_doc.yaml +++ b/.github/workflows/build_doc.yaml @@ -52,8 +52,17 @@ jobs: with: folder: docs_build target-folder: latest + + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + - name: Comment PR uses: thollander/actions-comment-pull-request@v2 + if: steps.fc.outputs.comment-id == '' with: message: | Thank you for your PR, here are some useful tips: From cd0a7627015f7390051fb011653991c9c8c2e269 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Tue, 14 Jan 2025 09:35:25 +0100 Subject: [PATCH 17/18] empty trigger ci From 09aa35b0d1abb8bf3934d5e83823fd122e08e093 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Thu, 16 Jan 2025 18:58:57 +0100 Subject: [PATCH 18/18] refere to benchmark data repo --- .github/workflows/build_doc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_doc.yaml b/.github/workflows/build_doc.yaml index 4bf529c0f..82356d765 100644 --- a/.github/workflows/build_doc.yaml +++ b/.github/workflows/build_doc.yaml @@ -68,6 +68,7 @@ jobs: Thank you for your PR, here are some useful tips: - Use labels to change the workflow behavior. Set `auto-fix` to automatically apply fixes, `full-ci` for a comprehensive set of tests and sanitizer runs, `ready-for-review` to show that you're done and need a review. - I deployed a test documentation to https://exasim-project.com/NeoFOAM/Build_PR_${{ env.PR_NUMBER }} + - For `full-ci` builds benchmark results are available at https://github.com/exasim-project/NeoFOAM-BenchmarkData/${{ env.PR_NUMBER }} - If this is your first PR, please add yourself to the AUTHORS.md file comment_tag: build_url mode: createIfNotExists