diff --git a/.github/actions/submodulePR/action.yml b/.github/actions/submodulePR/action.yml new file mode 100644 index 000000000..b2ef3a92b --- /dev/null +++ b/.github/actions/submodulePR/action.yml @@ -0,0 +1,127 @@ +name: "Automatic PR on framework at submodule PR" +inputs: + branch: + description: "Target branch name" + required: true + submodule: + description: "Relative path to the submodule" + required: true + label: + description: "Add the following label to the submodule PR" + token: + description: "Authentification token" + required: true + +runs: + using: 'composite' + steps: + - name: Checkout framework repository + uses: actions/checkout@v3 + with: + token: ${{ inputs.token }} + repository: rest-for-physics/framework + ref: master + path: framework + - name: Pull submodules + run: | + cd framework + ./scripts/checkoutRemoteBranch.sh ${{ inputs.branch }} + python3 pull-submodules.py --force --dontask --latest:${{ inputs.branch }} + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + shell: bash + - name: Check if framework branch exist + id: frameworkBranch + run: | + cd framework + echo "ref=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT + shell: bash + - name: Commit changes if branch exist + if: steps.frameworkBranch.outputs.ref == ${{ inputs.branch }} + run: | + cd framework + git pull + git add ${{ inputs.submodule }} + var=$(git diff --cached) + if [[ -z $var ]]; then + echo "Nothing to commit" + else + git commit -m "Updating submodule ${{ inputs.submodule }}" + git push + fi + shell: bash + - name: Commit changes to new branch + if: steps.frameworkBranch.outputs.ref == 'master' + run: | + cd framework + git checkout -b ${{ inputs.branch }} + git add ${{ inputs.submodule }} + git commit -m "Updating submodule ${{ inputs.submodule }}" + git push --set-upstream origin ${{ inputs.branch }} + shell: bash + - name: Checkout submodule + uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + path: submodule + - name: Check submodule PR + id: submodulePR + run: | + cd submodule + #Check submodule PR + gh auth status + gh pr view + prurl=$(gh pr view --json url -t '{{ .url }}') + echo "prurl=$prurl" >> $GITHUB_OUTPUT + echo -e "body<> $GITHUB_OUTPUT + #Add framework-pr label + gh pr edit $prurl --add-label "framework-pr" + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + - name: Check framework PR + id: frameworkPR + run: | + cd framework + #Check framework PR + echo "prurl=$(gh pr view --json url -t '{{ .url }}')" >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + - name: Create PR in framework + if: "steps.frameworkBranch.outputs.ref == 'master' || steps.frameworkPR.outputs.prurl == ''" + run: | + cd framework + gh pr create -B master -H ${{ inputs.branch }} --title 'Submodule Updates from ${{ inputs.submodule }} branch ${{ inputs.branch }}' --body 'Automatic PR from ${{ inputs.submodule }} branch ${{ inputs.branch }}, related PR ${{ steps.submodulePR.outputs.prurl }}' + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + - name: Second check on framework PR + id: PRFramework + run: | + cd framework + #Check framework PR + gh pr view + echo "prurl=$(gh pr view --json url -t '{{ .url }}')" >> $GITHUB_OUTPUT + echo -e "body<> $GITHUB_OUTPUT + #Add custom label + gh pr edit $prurl --add-label ${{ inputs.label }} + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + - name: Update submodule PR body + if: "steps.frameworkBranch.outputs.ref != 'master' && !contains(steps.submodulePR.outputs.body, steps.PRFramework.outputs.prurl)" + run: | + cd submodule + gh pr edit ${{ steps.submodulePR.outputs.prurl }} --body '${{ steps.submodulePR.outputs.body }} Related framework PR ${{ steps.PRFramework.outputs.prurl }}' + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + - name: Update framework PR body + if: "steps.frameworkBranch.outputs.ref != 'master' && !contains(steps.PRFramework.outputs.body, steps.submodulePR.outputs.prurl)" + run: | + cd framework + gh pr edit ${{ steps.PRFramework.outputs.prurl }} --body '${{ steps.PRFramework.outputs.body }} Related PR ${{ steps.submodulePR.outputs.prurl }}' + env: + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 000000000..e24d329ba --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,92 @@ +name: "Automatic PR checks and merge" + +on: + pull_request: + branches: [ "master" ] + types: [ "opened", "reopened", "created", "closed", "synchronize", "labeled", "unlabeled"] + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +#permissions: write-all + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +defaults: + run: + shell: bash + +jobs: + submodule-pr: + strategy: + fail-fast: false + matrix: + submodule: ["rest-for-physics/rawlib", "rest-for-physics/detectorlib", "rest-for-physics/geant4lib","rest-for-physics/tracklib", "rest-for-physics/connectorslib", "rest-for-physics/axionlib", "rest-for-physics/legacylib", "rest-for-physics/wimplib", "rest-for-physics/restG4"] + runs-on: ubuntu-latest + if: github.head_ref || github.ref_name != 'master' + steps: + - name: Checkout submodule + uses: actions/checkout@v3 + with: + repository: ${{ matrix.submodule }} + path: submodule + - name: Check submodule branch + id: submoduleBranch + run: | + cd submodule + var=$(git ls-remote --heads origin ${{ env.BRANCH_NAME }}) + if [[ -z $var ]]; then + echo "Branch "${{ env.BRANCH_NAME }}" not found in " ${{ matrix.submodule }} + echo "exist=false" >> $GITHUB_OUTPUT + else + echo "Branch "${{ env.BRANCH_NAME }}" found in " ${{ matrix.submodule }} + git fetch + git checkout ${{ env.BRANCH_NAME }} + git pull + echo "exist=true" >> $GITHUB_OUTPUT + fi + shell: bash + - name: Check PR + id: PRCheck + if: steps.submoduleBranch.outputs.exist == 'true' + run: | + cd submodule + #Check PR + gh auth status + gh pr view + echo "prurl=$(gh pr view --json url -t '{{ .url }}')" >> $GITHUB_OUTPUT + echo "mergeStateStatus=$(gh pr view --json mergeStateStatus -t '{{ .mergeStateStatus }}')" >> $GITHUB_OUTPUT + echo "prState=$(gh pr view --json state -t '{{ .state }}')" >> $GITHUB_OUTPUT + echo "review=$(gh pr view --json reviewDecision -t '{{ .reviewDecision }}')" >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ secrets.REST_TOKEN }} + - name: Print outputs + if: steps.submoduleBranch.outputs.exist == 'true' + run: | + echo "Merge status " ${{ steps.PRCheck.outputs.mergeStateStatus }} + echo "PR REVIEW " ${{ steps.PRCheck.outputs.review }} + echo "PR url " ${{ steps.PRCheck.outputs.prurl }} + echo "PR state " ${{ steps.PRCheck.outputs.prState }} + if [[ ${{ steps.PRCheck.outputs.prState }} == "MERGED" ]]; then + echo "PR already merged" + elif [[ ${{ steps.PRCheck.outputs.review }} == "APPROVED" ]]; then + echo "PR is approved and mergeStateStatus is " $mergeStateStatus + else + echo "Not approved or invalid PR for branch " ${{ env.BRANCH_NAME }} " in " ${{ matrix.submodule }} " merge is not allowed" + exit 1 + fi + - name: Merge PR + if: (github.event.action == 'closed' && github.event.pull_request.merged == true && steps.PRCheck.outputs.review == 'APPROVED' && steps.PRCheck.outputs.prState != 'MERGED') + run: | + cd submodule + gh pr edit ${{ steps.PRCheck.outputs.prurl }} --remove "framework-pr" + gh auth status + echo "actor " ${{ github.actor }} + gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ steps.PRCheck.outputs.prurl }} + GITHUB_TOKEN: ${{ secrets.REST_TOKEN }} diff --git a/source/libraries/axion b/source/libraries/axion index 0b2704a02..b32b706b7 160000 --- a/source/libraries/axion +++ b/source/libraries/axion @@ -1 +1 @@ -Subproject commit 0b2704a02684a4af00d8fca3be5de1061717b13c +Subproject commit b32b706b710f000586b6f76ba72dbd271975775e diff --git a/source/libraries/connectors b/source/libraries/connectors index 4053c789e..836eeac9b 160000 --- a/source/libraries/connectors +++ b/source/libraries/connectors @@ -1 +1 @@ -Subproject commit 4053c789e53be296d934310c7d7631b3347236dd +Subproject commit 836eeac9b47bef322eaed0ab9063cf2e32f4ae69 diff --git a/source/libraries/detector b/source/libraries/detector index 53b99225e..17ce8e485 160000 --- a/source/libraries/detector +++ b/source/libraries/detector @@ -1 +1 @@ -Subproject commit 53b99225ee31bcfe0b8d119a182a148b02e9ce4b +Subproject commit 17ce8e48562d278c0baf3ac0369b911a3d122a41 diff --git a/source/libraries/geant4 b/source/libraries/geant4 index ed8266d5e..31100ac9c 160000 --- a/source/libraries/geant4 +++ b/source/libraries/geant4 @@ -1 +1 @@ -Subproject commit ed8266d5eb265ea5e7c01b6c95fac5f5a747bf30 +Subproject commit 31100ac9c4f1ca367661a5677a71bf8cf99af84e diff --git a/source/libraries/legacy b/source/libraries/legacy index 831424307..35998e031 160000 --- a/source/libraries/legacy +++ b/source/libraries/legacy @@ -1 +1 @@ -Subproject commit 83142430760cb35c2b3c597b24c1d884a01c0fff +Subproject commit 35998e031d74f6acf2dd526d175df2daf4de5861 diff --git a/source/libraries/raw b/source/libraries/raw index 952c92d85..eb42cb91b 160000 --- a/source/libraries/raw +++ b/source/libraries/raw @@ -1 +1 @@ -Subproject commit 952c92d85d8d6fd47f3aeedc4357032ce3ab8ee8 +Subproject commit eb42cb91b80ed7fe91bf462e9f72ff364e4277e9 diff --git a/source/libraries/track b/source/libraries/track index b7f0e27fa..08013296e 160000 --- a/source/libraries/track +++ b/source/libraries/track @@ -1 +1 @@ -Subproject commit b7f0e27fa1e71ed81d7f96ff2566a98b7fa55d30 +Subproject commit 08013296efc8586ea6f427b9295fbd30a3c3a46f diff --git a/source/libraries/wimp b/source/libraries/wimp index 3c0933eec..896e05182 160000 --- a/source/libraries/wimp +++ b/source/libraries/wimp @@ -1 +1 @@ -Subproject commit 3c0933eecb23a96624a2f61dbc259f04e297b016 +Subproject commit 896e05182734eed1c94c4f7d6acdf8e039ec675d diff --git a/source/packages/restG4 b/source/packages/restG4 index a29c27d1d..fb670a124 160000 --- a/source/packages/restG4 +++ b/source/packages/restG4 @@ -1 +1 @@ -Subproject commit a29c27d1d34331a2b40db6d2cad40c316bfc1870 +Subproject commit fb670a124f2280416851705e7f3e614908db62f7