Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

devops: add cherry-pick bot (#16419)

Max Schmittae7d767e5826
diff --git a/.github/workflows/cherry_pick_into_release_branch.yml b/.github/workflows/cherry_pick_into_release_branch.yml
new file mode 100644
index 0000000000..8a70defe4b
--- /dev/null
+++ b/.github/workflows/cherry_pick_into_release_branch.yml
@@ -0,0 +1,77 @@
+name: Cherry-pick into release branch
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ type: string
+ description: Version number, e.g. 1.25
+ required: true
+ commit_hashes:
+ type: string
+ description: Comma-separated list of commit hashes to cherry-pick
+ required: true
+
+jobs:
+ roll:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Validate input version number
+ run: |
+ VERSION="${{ github.event.inputs.version }}"
+ if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
+ echo "Version is not a two digit semver version"
+ exit 1
+ fi
+ - uses: actions/checkout@v2
+ with:
+ ref: release-${{ github.event.inputs.version }}
+ fetch-depth: 0
+ - name: Cherry-pick commits
+ run: |
+ for COMMIT_HASH in $(echo "${{ github.event.inputs.commit_hashes }}" | tr "," "\n"); do
+ git cherry-pick --no-commit "$COMMIT_HASH"
+
+ COMMIT_MESSAGE=$(node -e '
+ console.log(process.argv[1])
+ const match = /^(.*) (\(#\d+\))$/.exec(process.argv[1]);
+ if (!match) {
+ console.log(process.argv[1]);
+ process.exit(0);
+ }
+ console.log(`chery-pick${match[2]}: ${match[1]}`);
+ ' $(git show -s --format=%B $COMMIT_HASH))
+
+ git commit -m "$COMMIT_MESSAGE"
+ done
+ LAST_COMMIT_MESSAGE=$(git show -s --format=%B)
+ echo "::set-output name=PR_TITLE::$LAST_COMMIT_MESSAGE"
+ - name: Prepare branch
+ id: prepare-branch
+ run: |
+ BRANCH_NAME="cherry-pick-${{ github.event.inputs.version }}-$(date +%Y-%m-%d-%H-%M-%S)"
+ echo "::set-output name=BRANCH_NAME::$BRANCH_NAME"
+ git config --global user.name github-actions
+ git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
+ git checkout -b "$BRANCH_NAME"
+ git push origin $BRANCH_NAME
+ - name: Create Pull Request
+ uses: actions/github-script@v6
+ with:
+ github-token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
+ script: |
+ const readableCommitHashesList = '${{ github.event.inputs.commit_hashes }}'.split(',').map(hash => `- ${hash}`).join('\n');
+ const response = await github.pulls.create({
+ owner: 'microsoft',
+ repo: 'playwright',
+ head: 'microsoft:${{ steps.prepare-branch.outputs.BRANCH_NAME }}',
+ base: 'main',
+ title: '${{ steps.prepare-branch.outputs.PR_TITLE }}',
+ body: `This PR cherry-picks the following commits:\n\n${readableCommitHashesList}`,
+ });
+ await github.issues.addLabels({
+ owner: 'microsoft',
+ repo: 'playwright',
+ issue_number: response.data.number,
+ labels: ['CQ1'],
+ });
diff --git a/.github/workflows/roll_browser_into_playwright.yml b/.github/workflows/roll_browser_into_playwright.yml
index 4fb56fc74e..2085178edf 100644
--- a/.github/workflows/roll_browser_into_playwright.yml
+++ b/.github/workflows/roll_browser_into_playwright.yml
@@ -24,7 +24,6 @@ jobs:
- name: Prepare branch
id: prepare-branch
run: |
- BASE_POSITION="${{ steps.bump-chromium.outputs.BASE_POSITION }}"
BRANCH_NAME="roll-into-pw-${{ github.event.client_payload.browser }}/${{ github.event.client_payload.revision }}"
echo "::set-output name=BRANCH_NAME::$BRANCH_NAME"
git config --global user.name github-actions