diff --git a/.github/workflows/mg5_codegen.yml b/.github/workflows/mg5_codegen.yml new file mode 100644 index 0000000000..ac0d7e992d --- /dev/null +++ b/.github/workflows/mg5_codegen.yml @@ -0,0 +1,106 @@ +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 + submodules: true + + - 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 + + - 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 "*.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" + 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: 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 + cd madgraph4gpu-generated-processes + + # 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 }}" + + 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/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 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.* 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