diff --git a/.github/actions/scripts/do_backports.js b/.github/actions/scripts/do_backports.js deleted file mode 100644 index a814c82fde..0000000000 --- a/.github/actions/scripts/do_backports.js +++ /dev/null @@ -1,43 +0,0 @@ - -async function getBackportComment(deps) { - // get all comments on the PR - const comments = await deps.github.rest.issues.listComments({ - owner: deps.context.repo.owner, - repo: deps.context.repo.repo, - issue_number: deps.context.issue.number - }); - - const backportComments = comments.data.filter( - (comment) => comment.body.includes("[backport]") - ); - - if (backportComments.length == 0) { - console.log("No backport comment found"); - return undefined; - } - const comment = backportComments.map(comment => comment.body).join("\n"); - return comment; -} - -async function getBackportBranches(deps) { - const comment = await getBackportComment(deps); - if (comment == undefined) { - return []; - } - console.log(comment); - - const lines = comment.split('\n'); - const backportLines = lines.filter((line) => { - return line.match(/^\s*- \[x\]/) !== null; - }); - - const backportBranches = backportLines.map((line) => { - return line.split(']')[1].trim(); - }); - - return backportBranches; -} - -module.exports = async ({ github, context }) => { - return await getBackportBranches({ github, context }); -}; diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml deleted file mode 100644 index 862e07969a..0000000000 --- a/.github/workflows/backport.yml +++ /dev/null @@ -1,167 +0,0 @@ -name: Backport a commit or PR across branches -on: - workflow_dispatch: - inputs: - commit_sha: - description: 'A commit SHA to backport (either commit_sha or pr_number must be provided)' - required: false - type: string - pr_number: - description: 'A merged PR to backport (either commit_sha or pr_number must be provided)' - required: false - type: number - base_branch: - description: 'The branch to backport to' - required: true - type: string - reviewer: - description: 'The GitHub username of a reviewer to request a review from (currently supports only one reviewer)' - required: false - type: string - workflow_call: - inputs: - commit_sha: - description: 'A commit SHA to backport (either commit_sha or pr_number must be provided)' - required: false - type: string - pr_number: - description: 'A merged PR to backport (either commit_sha or pr_number must be provided)' - required: false - type: number - base_branch: - description: 'The branch to backport to' - required: true - type: string - reviewer: - description: 'The GitHub username of a reviewer to request a review from (currently supports only one reviewer)' - required: false - type: string - -jobs: - get_commit_sha: - runs-on: self-hosted-docker-tiny - outputs: - result: ${{ steps.get_commit_sha.outputs.result }} - steps: - - name: Check Inputs - run: | - if [ -z "${{ inputs.commit_sha }}" ] && [ -z "${{ inputs.pr_number }}" ]; then - echo "Either commit_sha or pr_number must be provided" - exit 1 - fi - if [ -n "${{ inputs.commit_sha }}" ] && [ -n "${{ inputs.pr_number }}" ]; then - echo "Only one of commit_sha or pr_number can be provided" - exit 1 - fi - - name: Get Commit Sha - id: get_commit_sha - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - env: - commit_sha: ${{ inputs.commit_sha }} - pr_number: ${{ inputs.pr_number }} - with: - retries: 3 - script: | - const { commit_sha, pr_number } = process.env; - if (commit_sha) { - return commit_sha; - } - return await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pr_number - }).then(pull => { - return pull.data.merge_commit_sha; - }); - - do_backport: - runs-on: ubuntu-latest - needs: get_commit_sha - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - ref: ${{ inputs.base_branch }} - - name: Backport to ${{ inputs.base_branch }} - Create branch & push - id: create_branch - shell: bash - run: | - commit_sha="${{ needs.get_commit_sha.outputs.result }}" - base_branch="${{ inputs.base_branch }}" - new_branch="automation/backport-$commit_sha-$base_branch" - echo "Backporting commit $commit_sha to branch $base_branch (using branch $new_branch)" - git fetch origin $base_branch - git fetch origin $commit_sha - # TODO(#16006): should this be the original author instead? - git config user.email "splice-maintainers@digitalasset.com" - git config user.name "DA Automation" - git checkout -b $new_branch origin/$base_branch - git cherry-pick $commit_sha - git commit -m "[static]" --allow-empty - git push origin $new_branch - # output the backport branch name for use in the next step - echo "new_branch=$new_branch" >> "$GITHUB_OUTPUT" - - name: Backport to ${{ inputs.base_branch }} - Create PR - id: create_pr - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - env: - new_branch: ${{ steps.create_branch.outputs.new_branch }} - base_branch: ${{ inputs.base_branch }} - input_commit_sha: ${{ inputs.commit_sha }} - pr_number: ${{ inputs.pr_number }} - with: - # Switch the GH token from the default repo token to the one for - # canton-network-da. This ensures this is treated as a regular pull request - # that can trigger CI. - github-token: ${{ secrets.GH_ISSUES }} - retries: 3 - script: | - const { new_branch, base_branch, input_commit_sha, pr_number } = process.env; - const backport_what = input_commit_sha ? `commit ${input_commit_sha}` : `PR #${pr_number}`; - const title = `Backport ${backport_what} to ${base_branch}`; - return await github.rest.pulls.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: title, - head: new_branch, - base: base_branch, - body: `This PR was automatically created to backport ${backport_what} to ${base_branch}.` - }).then(pull => { - return pull.data.number; - }); - - name: Request review - if: ${{ inputs.reviewer }} - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - env: - reviewer: ${{ inputs.reviewer }} - pr_number: ${{ steps.create_pr.outputs.result }} - with: - retries: 3 - script: | - const { reviewer } = process.env; - await github.rest.pulls.requestReviewers({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: process.env.pr_number, - reviewers: [process.env.reviewer] - }); - notify_on_failure: - runs-on: self-hosted-docker-tiny - needs: do_backport - # If a PR was given for backporting from, notify on failure as a comment on that PR - if: ${{ failure() && inputs.pr_number }} - steps: - - name: Notify on failure - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - env: - pr_number: ${{ inputs.pr_number }} - base_branch: ${{ inputs.base_branch }} - with: - # TODO(#16006): link to the logs - retries: 3 - script: | - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: process.env.pr_number, - body: `Backport to branch ${process.env.base_branch} failed. Please check the logs for more information.`, - }); diff --git a/.github/workflows/backport_reminder.yml b/.github/workflows/backport_reminder.yml deleted file mode 100644 index c690477a01..0000000000 --- a/.github/workflows/backport_reminder.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Remind to backport PRs to release branches -on: - pull_request: - types: [opened, reopened] - paths: - - cluster/deployment/devnet/** - - cluster/deployment/testnet/** - - cluster/deployment/mainnet/** - - '**/expected-devnet.json' - - '**/expected-testnet.json' - - '**/expected-mainnet.json' - # TODO(#16006): other cases to consider: - # - All commits on a release-line branch - -jobs: - add_comment: - runs-on: self-hosted-docker-tiny - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Setup Node.js (in order to install npm packages) - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: '20.x' - - name: Install npm dependencies - run: npm install js-yaml - - name: Main script - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - retries: 3 - script: | - const jsyaml = require('js-yaml') - const script = require('.github/actions/scripts/backport_reminder.js') - await script({github, context, jsyaml}) diff --git a/.github/workflows/do_backports.yml b/.github/workflows/do_backports.yml deleted file mode 100644 index 2b554ae2f8..0000000000 --- a/.github/workflows/do_backports.yml +++ /dev/null @@ -1,41 +0,0 @@ - -# On merging a PR, automatically backport it to other branches as requested in a comment on that PR - -name: Auto-backport PRs to release branches -on: - pull_request: - types: - - closed - -jobs: - get_backport_branches: - if: github.event.pull_request.merged == true - runs-on: self-hosted-docker-tiny - outputs: - branches: ${{ steps.get_backport_branches.outputs.result }} - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Get backport branches - id: get_backport_branches - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - retries: 3 - script: | - const script = require('.github/actions/scripts/do_backports.js'); - return await script({github, context}); - backport_prs: - needs: get_backport_branches - if: needs.get_backport_branches.outputs.branches != '[]' && needs.get_backport_branches.outputs.branches != '' - strategy: - matrix: - branch: ${{ fromJSON(needs.get_backport_branches.outputs.branches) }} - fail-fast: false - uses: ./.github/workflows/backport.yml - # Grant access to secrets in order to use the ssh key to pull the submodule - secrets: inherit - with: - base_branch: ${{ matrix.branch }} - pr_number: ${{ github.event.pull_request.number }} - # Request the original PR author to review the backport PR (since this was approved by others - # and merged already, we don't need to request review from them) - reviewer: ${{ github.event.pull_request.user.login }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e48cab6cf8..8586929734 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -167,42 +167,9 @@ Java as early as possible. To convert, import `scala.jdk.CollectionConverters.*`. You can then use `asScala` and `asJava` methods. -## Porting between branches - -Note that we often maintain multiple branches in parallel, e.g. ones for the release-lines -that are deployed on Prod clusters, or ones for previous or coming major releases. It is -therefore quite common that we need to port commits between the different branches. - -This can of course be done manually using `git` commands and github UI, but we also have -automation to support it: - -Automatically on PRs: -- On every PR that satisfies a set of conditions, you will automatically get a reminder - with a list of suggested branches you may wish to port this PR to. Check the boxes of - those that fit (you can also edit the comment and add other branches if needed). -- Once the PR is merged, automation (in GitHub Actions) will pick up that reminder comment - and attempt to port this commit to the selected branches. If successful, you will be - asked to review the port PRs. Upon failure, a comment will be added to the original PR. -- Note that on any unmerged PR, you can add a comment yourself that includes the string - `[backport]`, and any checked check box in that comment will be assumed to be a branch - to which you wish to port this PR, e.g. a comment: - - [backport] - - \- [x] my-branch - - will cause your PR to be ported to the "my-branch" branch once merged. - -Manually: -- There is also a manually triggered workflow for porting PRs that have already been merged. - To use that, navigate to the ["Backport a commit or PR across branches" workflow in the repo's Actions page](https://github.com/DACH-NY/canton-network-node/actions/workflows/backport.yml), - and press "Run workflow". You will be asked for a merged PR or a Git commit hash to port from, - the branch to port to, and the reviewer to request the review from. Run the workflow to create - a PR to port your contributions. - ## Dev Docs We publish docs from each commit from `main` to -https://digital-asset.github.io/decentralized-canton-sync/. This can +https://hyperledger-labs.github.io/splice/. This can often be useful to answer support requests with a docs link even if those docs are still very recent.