diff --git a/.github/workflows/roll_chromium_build.yml b/.github/workflows/roll_chromium_build.yml index d6f50bad3e..9a766e1197 100644 --- a/.github/workflows/roll_chromium_build.yml +++ b/.github/workflows/roll_chromium_build.yml @@ -1,4 +1,4 @@ -name: "PR: bump //browser_patches/chromium/BUILD_NUMBER" +name: "PR: bump chromium/BUILD_NUMBER" on: workflow_dispatch: schedule: diff --git a/.github/workflows/roll_chromium_tip_of_treebuild.yml b/.github/workflows/roll_chromium_tip_of_treebuild.yml index c25c268c0a..a55d641444 100644 --- a/.github/workflows/roll_chromium_tip_of_treebuild.yml +++ b/.github/workflows/roll_chromium_tip_of_treebuild.yml @@ -1,4 +1,4 @@ -name: "PR: bump //browser_patches/chromium-tip-of-tree/BUILD_NUMBER" +name: "PR: bump chromium-tip-of-tree/BUILD_NUMBER" on: workflow_dispatch: schedule: @@ -20,7 +20,7 @@ jobs: fi echo "::set-output name=HAS_CHANGES::1" CURRENT_DATE=$(date +%Y-%b-%d) - BRANCH_NAME="roll-chromium/${CURRENT_DATE}" + BRANCH_NAME="roll-tip-of-tree-chromium/${CURRENT_DATE}" echo "::set-output name=BRANCH_NAME::$BRANCH_NAME" echo "::set-output name=CURRENT_DATE::$CURRENT_DATE" git config --global user.name github-actions diff --git a/.github/workflows/roll_driver_nodejs.yml b/.github/workflows/roll_driver_nodejs.yml new file mode 100644 index 0000000000..5a2ade5977 --- /dev/null +++ b/.github/workflows/roll_driver_nodejs.yml @@ -0,0 +1,44 @@ +name: "PR: bump driver Node.js" +on: + workflow_dispatch: + schedule: + # At 10:00am UTC (3AM PST) every tuesday and thursday to roll to new Node.js driver + - cron: "0 10 * * 2,4" +jobs: + trigger-nodejs-roll: + name: Trigger Roll + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: node utils/build/update-playwright-driver-version.mjs + - name: Prepare branch + id: prepare-branch + run: | + if [[ "$(git status --porcelain)" == "" ]]; then + echo "there are no changes"; + exit 0; + fi + echo "::set-output name=HAS_CHANGES::1" + BRANCH_NAME="roll-driver-nodejs/$(date +%Y-%b-%d)" + 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 add . + git commit -m "chore(driver): roll driver to recent Node.js LTS version" + git push origin $BRANCH_NAME + - name: Create Pull Request + if: ${{ steps.prepare-branch.outputs.HAS_CHANGES == '1' }} + uses: actions/github-script@v4 + with: + script: | + await github.pulls.create({ + owner: 'microsoft', + repo: 'playwright', + head: 'microsoft:${{ steps.prepare-branch.outputs.BRANCH_NAME }}', + base: 'main', + title: 'chore(driver): roll driver to recent Node.js LTS version', + }); diff --git a/utils/build/build-playwright-driver.sh b/utils/build/build-playwright-driver.sh index ee551a4d99..4bbae23689 100755 --- a/utils/build/build-playwright-driver.sh +++ b/utils/build/build-playwright-driver.sh @@ -4,7 +4,7 @@ set -x trap "cd $(pwd -P)" EXIT SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)" -NODE_VERSION="16.13.0" +NODE_VERSION="16.13.0" # autogenerated via ./update-playwright-driver-version.mjs"""""" cd "$(dirname "$0")" PACKAGE_VERSION=$(node -p "require('../../package.json').version") diff --git a/utils/build/update-playwright-driver-version.mjs b/utils/build/update-playwright-driver-version.mjs new file mode 100644 index 0000000000..08c4e5d739 --- /dev/null +++ b/utils/build/update-playwright-driver-version.mjs @@ -0,0 +1,49 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fs from 'fs'; +import url from 'url'; +import path from 'path'; +import https from 'https'; + +const currentFilePath = url.fileURLToPath(import.meta.url); +const buildFilePath = path.join(path.dirname(currentFilePath), 'build-playwright-driver.sh'); +const latestNodeJsLts = await getLatestNodeJsVersion(); + +refreshBuildScriptVersionNumber(latestNodeJsLts, buildFilePath); +console.log(`Updated build script ${path.relative(process.cwd(), buildFilePath)} to Node.js ${latestNodeJsLts}`); + +function getLatestNodeJsVersion() { + return new Promise((resolve, reject) => { + https.get('https://nodejs.org/dist/index.json', res => { + let content = ''; + res.on('data', chunk => content += chunk); + res.on('end', () => { + if (res.statusCode !== 200) + reject(new Error(`Failed to get nodejs version, status code: ${res.statusCode}`)); + const version = JSON.parse(content); + const latestLts = version.find(release => release.lts); + resolve(latestLts.version.slice(1)); + }); + }); + }); +} + +function refreshBuildScriptVersionNumber(newNodeJsVersion, buildScriptPath) { + const replacementRegex = new RegExp(`(NODE_VERSION=")(.*)(" # autogenerated via \\.\/${path.basename(currentFilePath).replace('.', '\\.')})`); + let buildFile = fs.readFileSync(buildFilePath, 'utf8'); + buildFile = buildFile.replace(replacementRegex, `$1${latestNodeJsLts}$3"`); + fs.writeFileSync(buildFilePath, buildFile); +}