You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by yi...@apache.org on 2024/02/26 19:10:39 UTC
(hudi) 01/01: [HUDI-6163] WIP
This is an automated email from the ASF dual-hosted git repository.
yihua pushed a commit to branch HUDI-6163-move-size-labeling
in repository https://gitbox.apache.org/repos/asf/hudi.git
commit c50d19d4cc14eb7502807d610f99fcf157d6b7c0
Author: Y Ethan Guo <et...@gmail.com>
AuthorDate: Mon Feb 26 11:09:06 2024 -0800
[HUDI-6163] WIP
---
.github/workflows/labeler.js | 68 ++++++++++++++++++++++++++++++++
.github/workflows/labeler.yml | 24 -----------
.github/workflows/scheduled_workflow.yml | 30 ++++++++++----
3 files changed, 90 insertions(+), 32 deletions(-)
diff --git a/.github/workflows/labeler.js b/.github/workflows/labeler.js
new file mode 100644
index 00000000000..740ad1f5c98
--- /dev/null
+++ b/.github/workflows/labeler.js
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+async function labelDocsPr({ github, context, prNumber }) {
+/*
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: prNumber,
+ labels: ['docs']
+ });
+
+ console.log(`- Labeled Docs PR: ${prNumber}`);*/
+}
+
+async function labelPrWithSize({ github, context, prNumber, prData }) {
+/*
+ console.log(`Label PR based on size: ${prNumber} ${prData.html_url}`);
+ const additions = prData.additions;
+ const deletions = prData.deletions;
+ const totalChanges = additions + deletions;
+
+ let label = "";
+
+ if (totalChanges <= 10) {
+ label = "size:XS";
+ } else if (totalChanges <= 100) {
+ label = "size:S";
+ } else if (totalChanges <= 300) {
+ label = "size:M";
+ } else if (totalChanges <= 1000) {
+ label = "size:L";
+ } else {
+ label = "size:XL";
+ }
+
+ // Apply the label
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: prNumber,
+ labels: [label]
+ });
+
+ console.log(`Total lines of changes: ${totalChanges}`);
+ console.log(`Label: ${label}`);*/
+}
+
+module.exports = {
+ labelDocsPr,
+ labelPrWithSize
+};
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
deleted file mode 100644
index d0b809c2958..00000000000
--- a/.github/workflows/labeler.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-name: Label PR
-
-on: [ pull_request ]
-
-jobs:
- labeler:
- runs-on: ubuntu-latest
- name: Label the PR size
- steps:
- - uses: codelytv/pr-size-labeler@v1
- with:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- xs_label: 'size-xs'
- xs_max_size: '10'
- s_label: 'size-s'
- s_max_size: '100'
- m_label: 'size-m'
- m_max_size: '500'
- l_label: 'size-l'
- l_max_size: '1000'
- xl_label: 'size-xl'
- fail_if_xl: 'false'
- github_api_url: 'api.github.com'
- files_to_ignore: ''
\ No newline at end of file
diff --git a/.github/workflows/scheduled_workflow.yml b/.github/workflows/scheduled_workflow.yml
index 4e17ee12990..2c536874019 100644
--- a/.github/workflows/scheduled_workflow.yml
+++ b/.github/workflows/scheduled_workflow.yml
@@ -21,10 +21,12 @@ on:
schedule:
# Runs every 5 minutes
- cron: '*/5 * * * *'
+ pull_request:
+ types: [ opened, edited, reopened, synchronize ]
permissions:
statuses: write
- pull-requests: read
+ pull-requests: write
issues: read
jobs:
@@ -46,7 +48,7 @@ jobs:
script: |
// Cron schedule may not be reliable so giving buffer time to avoid missing recent PRs
const since = new Date(new Date().getTime() - (900 * 1000)).toISOString();
- const query = `repo:${context.repo.owner}/${context.repo.repo} type:pr state:open base:master updated:>=${since}`;
+ const query = `repo:${context.repo.owner}/${context.repo.repo} type:pr state:open updated:>=${since}`;
const openPrs = await github.paginate(github.rest.search.issuesAndPullRequests, {
q: query,
sort: 'updated',
@@ -54,19 +56,31 @@ jobs:
per_page: 100
});
+ const { labelDocsPr, labelPrWithSize } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/labeler.js`);
const checkAzureCiAndCreateCommitStatus = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/azure_ci.js`);
console.log(`Number of PRs to process: ${openPrs.length}`);
for (const pr of openPrs) {
console.log(`*** Processing PR: ${pr.title}, URL: ${pr.html_url}`);
+ const { data: pullRequest } = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: pr.number
+ });
- if (!pr.body.includes('HOTFIX: SKIP AZURE CI')) {
- const { data: pullRequest } = await github.rest.pulls.get({
- owner: context.repo.owner,
- repo: context.repo.repo,
- pull_number: pr.number
- });
+ const targetBase = '';//pullRequest.base.ref;
+
+ // Label docs PR (targeting "asf-site" branch)
+ if (targetBase === 'asf-site') {
+ //await labelDocsPr({ github, context, pr.number });
+ }
+
+ // Label PR size
+ await labelPrWithSize({ github, context, pr.number, pullRequest });
+
+ // Check Azure CI and create commit status
+ if (targetBase === 'master' && !pr.body.includes('HOTFIX: SKIP AZURE CI')) {
const latestCommitHash = pullRequest.head.sha;
// Create commit status based on Azure CI report to PR