From ac0d74181605de2288e46b5e51319cdcb666fc59 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Sat, 22 Nov 2025 19:19:45 +0100 Subject: [PATCH 01/27] new file change branch pwd Enhance hello world step with directory listing new file --- .github/workflows/mg5_ghci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/mg5_ghci.yml diff --git a/.github/workflows/mg5_ghci.yml b/.github/workflows/mg5_ghci.yml new file mode 100644 index 0000000000..efa4b34575 --- /dev/null +++ b/.github/workflows/mg5_ghci.yml @@ -0,0 +1,15 @@ +name: ghci + +on: + push: + branches: ghci + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: hello world + run: echo hello world && echo `pwd` && echo `ls` From 339c58c9504b0b5b6766f6be74fe6281ea01f26d Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 26 Nov 2025 14:32:04 +0100 Subject: [PATCH 02/27] update submodule fix process move ci file update submodule --- .github/workflows/mg5_codegen.yml | 102 ++++++++++++++++++++++++++++++ .github/workflows/mg5_ghci.yml | 15 ----- test/processes/pp_ttx/launch.mg5 | 6 ++ test/processes/pp_ttx/output.mg5 | 2 + 4 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/mg5_codegen.yml delete mode 100644 .github/workflows/mg5_ghci.yml create mode 100644 test/processes/pp_ttx/launch.mg5 create mode 100644 test/processes/pp_ttx/output.mg5 diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml new file mode 100644 index 0000000000..5cbd0f0952 --- /dev/null +++ b/.github/workflows/mg5_codegen.yml @@ -0,0 +1,102 @@ +name: Code Generator CI + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + generate-and-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout codegen repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run code generator + run: | + chmod +x codegen.sh + ./codegen.sh + + - name: Check code format with clang-format + id: format-check + run: | + # Find all generated C/C++ files (adjust pattern as needed) + find . -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) > files.txt + + # Run clang-format check + if clang-format --dry-run --Werror $(cat files.txt) 2>&1 | tee format-output.txt; then + echo "format_ok=true" >> $GITHUB_OUTPUT + echo "✅ Code is properly formatted" + else + echo "format_ok=false" >> $GITHUB_OUTPUT + echo "❌ Code needs formatting" + + # Generate the diff for needed changes + clang-format -i $(cat files.txt) + git diff > format-changes.patch + fi + + - name: Commit to target repository + if: steps.format-check.outputs.format_ok == 'true' + env: + TARGET_REPO: your-username/target-repo # Change this + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Or use a PAT: secrets.TARGET_REPO_PAT + run: | + # Configure git + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # Clone target repo + git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git target-repo + cd target-repo + + # Create branch based on PR number + BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" + git checkout -b ${BRANCH_NAME} + + # Copy generated files (adjust paths as needed) + cp -r ../generated-output/* . + + # Commit and push + git add . + git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" \ + -m "Source PR: ${{ github.event.pull_request.html_url }}" + git push origin ${BRANCH_NAME} + + echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" + + - name: Comment on PR with format issues + if: steps.format-check.outputs.format_ok == 'false' + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const patch = fs.readFileSync('format-changes.patch', 'utf8'); + + const comment = `## ❌ Code Format Check Failed + + The generated code does not conform to clang-format rules. + +
+ Required formatting changes + + \`\`\`diff + ${patch} + \`\`\` + +
+ + Please update your code generator to produce properly formatted code.`; + + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment + }); + + - name: Fail if format check failed + if: steps.format-check.outputs.format_ok == 'false' + run: exit 1 diff --git a/.github/workflows/mg5_ghci.yml b/.github/workflows/mg5_ghci.yml deleted file mode 100644 index efa4b34575..0000000000 --- a/.github/workflows/mg5_ghci.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: ghci - -on: - push: - branches: ghci - -jobs: - test: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: hello world - run: echo hello world && echo `pwd` && echo `ls` diff --git a/test/processes/pp_ttx/launch.mg5 b/test/processes/pp_ttx/launch.mg5 new file mode 100644 index 0000000000..2acf6a78e1 --- /dev/null +++ b/test/processes/pp_ttx/launch.mg5 @@ -0,0 +1,6 @@ +launch PROC_pp_ttx +set vector_size 32 +set nevents 25k +set sde_strategy 1 +set gridpack True + diff --git a/test/processes/pp_ttx/output.mg5 b/test/processes/pp_ttx/output.mg5 new file mode 100644 index 0000000000..0299c86959 --- /dev/null +++ b/test/processes/pp_ttx/output.mg5 @@ -0,0 +1,2 @@ +generate p p > t t~ +output madevent_simd PROC_pp_ttx From c1967870ffb718110aa13dcaf82adf9e46716708 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Mon, 12 Jan 2026 09:53:58 +0100 Subject: [PATCH 03/27] add py.py --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d59d93cf5c..a8ade725e6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.mod *.pyc *.so +py.py build.* .build.* From dc1e05bff71a423b84dc1f0953ce1fd8a2a375c3 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Mon, 12 Jan 2026 09:54:21 +0100 Subject: [PATCH 04/27] gen one process pwd pwd pwd mg5 fetch submodules disable all processes, generate first process fix remote repo fix typo generate one process --- .github/workflows/mg5_codegen.yml | 8 +++++--- ...lprocesses.yml => testsuite_allprocesses.yml.disabled} | 0 2 files changed, 5 insertions(+), 3 deletions(-) rename .github/workflows/{testsuite_allprocesses.yml => testsuite_allprocesses.yml.disabled} (100%) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 5cbd0f0952..182e39f672 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -13,15 +13,17 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + submodules: true - name: Run code generator run: | - chmod +x codegen.sh - ./codegen.sh + if [ ! -e MG5aMC/mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT ] ; then pushd MG5aMC/mg5amcnlo/PLUGIN/ && ln -s ../../../epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT && popd ; fi + ./MG5aMC/mg5amcnlo/bin/mg5_aMC test/processes/pp_ttx/output.mg5 - name: Check code format with clang-format id: format-check run: | + cd PROC_pp_ttx # Find all generated C/C++ files (adjust pattern as needed) find . -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) > files.txt @@ -41,7 +43,7 @@ jobs: - name: Commit to target repository if: steps.format-check.outputs.format_ok == 'true' env: - TARGET_REPO: your-username/target-repo # Change this + TARGET_REPO: roiser/madgraph4gpu-generated-processes GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Or use a PAT: secrets.TARGET_REPO_PAT run: | # Configure git diff --git a/.github/workflows/testsuite_allprocesses.yml b/.github/workflows/testsuite_allprocesses.yml.disabled similarity index 100% rename from .github/workflows/testsuite_allprocesses.yml rename to .github/workflows/testsuite_allprocesses.yml.disabled From f47c8ff94154fabcac231c1dfcc34ca25ca30962 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Mon, 12 Jan 2026 10:49:32 +0100 Subject: [PATCH 05/27] copy files over move to PAT empty add pwd add git status spell out repo fix repo name more debug go one level up copy files over --- .github/workflows/mg5_codegen.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 182e39f672..ef28ac49d8 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -44,27 +44,43 @@ jobs: if: steps.format-check.outputs.format_ok == 'true' env: TARGET_REPO: roiser/madgraph4gpu-generated-processes - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Or use a PAT: secrets.TARGET_REPO_PAT + GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} ## ${{ secrets.GITHUB_TOKEN }} # Or use a PAT: secrets.TARGET_REPO_PAT + persist-credentials: true run: | + cd .. # Configure git - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions" + git config --global user.email "github-actions@users.noreply.github.com" # Clone target repo - git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git target-repo - cd target-repo + git clone https://x-access-token:${{ secrets.PAT_FOR_PUSH }}@github.com/roiser/madgraph4gpu-generated-processes.git + #git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git target-repo + cd madgraph4gpu-generated-processes + + echo git status + git status # Create branch based on PR number BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" git checkout -b ${BRANCH_NAME} # Copy generated files (adjust paths as needed) - cp -r ../generated-output/* . - + cp -r ${GITHUB_WORKSPACE}/PROC_pp_ttx . + # Commit and push git add . git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" \ -m "Source PR: ${{ github.event.pull_request.html_url }}" + + echo git status + git status + + echo pwd + pwd + + echo git remote -v + git remote -v + git push origin ${BRANCH_NAME} echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" From 17c9d4dc6a78a7967e3f3b50bccbceccadc50ead Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Mon, 12 Jan 2026 15:59:06 +0100 Subject: [PATCH 06/27] move to new token remove persist credentials change pat name add ls remove if, single line commit simplify ci pat in local repo use PAT as a token --- .github/workflows/mg5_codegen.yml | 61 ++++++++++++++++++------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index ef28ac49d8..0d72e49324 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -25,10 +25,11 @@ jobs: run: | cd PROC_pp_ttx # Find all generated C/C++ files (adjust pattern as needed) - find . -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) > files.txt + find . -type f \( -name "*.cc" -o -name "*.h" \) > files.txt # Run clang-format check - if clang-format --dry-run --Werror $(cat files.txt) 2>&1 | tee format-output.txt; then + if find . -name '*.cc' -o -name '*.h' | xargs -n1 clang-format -style=file -assume-filename={} {} | diff -u {} -; then + #if clang-format --dry-run --Werror $(cat files.txt) 2>&1 | tee format-output.txt; then echo "format_ok=true" >> $GITHUB_OUTPUT echo "✅ Code is properly formatted" else @@ -41,49 +42,57 @@ jobs: fi - name: Commit to target repository - if: steps.format-check.outputs.format_ok == 'true' + # if: steps.format-check.outputs.format_ok == 'true' env: TARGET_REPO: roiser/madgraph4gpu-generated-processes GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} ## ${{ secrets.GITHUB_TOKEN }} # Or use a PAT: secrets.TARGET_REPO_PAT - persist-credentials: true + #persist-credentials: true run: | - cd .. # Configure git git config --global user.name "github-actions" git config --global user.email "github-actions@users.noreply.github.com" # Clone target repo - git clone https://x-access-token:${{ secrets.PAT_FOR_PUSH }}@github.com/roiser/madgraph4gpu-generated-processes.git - #git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git target-repo + #git clone https://x-access-token:${{ secrets.PAT_FOR_PUSH }}@github.com/roiser/madgraph4gpu-generated-processes.git + git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git cd madgraph4gpu-generated-processes - echo git status - git status + touch foo + git add foo + git commit -m "Initial commit" -a + git push origin main + + # echo ls + # ls + + # echo git status + # git status - # Create branch based on PR number - BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" - git checkout -b ${BRANCH_NAME} + # # Create branch based on PR number + # BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" + # git checkout -b ${BRANCH_NAME} - # Copy generated files (adjust paths as needed) - cp -r ${GITHUB_WORKSPACE}/PROC_pp_ttx . + # # Copy generated files (adjust paths as needed) + # cp -r ${GITHUB_WORKSPACE}/PROC_pp_ttx . - # Commit and push - git add . - git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" \ - -m "Source PR: ${{ github.event.pull_request.html_url }}" + # # Commit and push + # git add . + # git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" + # # \ + # # -m "Source PR: ${{ github.event.pull_request.html_url }}" - echo git status - git status + # echo git status + # git status - echo pwd - pwd + # echo pwd + # pwd - echo git remote -v - git remote -v + # echo git remote -v + # git remote -v - git push origin ${BRANCH_NAME} + # git push origin ${BRANCH_NAME} - echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" + # echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" - name: Comment on PR with format issues if: steps.format-check.outputs.format_ok == 'false' From 753368dd97ebad71f682e82b63fc7ac225ee2c7e Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Mon, 12 Jan 2026 17:42:36 +0100 Subject: [PATCH 07/27] fix clang format --- .github/workflows/mg5_codegen.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 0d72e49324..cc671d24ce 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -28,8 +28,8 @@ jobs: find . -type f \( -name "*.cc" -o -name "*.h" \) > files.txt # Run clang-format check - if find . -name '*.cc' -o -name '*.h' | xargs -n1 clang-format -style=file -assume-filename={} {} | diff -u {} -; then - #if clang-format --dry-run --Werror $(cat files.txt) 2>&1 | tee format-output.txt; then + #if find . -name '*.cc' -o -name '*.h' | xargs -n1 clang-format -style=file -assume-filename={} {} | diff -u {} -; then + if clang-format --dry-run --Werror $(cat files.txt) 2>&1 | tee format-output.txt; then echo "format_ok=true" >> $GITHUB_OUTPUT echo "✅ Code is properly formatted" else From cb08b11bfb97e46f967b3a218e125028bf0601b1 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Mon, 12 Jan 2026 17:45:52 +0100 Subject: [PATCH 08/27] fix commit to remote repo --- .github/workflows/mg5_codegen.yml | 47 ++++++++----------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index cc671d24ce..ac0d7e992d 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -45,54 +45,31 @@ jobs: # if: steps.format-check.outputs.format_ok == 'true' env: TARGET_REPO: roiser/madgraph4gpu-generated-processes - GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} ## ${{ secrets.GITHUB_TOKEN }} # Or use a PAT: secrets.TARGET_REPO_PAT - #persist-credentials: true + GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} run: | # Configure git git config --global user.name "github-actions" git config --global user.email "github-actions@users.noreply.github.com" # Clone target repo - #git clone https://x-access-token:${{ secrets.PAT_FOR_PUSH }}@github.com/roiser/madgraph4gpu-generated-processes.git git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git cd madgraph4gpu-generated-processes - - touch foo - git add foo - git commit -m "Initial commit" -a - git push origin main - - # echo ls - # ls - - # echo git status - # git status - # # Create branch based on PR number - # BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" - # git checkout -b ${BRANCH_NAME} + # Create branch based on PR number + BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" + git checkout -b ${BRANCH_NAME} - # # Copy generated files (adjust paths as needed) - # cp -r ${GITHUB_WORKSPACE}/PROC_pp_ttx . - - # # Commit and push - # git add . - # git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" - # # \ - # # -m "Source PR: ${{ github.event.pull_request.html_url }}" - - # echo git status - # git status - - # echo pwd - # pwd + # Copy generated files (adjust paths as needed) + cp -r ${GITHUB_WORKSPACE}/PROC_pp_ttx . - # echo git remote -v - # git remote -v + # Commit and push + git add . + git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" \ + -m "Source PR: ${{ github.event.pull_request.html_url }}" - # git push origin ${BRANCH_NAME} + git push origin ${BRANCH_NAME} - # echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" + echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" - name: Comment on PR with format issues if: steps.format-check.outputs.format_ok == 'false' From 46f4864a2dd1561dc1663db05cc30460db761899 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 10:36:02 +0100 Subject: [PATCH 09/27] formatting script --- .github/workflows/check-formatting.sh | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 .github/workflows/check-formatting.sh diff --git a/.github/workflows/check-formatting.sh b/.github/workflows/check-formatting.sh new file mode 100755 index 0000000000..e1b40c6f80 --- /dev/null +++ b/.github/workflows/check-formatting.sh @@ -0,0 +1,43 @@ +if [ ! -d "src" ] && [ ! -d "SubProcesses" ]; then + echo "Error: Neither 'src' nor 'SubProcesses' directory exists, script needs to be run from the root directory of a generated process" >&2 + exit 255 +fi + +count=0 +total=0 +files_needing_format=() +patch_file="format-changes.patch" + +# clean patch file if it exists +> "$patch_file" + +echo "" +echo "Checking formatting with clang-format..." +echo "" + +while IFS= read -r file; do + ((total++)) + if ! clang-format --dry-run --Werror "$file" 2>/dev/null; then + echo "=== $file needs formatting ===" + clang-format "$file" | diff -u "$file" - >> "$patch_file" + echo "" >> "$patch_file" + ((count++)) + files_needing_format+=("$file") + fi +done < <(find src SubProcesses -type f \( -name "*.cc" -o -name "*.h" \) 2>/dev/null) + + +echo "" +echo "Files needing formatting: $count" +echo "Total files checked: $total" + +if [ $count -gt 0 ]; then + echo "Detailed patch saved to '$patch_file'" + echo "If this scrpt is run in the CI workflow, detailed patches are provided as comment on the PR." +else + echo "All files are properly formatted." + rm "$patch_file" +fi +echo "" + +exit $count From 50e442a85e56a71176934ae77099230e35a7b2b7 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 10:36:34 +0100 Subject: [PATCH 10/27] ignore test process directories --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a8ade725e6..a617fdaf7b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ py.py build.* .build.* +#=== testing === +test/processes/PROC_* + #=== Profiling === nsight_logs profile_* From 6b86a94df7958986d3ebfebb017d7308a10a2bf4 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 10:37:12 +0100 Subject: [PATCH 11/27] change to script for formatting check and more details if fails fix syntax, not bash syntax error change to script for formatting check and more details if fails --- .github/workflows/mg5_codegen.yml | 59 ++++++++++++++----------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index ac0d7e992d..65041d2459 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -1,4 +1,4 @@ -name: Code Generator CI +name: Generate code, check format and push to generated processes repo on: pull_request: @@ -21,28 +21,21 @@ jobs: ./MG5aMC/mg5amcnlo/bin/mg5_aMC test/processes/pp_ttx/output.mg5 - name: Check code format with clang-format - id: format-check + id: clang-format-check run: | + chmod +x .github/workflows/check-formatting.sh cd PROC_pp_ttx - # Find all generated C/C++ files (adjust pattern as needed) - find . -type f \( -name "*.cc" -o -name "*.h" \) > files.txt - - # Run clang-format check - #if find . -name '*.cc' -o -name '*.h' | xargs -n1 clang-format -style=file -assume-filename={} {} | diff -u {} -; then - if clang-format --dry-run --Werror $(cat files.txt) 2>&1 | tee format-output.txt; then - echo "format_ok=true" >> $GITHUB_OUTPUT - echo "✅ Code is properly formatted" + $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh + echo "format_exit=$?" >> $GITHUB_OUTPUT + + if [ "$format_exit" -eq 0 ]; then + echo "✅ clang-format check passed." else - echo "format_ok=false" >> $GITHUB_OUTPUT - echo "❌ Code needs formatting" - - # Generate the diff for needed changes - clang-format -i $(cat files.txt) - git diff > format-changes.patch + echo "❌ clang-format check failed." fi - name: Commit to target repository - # if: steps.format-check.outputs.format_ok == 'true' + if: "${{ steps.clang-format-check.outputs.format_exit == '0'}}" env: TARGET_REPO: roiser/madgraph4gpu-generated-processes GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} @@ -71,8 +64,17 @@ jobs: echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" + - name: Read patch file + if: "${{ steps.clang-format-check.outputs.format_exit == '0' }}" + run: | + { + echo "patch_file_content<> $GITHUB_OUTPUT + - name: Comment on PR with format issues - if: steps.format-check.outputs.format_ok == 'false' + if: "${{ steps.clang-format-check.outputs.format_exit == '0' }}" uses: actions/github-script@v7 with: script: | @@ -81,26 +83,19 @@ jobs: const comment = `## ❌ Code Format Check Failed - The generated code does not conform to clang-format rules. - -
- Required formatting changes - - \`\`\`diff - ${patch} - \`\`\` - -
- - Please update your code generator to produce properly formatted code.`; + The generated code does not conform to clang-format rules. + + Please update your code generator to produce properly formatted code. + ${{steps.clang-format-check.outputs.format_exit}} files need formatting. + See attached patch for details:`; github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, - body: comment + body: `${comment} \n ${{steps.clang-format-check.outputs.patch_file_content}}` }); - name: Fail if format check failed - if: steps.format-check.outputs.format_ok == 'false' + if: "${{ steps.clang-format-check.outputs.format_exit == '0' }}" run: exit 1 From c2416f917dc2a9f5e009e9e86631554680e3eac9 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 11:17:58 +0100 Subject: [PATCH 12/27] continue if the format check returns non 0 check value rebase continue if the format check returns non 0 --- .github/workflows/mg5_codegen.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 65041d2459..1312d8b8f2 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -33,9 +33,10 @@ jobs: else echo "❌ clang-format check failed." fi + continue-on-error: true - name: Commit to target repository - if: "${{ steps.clang-format-check.outputs.format_exit == '0'}}" + if: "${{ steps.clang-format-check.outputs.format_exit == 0}}" env: TARGET_REPO: roiser/madgraph4gpu-generated-processes GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} @@ -60,12 +61,14 @@ jobs: git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" \ -m "Source PR: ${{ github.event.pull_request.html_url }}" + git fetch origin + git rebase origin/${BRANCH_NAME} git push origin ${BRANCH_NAME} echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" - name: Read patch file - if: "${{ steps.clang-format-check.outputs.format_exit == '0' }}" + if: "${{ steps.clang-format-check.outputs.format_exit != 0 }}" run: | { echo "patch_file_content<> $GITHUB_OUTPUT - name: Comment on PR with format issues - if: "${{ steps.clang-format-check.outputs.format_exit == '0' }}" + if: "${{ steps.clang-format-check.outputs.format_exit != 0 }}" uses: actions/github-script@v7 with: script: | @@ -97,5 +100,5 @@ jobs: }); - name: Fail if format check failed - if: "${{ steps.clang-format-check.outputs.format_exit == '0' }}" + if: "${{ steps.clang-format-check.outputs.format_exit != 0 }}" run: exit 1 From d6c9c3b1e61dbcef0985b5e57627e21a3e7f5492 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 11:32:33 +0100 Subject: [PATCH 13/27] push force --- .github/workflows/mg5_codegen.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 1312d8b8f2..871e019648 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -61,9 +61,7 @@ jobs: git commit -m "Code generated from PR #${{ github.event.pull_request.number }}" \ -m "Source PR: ${{ github.event.pull_request.html_url }}" - git fetch origin - git rebase origin/${BRANCH_NAME} - git push origin ${BRANCH_NAME} + git push -f origin ${BRANCH_NAME} echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" From c8ba390f2fe656066764e154ac85fd1aaf2772c3 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 11:44:11 +0100 Subject: [PATCH 14/27] move away from return value fix directory change if statement add spaces fix java script read file inside the script verbose text, remove newline, check for 8 failures move back to 0 for the check move away from return value for code checking script --- .github/workflows/check-formatting.sh | 4 +++- .github/workflows/mg5_codegen.yml | 31 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check-formatting.sh b/.github/workflows/check-formatting.sh index e1b40c6f80..0c2effbbb9 100755 --- a/.github/workflows/check-formatting.sh +++ b/.github/workflows/check-formatting.sh @@ -7,9 +7,11 @@ count=0 total=0 files_needing_format=() patch_file="format-changes.patch" +num_file="files2format" # clean patch file if it exists > "$patch_file" +> "$num_file" echo "" echo "Checking formatting with clang-format..." @@ -40,4 +42,4 @@ else fi echo "" -exit $count +echo $count | tr -d \\n >> $num_file diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 871e019648..65b568b50f 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -26,17 +26,17 @@ jobs: chmod +x .github/workflows/check-formatting.sh cd PROC_pp_ttx $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh - echo "format_exit=$?" >> $GITHUB_OUTPUT + files2format=$(cat files2format) + echo "files2format=$files2format" >> $GITHUB_OUTPUT - if [ "$format_exit" -eq 0 ]; then + if [ "$files2format" -eq 0 ]; then echo "✅ clang-format check passed." else echo "❌ clang-format check failed." fi - continue-on-error: true - name: Commit to target repository - if: "${{ steps.clang-format-check.outputs.format_exit == 0}}" + if: ${{ steps.clang-format-check.outputs.files2format == '0' }} env: TARGET_REPO: roiser/madgraph4gpu-generated-processes GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} @@ -66,37 +66,42 @@ jobs: echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" - name: Read patch file - if: "${{ steps.clang-format-check.outputs.format_exit != 0 }}" + if: ${{ steps.clang-format-check.outputs.files2format != '0' }} run: | { echo "patch_file_content<> $GITHUB_OUTPUT - name: Comment on PR with format issues - if: "${{ steps.clang-format-check.outputs.format_exit != 0 }}" + if: ${{ steps.clang-format-check.outputs.files2format != '0' }} uses: actions/github-script@v7 + env: + FILES2FORMAT: ${{ steps.clang-format-check.outputs.files2format }} + PROC_DIR: PROC_pp_ttx with: script: | + const fs = require('fs'); - const patch = fs.readFileSync('format-changes.patch', 'utf8'); - + const filesToFormat = parseInt(process.env.FILES2FORMAT); + const patchContent = fs.readFileSync(`${process.env.PROC_DIR}/format-changes.patch`, 'utf8'); + const comment = `## ❌ Code Format Check Failed The generated code does not conform to clang-format rules. Please update your code generator to produce properly formatted code. - ${{steps.clang-format-check.outputs.format_exit}} files need formatting. + ${filesToFormat} files need formatting. See attached patch for details:`; github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, - body: `${comment} \n ${{steps.clang-format-check.outputs.patch_file_content}}` + body: `${comment} \n \`\`\` \n ${patchContent} \n \`\`\`` }); - + - name: Fail if format check failed - if: "${{ steps.clang-format-check.outputs.format_exit != 0 }}" + if: ${{ steps.clang-format-check.outputs.files2format != '0' }} run: exit 1 From 7c2c913471dfc85726ce17f3e53d93ec38cb8582 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 15:29:52 +0100 Subject: [PATCH 15/27] introduce gh matrix more debug info introduce gh ci matrix --- .github/workflows/mg5_codegen.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 65b568b50f..ad62cf6072 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -7,6 +7,15 @@ on: jobs: generate-and-check: runs-on: ubuntu-latest + + strategy: + matrix: + process: [pp_ttx, pp_ttxj] + backend: [scalar, avx2, avx512, cuda, hip] + + env: + PROC_DIR: PROC_${{ matrix.process }} + BACKEND : ${{ matrix.backend }} steps: - name: Checkout codegen repo @@ -18,13 +27,13 @@ jobs: - name: Run code generator run: | if [ ! -e MG5aMC/mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT ] ; then pushd MG5aMC/mg5amcnlo/PLUGIN/ && ln -s ../../../epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT && popd ; fi - ./MG5aMC/mg5amcnlo/bin/mg5_aMC test/processes/pp_ttx/output.mg5 + ./MG5aMC/mg5amcnlo/bin/mg5_aMC test/processes/${{ matrix.process }}/output.mg5 - name: Check code format with clang-format id: clang-format-check run: | chmod +x .github/workflows/check-formatting.sh - cd PROC_pp_ttx + cd ${{ env.PROC_DIR }} $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh files2format=$(cat files2format) echo "files2format=$files2format" >> $GITHUB_OUTPUT @@ -54,7 +63,7 @@ jobs: git checkout -b ${BRANCH_NAME} # Copy generated files (adjust paths as needed) - cp -r ${GITHUB_WORKSPACE}/PROC_pp_ttx . + cp -r ${GITHUB_WORKSPACE}/${{ env.PROC_DIR }} . # Commit and push git add . @@ -70,7 +79,7 @@ jobs: run: | { echo "patch_file_content<> $GITHUB_OUTPUT @@ -79,7 +88,7 @@ jobs: uses: actions/github-script@v7 env: FILES2FORMAT: ${{ steps.clang-format-check.outputs.files2format }} - PROC_DIR: PROC_pp_ttx +# PROC_DIR: ${{ env.PROC_DIR }} with: script: | @@ -93,6 +102,10 @@ jobs: Please update your code generator to produce properly formatted code. ${filesToFormat} files need formatting. + + Note: The CI is setup so it fails early, if formatting issues are detected for any of the processes. + The report below is for process **${process.env.PROC_DIR}** with backend **${process.env.BACKEND}**. + See attached patch for details:`; github.rest.issues.createComment({ From bd07d8082131c8b7debbdaef6855405613351386 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Wed, 14 Jan 2026 15:40:41 +0100 Subject: [PATCH 16/27] add second process dir --- test/processes/pp_ttxj/launch.mg5 | 6 ++++++ test/processes/pp_ttxj/output.mg5 | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 test/processes/pp_ttxj/launch.mg5 create mode 100644 test/processes/pp_ttxj/output.mg5 diff --git a/test/processes/pp_ttxj/launch.mg5 b/test/processes/pp_ttxj/launch.mg5 new file mode 100644 index 0000000000..6be9aa7461 --- /dev/null +++ b/test/processes/pp_ttxj/launch.mg5 @@ -0,0 +1,6 @@ +launch PROC_pp_ttxj +set vector_size 32 +set nevents 25k +set sde_strategy 1 +set gridpack True + diff --git a/test/processes/pp_ttxj/output.mg5 b/test/processes/pp_ttxj/output.mg5 new file mode 100644 index 0000000000..1a934c01e6 --- /dev/null +++ b/test/processes/pp_ttxj/output.mg5 @@ -0,0 +1,2 @@ +generate p p > t t~ j +output madevent_simd PROC_pp_ttxj From b8846e11de5c01a1ce05149971d77b7a102ca847 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 08:39:04 +0100 Subject: [PATCH 17/27] test github app generate access token run only one config fix typo indentation error simplify token gen remove installation-id add repo name test github app --- .github/workflows/mg5_codegen.yml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index ad62cf6072..96dd093740 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -10,8 +10,10 @@ jobs: strategy: matrix: - process: [pp_ttx, pp_ttxj] - backend: [scalar, avx2, avx512, cuda, hip] +# process: [pp_ttx, pp_ttxj] +# backend: [scalar, avx2, avx512, cuda, hip] + process: [pp_ttx] + backend: [scalar] env: PROC_DIR: PROC_${{ matrix.process }} @@ -43,19 +45,28 @@ jobs: else echo "❌ clang-format check failed." fi - + + - name: Generate GitHub App token + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.GH_APP_ID }} + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} + repositories: madgraph4gpu-generated-processes +# installation-id: ${{ secrets.GH_APP_INSTALLATION_ID }} + - name: Commit to target repository - if: ${{ steps.clang-format-check.outputs.files2format == '0' }} + if: ${{ steps.clang-format-check.outputs.files2format == '8' }} env: TARGET_REPO: roiser/madgraph4gpu-generated-processes - GH_TOKEN: ${{ secrets.MG4GPU_GEN_PAT }} run: | # Configure git + git config --global user.name "github-actions" git config --global user.email "github-actions@users.noreply.github.com" # Clone target repo - git clone https://x-access-token:${GH_TOKEN}@github.com/${TARGET_REPO}.git + git clone https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${TARGET_REPO}.git cd madgraph4gpu-generated-processes # Create branch based on PR number From 12aac6595137fb34c8c5981ab152d12043f13e19 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 11:02:55 +0100 Subject: [PATCH 18/27] empty From b8a92a6f4a9fca11ef1dd9e7f835ac91bc59ddea Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 13:34:31 +0100 Subject: [PATCH 19/27] gather data for readme update remote readme gather data for readme --- .github/workflows/mg5_codegen.yml | 37 +++++++++++++-- .github/workflows/update_readme.py | 75 ++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/update_readme.py diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 96dd093740..dd19d9ea8f 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -34,7 +34,7 @@ jobs: - name: Check code format with clang-format id: clang-format-check run: | - chmod +x .github/workflows/check-formatting.sh + chmod +x $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh cd ${{ env.PROC_DIR }} $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh files2format=$(cat files2format) @@ -53,10 +53,9 @@ jobs: app-id: ${{ secrets.GH_APP_ID }} private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} repositories: madgraph4gpu-generated-processes -# installation-id: ${{ secrets.GH_APP_INSTALLATION_ID }} - name: Commit to target repository - if: ${{ steps.clang-format-check.outputs.files2format == '8' }} + if: ${{ steps.clang-format-check.outputs.files2format == '0' }} env: TARGET_REPO: roiser/madgraph4gpu-generated-processes run: | @@ -94,12 +93,42 @@ jobs: echo "EOF" } >> $GITHUB_OUTPUT + - name: Update README.md + if: ${{ steps.clang-format-check.outputs.files2format == '8' }} + run: | + echo "title: ${{ github.event.pull_request.title }}" + echo "url: ${{ github.event.pull_request.html_url }}" + echo "number: ${{ github.event.pull_request.number }}" + echo "updated_at: ${{ github.event.pull_request.updated_at }}" + echo "user: ${{ github.event.pull_request.user.login }}" + echo "draft: ${{ github.event.pull_request.draft }}" + echo "created_at: ${{ github.event.pull_request.created_at }}" + echo "commits: ${{ github.event.pull_request.commits }}" + + cd $GITHUB_WORKSPACE/madgraph4gpu-generated-processes + git checkout main + + python3 $GITHUB_WORKSPACE/.github/workflows/update_readme.py \ + --title "${{ github.event.pull_request.title }}" \ + --url "${{ github.event.pull_request.html_url }}" \ + --pr_num "${{ github.event.pull_request.number }}" \ + --created "${{ github.event.pull_request.created_at }}" \ + --last_updated "${{ github.event.pull_request.updated_at }}" \ + --wip "${{ github.event.pull_request.draft }}" \ + --num_commits "${{ github.event.pull_request.commits }}" \ + --author "${{ github.event.pull_request.user.login }}" + + git add . + git commit -m "Update README for PR #${{ github.event.pull_request.number }}" + git push -f origin main + + echo "✅ Pushed to ${TARGET_REPO} on branch main" + - name: Comment on PR with format issues if: ${{ steps.clang-format-check.outputs.files2format != '0' }} uses: actions/github-script@v7 env: FILES2FORMAT: ${{ steps.clang-format-check.outputs.files2format }} -# PROC_DIR: ${{ env.PROC_DIR }} with: script: | diff --git a/.github/workflows/update_readme.py b/.github/workflows/update_readme.py new file mode 100644 index 0000000000..6918442ee7 --- /dev/null +++ b/.github/workflows/update_readme.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +import json + +class UpdateReadme: + def __init__(self, title, url, pr_num, created, last_updated, wip, num_commits, author): + self.title = title + self.url = url + self.pr_num = pr_num + self.created = created + self.last_updated = last_updated + self.wip = wip + self.num_commits = num_commits + self.author = author + + def update_json(self): + fh = open('readme_data.json', 'r') + data = json.load(fh) + fh.close() + + if self.pr_num not in data: + new_entry = { + "title": self.title, + "url": self.url, + "created": self.created, + "last_updated": self.last_updated, + "wip": self.wip, + "num_commits": self.num_commits, + "author": self.author + } + data[self.pr_num] = new_entry + else: + data[self.pr_num]['last_updated'] = self.last_updated + data[self.pr_num]['wip'] = self.wip + data[self.pr_num]['num_commits'] = self.num_commits + data[self.pr_num]['title'] = self.title + + fh = open('readme_data.json', 'w') + json.dump(data, fh, indent=4) + fh.close() + + def write_readme(self): + fh = open('readme_data.json', 'r') + data = json.load(fh) + fh.close() + + sorted_prs = sorted(data.items(), key=lambda x: x[1]['last_updated'], reverse=True) + + with open('README.md', 'w') as fh: + fh.write("# Pull Request Summary\n\n") + fh.write("| PR Number | Title | Author | Created | Last Updated | WIP | Number of Commits |\n") + fh.write("|-----------|-------|--------|---------|--------------|-----|-------------------|\n") + for pr_num, details in sorted_prs: + fh.write(f"| [{pr_num}]({details['url']}) | {details['title']} | {details['author']} | {details['created']} | {details['last_updated']} | {details['wip']} | {details['num_commits']} |\n") + + def run(self): + self.update_json() + self.write_readme() + +if __name__ == "__main__": +import optparse + parser = optparse.OptionParser() + parser.add_option('--title', dest='title', help='PR title') + parser.add_option('--url', dest='url', help='PR URL') + parser.add_option('--pr_num', dest='pr_num', help='PR number') + parser.add_option('--created', dest='created', help='PR creation date') + parser.add_option('--last_updated', dest='last_updated', help='PR last updated date') + parser.add_option('--wip', dest='wip', help='Is PR WIP') + parser.add_option('--num_commits', dest='num_commits', help='Number of commits in PR') + parser.add_option('--author', dest='author', help='PR author') + + options, _ = parser.parse_args() + + updater = UpdateReadme(options.title, options.url, options.pr_num, options.created, options.last_updated, options.wip, options.num_commits, options.author) + updater.run() \ No newline at end of file From fc2d67cc85d8f78776c5c562396a0bd9ac437870 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 14:53:46 +0100 Subject: [PATCH 20/27] always use home dir fix python script always use home dir --- .github/workflows/mg5_codegen.yml | 14 ++++++++------ .github/workflows/update_readme.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index dd19d9ea8f..2c74e256ae 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -28,15 +28,16 @@ jobs: - name: Run code generator run: | + cd ${GITHUB_WORKSPACE} if [ ! -e MG5aMC/mg5amcnlo/PLUGIN/CUDACPP_SA_OUTPUT ] ; then pushd MG5aMC/mg5amcnlo/PLUGIN/ && ln -s ../../../epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT && popd ; fi ./MG5aMC/mg5amcnlo/bin/mg5_aMC test/processes/${{ matrix.process }}/output.mg5 - name: Check code format with clang-format id: clang-format-check run: | - chmod +x $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh - cd ${{ env.PROC_DIR }} - $GITHUB_WORKSPACE/.github/workflows/check-formatting.sh + chmod +x ${GITHUB_WORKSPACE}/.github/workflows/check-formatting.sh + cd ${GITHUB_WORKSPACE}/${{ env.PROC_DIR }} + ${GITHUB_WORKSPACE}/.github/workflows/check-formatting.sh files2format=$(cat files2format) echo "files2format=$files2format" >> $GITHUB_OUTPUT @@ -65,8 +66,9 @@ jobs: git config --global user.email "github-actions@users.noreply.github.com" # Clone target repo + cd ${GITHUB_WORKSPACE} git clone https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${TARGET_REPO}.git - cd madgraph4gpu-generated-processes + cd ${GITHUB_WORKSPACE}/madgraph4gpu-generated-processes # Create branch based on PR number BRANCH_NAME="codegen-pr-${{ github.event.pull_request.number }}" @@ -105,10 +107,10 @@ jobs: echo "created_at: ${{ github.event.pull_request.created_at }}" echo "commits: ${{ github.event.pull_request.commits }}" - cd $GITHUB_WORKSPACE/madgraph4gpu-generated-processes + cd ${GITHUB_WORKSPACE}/madgraph4gpu-generated-processes git checkout main - python3 $GITHUB_WORKSPACE/.github/workflows/update_readme.py \ + python3 ${GITHUB_WORKSPACE}/.github/workflows/update_readme.py \ --title "${{ github.event.pull_request.title }}" \ --url "${{ github.event.pull_request.html_url }}" \ --pr_num "${{ github.event.pull_request.number }}" \ diff --git a/.github/workflows/update_readme.py b/.github/workflows/update_readme.py index 6918442ee7..77dd0bb624 100644 --- a/.github/workflows/update_readme.py +++ b/.github/workflows/update_readme.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json +import optparse class UpdateReadme: def __init__(self, title, url, pr_num, created, last_updated, wip, num_commits, author): @@ -58,7 +59,6 @@ def run(self): self.write_readme() if __name__ == "__main__": -import optparse parser = optparse.OptionParser() parser.add_option('--title', dest='title', help='PR title') parser.add_option('--url', dest='url', help='PR URL') From 4a776ef41bcad1aa4c784d0ac52ab6974f5cf110 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 14:57:20 +0100 Subject: [PATCH 21/27] use python setup print python version add 8 use python setup --- .github/workflows/mg5_codegen.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 2c74e256ae..cc8c15cb26 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -56,7 +56,7 @@ jobs: repositories: madgraph4gpu-generated-processes - name: Commit to target repository - if: ${{ steps.clang-format-check.outputs.files2format == '0' }} + if: ${{ steps.clang-format-check.outputs.files2format == '8' }} env: TARGET_REPO: roiser/madgraph4gpu-generated-processes run: | @@ -95,6 +95,11 @@ jobs: echo "EOF" } >> $GITHUB_OUTPUT + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Update README.md if: ${{ steps.clang-format-check.outputs.files2format == '8' }} run: | @@ -110,7 +115,9 @@ jobs: cd ${GITHUB_WORKSPACE}/madgraph4gpu-generated-processes git checkout main - python3 ${GITHUB_WORKSPACE}/.github/workflows/update_readme.py \ + # python --version + + python ${GITHUB_WORKSPACE}/.github/workflows/update_readme.py \ --title "${{ github.event.pull_request.title }}" \ --url "${{ github.event.pull_request.html_url }}" \ --pr_num "${{ github.event.pull_request.number }}" \ From b7124cf5fd250580dd86123b63517ab8377255a6 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 16:04:46 +0100 Subject: [PATCH 22/27] re-order table, add branch name fix typo empty empty re-order table, add branch name --- .github/workflows/update_readme.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_readme.py b/.github/workflows/update_readme.py index 77dd0bb624..21c72607e0 100644 --- a/.github/workflows/update_readme.py +++ b/.github/workflows/update_readme.py @@ -13,6 +13,7 @@ def __init__(self, title, url, pr_num, created, last_updated, wip, num_commits, self.wip = wip self.num_commits = num_commits self.author = author + self.remote_repo_url = "https://github.com/roiser/madgraph4gpu-generated-processes/" def update_json(self): fh = open('readme_data.json', 'r') @@ -22,6 +23,7 @@ def update_json(self): if self.pr_num not in data: new_entry = { "title": self.title, + "branch": self.remote_repo_url + "tree/codegen-pr-" + str(self.pr_num), "url": self.url, "created": self.created, "last_updated": self.last_updated, @@ -49,10 +51,10 @@ def write_readme(self): with open('README.md', 'w') as fh: fh.write("# Pull Request Summary\n\n") - fh.write("| PR Number | Title | Author | Created | Last Updated | WIP | Number of Commits |\n") - fh.write("|-----------|-------|--------|---------|--------------|-----|-------------------|\n") + fh.write("| PR Number | Local Branch | Title | WIP | # Commits | Author | Created | Last Update |\n") + fh.write("|-----------|--------------|-------|-----|-----------|--------|---------|-------------|\n") for pr_num, details in sorted_prs: - fh.write(f"| [{pr_num}]({details['url']}) | {details['title']} | {details['author']} | {details['created']} | {details['last_updated']} | {details['wip']} | {details['num_commits']} |\n") + fh.write(f"| [{pr_num}]({details['url']}) | [{details['branch'].split('/')[-1]}]({details['branch']}) | {details['title']} | {details['wip']} | {details['num_commits']} | {details['author']} | {details['created']} | {details['last_updated']} |\n") def run(self): self.update_json() From f183d8b912160dc0dd575db5c4455fd2f9752e51 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 17:17:54 +0100 Subject: [PATCH 23/27] multiple processes move to 0, check success invert use multiple processes --- .github/workflows/mg5_codegen.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index cc8c15cb26..126398174c 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -10,14 +10,10 @@ jobs: strategy: matrix: -# process: [pp_ttx, pp_ttxj] -# backend: [scalar, avx2, avx512, cuda, hip] - process: [pp_ttx] - backend: [scalar] + process: [pp_ttx, pp_ttxj] env: PROC_DIR: PROC_${{ matrix.process }} - BACKEND : ${{ matrix.backend }} steps: - name: Checkout codegen repo @@ -101,7 +97,7 @@ jobs: python-version: "3.11" - name: Update README.md - if: ${{ steps.clang-format-check.outputs.files2format == '8' }} + if: ${{ steps.commit_to_target_repository.outcome == 'success' }} run: | echo "title: ${{ github.event.pull_request.title }}" echo "url: ${{ github.event.pull_request.html_url }}" From bf37539200b4b9280a1b0f2eaa15580257749513 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 17:28:00 +0100 Subject: [PATCH 24/27] move to 0 --- .github/workflows/mg5_codegen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 126398174c..7dc8395ea4 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -52,7 +52,7 @@ jobs: repositories: madgraph4gpu-generated-processes - name: Commit to target repository - if: ${{ steps.clang-format-check.outputs.files2format == '8' }} + if: ${{ steps.clang-format-check.outputs.files2format == '0' }} env: TARGET_REPO: roiser/madgraph4gpu-generated-processes run: | From a4767119bcd776848b255925f24f1af4d670ac4e Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 17:38:42 +0100 Subject: [PATCH 25/27] make ci fail immediately when code check fails --- .github/workflows/mg5_codegen.yml | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 7dc8395ea4..ae866858a8 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -41,6 +41,7 @@ jobs: echo "✅ clang-format check passed." else echo "❌ clang-format check failed." + exit 1 fi - name: Generate GitHub App token @@ -82,15 +83,6 @@ jobs: echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" - - name: Read patch file - if: ${{ steps.clang-format-check.outputs.files2format != '0' }} - run: | - { - echo "patch_file_content<> $GITHUB_OUTPUT - - name: Set up Python uses: actions/setup-python@v5 with: @@ -99,20 +91,9 @@ jobs: - name: Update README.md if: ${{ steps.commit_to_target_repository.outcome == 'success' }} run: | - echo "title: ${{ github.event.pull_request.title }}" - echo "url: ${{ github.event.pull_request.html_url }}" - echo "number: ${{ github.event.pull_request.number }}" - echo "updated_at: ${{ github.event.pull_request.updated_at }}" - echo "user: ${{ github.event.pull_request.user.login }}" - echo "draft: ${{ github.event.pull_request.draft }}" - echo "created_at: ${{ github.event.pull_request.created_at }}" - echo "commits: ${{ github.event.pull_request.commits }}" - cd ${GITHUB_WORKSPACE}/madgraph4gpu-generated-processes git checkout main - # python --version - python ${GITHUB_WORKSPACE}/.github/workflows/update_readme.py \ --title "${{ github.event.pull_request.title }}" \ --url "${{ github.event.pull_request.html_url }}" \ @@ -129,6 +110,15 @@ jobs: echo "✅ Pushed to ${TARGET_REPO} on branch main" + - name: Read patch file + if: ${{ steps.clang-format-check.outputs.files2format != '0' }} + run: | + { + echo "patch_file_content<> $GITHUB_OUTPUT + - name: Comment on PR with format issues if: ${{ steps.clang-format-check.outputs.files2format != '0' }} uses: actions/github-script@v7 From e4e2fb3d83707385722a7db5f19e191f46c19cbb Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 17:40:50 +0100 Subject: [PATCH 26/27] remove last step, not needed anymore --- .github/workflows/mg5_codegen.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index ae866858a8..5b31d381a4 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -149,7 +149,3 @@ jobs: issue_number: context.issue.number, body: `${comment} \n \`\`\` \n ${patchContent} \n \`\`\`` }); - - - name: Fail if format check failed - if: ${{ steps.clang-format-check.outputs.files2format != '0' }} - run: exit 1 From 9c9238def197ac4ec25fafd8899772b25a3cfa52 Mon Sep 17 00:00:00 2001 From: Stefan Roiser Date: Fri, 16 Jan 2026 17:44:14 +0100 Subject: [PATCH 27/27] preprend all steps with if statement --- .github/workflows/mg5_codegen.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml index 5b31d381a4..466444cb5d 100644 --- a/.github/workflows/mg5_codegen.yml +++ b/.github/workflows/mg5_codegen.yml @@ -41,10 +41,10 @@ jobs: echo "✅ clang-format check passed." else echo "❌ clang-format check failed." - exit 1 fi - name: Generate GitHub App token + if: ${{ steps.clang-format-check.outputs.files2format == '0' }} id: app-token uses: actions/create-github-app-token@v1 with: @@ -84,6 +84,7 @@ jobs: echo "✅ Pushed to ${TARGET_REPO} on branch ${BRANCH_NAME}" - name: Set up Python + if: ${{ steps.commit_to_target_repository.outcome == 'success' }} uses: actions/setup-python@v5 with: python-version: "3.11" @@ -149,3 +150,7 @@ jobs: issue_number: context.issue.number, body: `${comment} \n \`\`\` \n ${patchContent} \n \`\`\`` }); + + - name: Fail if format check failed + if: ${{ steps.clang-format-check.outputs.files2format != '0' }} + run: exit 1