mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 19:04:43 +03:00
devops: add auto driver Node.js roll bot (#15531)
This commit is contained in:
parent
fd1fae97b1
commit
9110d64917
2
.github/workflows/roll_chromium_build.yml
vendored
2
.github/workflows/roll_chromium_build.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: "PR: bump //browser_patches/chromium/BUILD_NUMBER"
|
||||
name: "PR: bump chromium/BUILD_NUMBER"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
|
@ -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
|
||||
|
44
.github/workflows/roll_driver_nodejs.yml
vendored
Normal file
44
.github/workflows/roll_driver_nodejs.yml
vendored
Normal file
@ -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',
|
||||
});
|
@ -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")
|
||||
|
49
utils/build/update-playwright-driver-version.mjs
Normal file
49
utils/build/update-playwright-driver-version.mjs
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user