Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: automate compat-data update #14248

Merged
merged 16 commits into from Jun 1, 2022
70 changes: 70 additions & 0 deletions .github/workflows/update-compat-data.yml
@@ -0,0 +1,70 @@
name: Update compat data
env:
YARN_ENABLE_SCRIPTS: false # disable post-install scripts
on:
workflow_dispatch:
inputs: {}
schedule:
- cron: "0 0 * * 5"

jobs:
createPullRequest:
name: Update compat-table
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: kangax/compat-table
path: packages/babel-compat-data/build/compat-table
nicolo-ribaudo marked this conversation as resolved.
Show resolved Hide resolved
- name: Use Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "*"
- name: Get latest kangax/compat-data commit
id: lastCommit
run: echo "::set-output name=sha1::$(node ./scripts/update-compat-data/get-last-commit.sh)"
- name: Update compat-data commit
run: echo ${{ steps.lastCommit.outputs.sha1 }} | ./scripts/update-compat-data/bump-data-compat-version.sh
- name: Check if it has been updated
run: |
[[ -z $(git status -s) ]] &&
echo "::set-output name=updated::false" ||
echo "::set-output name=updated::true"
id: updated
- name: Bootstrap
if: steps.updated.outputs.updated == 'true'
run: make bootstrap
- name: Run update script
if: steps.updated.outputs.updated == 'true'
run: make build-compat-data
- name: Update tests
if: steps.updated.outputs.updated == 'true'
run: yarn jest
env:
OVERWRITE: true
- name: Update tests (Babel 8)
if: steps.updated.outputs.updated == 'true'
run: yarn jest
env:
OVERWRITE: true
BABEL_8_BREAKING: true
- name: Commit changes
if: steps.updated.outputs.updated == 'true'
run: |
git config user.name "Babel Bot"
git config user.email "babel-bot@users.noreply.github.com"
git checkout -b update-compat-data
git commit -am "chore: update compat data to ${{ steps.lastCommit.outputs.sha1 }}"
git push --force origin update-compat-data
- name: Create Pull Request
if: steps.updated.outputs.updated == 'true'
uses: babel/actions/create-pull-request@v2
with:
token: ${{ secrets.BOT_TOKEN }}
branch: update-compat-data
title: Update compat data
description: Update compat data to [${{ steps.lastCommit.outputs.sha1 }}](https://github.com/kangax/compat-table/commit/${{ steps.lastCommit.outputs.sha1 }}).
labels: |
area: compat-data
repo automation :robot:
50 changes: 13 additions & 37 deletions .github/workflows/update-parser-tests.yml
Expand Up @@ -12,8 +12,9 @@ permissions:

jobs:
createPullRequest:
name: Update parser test262 tests
permissions:
contents: write # for Git to git push
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -47,40 +48,15 @@ jobs:
git commit -am "chore: update test262 to ${{ steps.test262.outputs.sha1 }}"
git push --force origin update-test262-parser
- name: Create Pull Request
uses: actions/github-script@v4
uses: babel/actions/create-pull-request@v2
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const base = process.env.GITHUB_REF.replace("refs/heads/", "");
const requestParam = {
owner: context.repo.owner,
repo: context.repo.repo,
head: context.repo.owner + ":update-test262-parser",
base: base,
state: "open"
};
const result = await github.pulls.list(requestParam);
console.log("Open PR request: ", requestParam);
console.log("Open PR response: ", result);
const prs = result.data;
if (prs.length === 0) {
const requestParam = {
owner: context.repo.owner,
repo: context.repo.repo,
head: "update-test262-parser",
base: base,
maintainer_can_modify: true,
title: "Update test262",
body: "Update test262 to [${{ steps.test262.outputs.sha1 }}](https://github.com/tc39/test262/commit/${{ steps.test262.outputs.sha1 }}).",
};
const result = await github.pulls.create(requestParam);
console.log("Create PR request: ", requestParam)
console.log("Create PR response: ", result);

github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: result.data.number,
labels: ["area: test262", "repo automation :robot:"]
})
}
token: ${{ secrets.BOT_TOKEN }}
branch: update-test262-parser
commit-user: Babel Bot
commit-email: babel-bot@users.noreply.github.com
commit-title: chore: update test262 to ${{ steps.test262.outputs.sha1 }}
pr-title: Update test262
pr-description: Update test262 to [${{ steps.test262.outputs.sha1 }}](https://github.com/tc39/test262/commit/${{ steps.test262.outputs.sha1 }}).
pr-labels: |
area: test262
repo automation :robot:
7 changes: 7 additions & 0 deletions scripts/update-compat-data/bump-data-compat-version.sh
@@ -0,0 +1,7 @@
#!/bin/sh
# read given commit SHA1 from stdin, update to COMPAT_TABLE_COMMIT in download-compat-table.sh
# usage:
# ./scripts/update-compat-data/get-last-commit.sh | ./scripts/update-compat-data/bump-data-compat-version.sh

set -e
perl -i -pe 's/^COMPAT_TABLE_COMMIT.+$/COMPAT_TABLE_COMMIT='$(cat)'/' ./packages/babel-compat-data/scripts/download-compat-table.sh
4 changes: 4 additions & 0 deletions scripts/update-compat-data/get-last-commit.sh
@@ -0,0 +1,4 @@
set -e
GIT_DIR=./packages/babel-compat-data/build/compat-table
git fetch -q origin HEAD
git rev-parse FETCH_HEAD