mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
[RN][CI][DoNotCommit] Testing the action in CI
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const MSEC_IN_DAY = 1000 * 60 * 60 * 24;
|
||||
|
||||
function formatUsers(users) {
|
||||
console.log(`${users[0]} ${users[1]}`.trim());
|
||||
}
|
||||
|
||||
function extractUsersFromScheduleAndDate(schedule, userMap, date) {
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1; // 0 is January, 1 is February
|
||||
const day = date.getDate();
|
||||
const dateStr = `${year}-${month < 10 ? `0${month}` : month}-${day < 10 ? `0${day}` : day}`;
|
||||
const user1 = userMap[schedule[dateStr][0]];
|
||||
const user2 = userMap[schedule[dateStr][1]];
|
||||
return [user1, user2];
|
||||
}
|
||||
|
||||
function main() {
|
||||
const configFilePath = process.argv[2];
|
||||
// const {userMap, schedule} = JSON.parse(
|
||||
// String(fs.readFileSync(configFilePath, 'utf8').trim()),
|
||||
// );
|
||||
const {userMap, schedule} = JSON.parse(configFilePath);
|
||||
extractIssueOncalls(schedule, userMap);
|
||||
}
|
||||
|
||||
function extractIssueOncalls(schedule, userMap) {
|
||||
const now = new Date();
|
||||
const dayOfTheWeek = now.getDay(); // 0 is Sunday, 1 is Monday, etc.
|
||||
let users;
|
||||
if (dayOfTheWeek === 2) {
|
||||
// exact match in the schedule
|
||||
users = extractUsersFromScheduleAndDate(schedule, userMap, now);
|
||||
} else if (dayOfTheWeek < 2) {
|
||||
// sunday
|
||||
// go to the tuesday of the last week
|
||||
const lastWeekTuesday = new Date(now - (5 + dayOfTheWeek) * MSEC_IN_DAY);
|
||||
users = extractUsersFromScheduleAndDate(schedule, userMap, lastWeekTuesday);
|
||||
} else if (dayOfTheWeek > 1) {
|
||||
// go to the previous tuesday
|
||||
const thisWeekTuesday = new Date(now - (dayOfTheWeek - 2) * MSEC_IN_DAY);
|
||||
users = extractUsersFromScheduleAndDate(schedule, userMap, thisWeekTuesday);
|
||||
}
|
||||
formatUsers(users);
|
||||
return users;
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
void main();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
extractIssueOncalls,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{\"userMap\": {\"@gammax\": \"178528720146006016\", \"@cipolleschi\": \"178123834233323520\", \"@shubham43245\": \"1272116738070286377\", \"@devanshsaini11\": \"1332338450409721947\", \"@migueldaipre\": \"955564231233777716\", \"@princekt001\": \"609764643178807296\", \"@fabricator2953\": \"756592099826335930\"}, \"schedule\": { \"2025-02-18\": [\"@migueldaipre\", \"@shubham43245\"], \"2025-02-25\": [\"@gammax\", \"@princekt001\"], \"2025-03-04\": [\"@cipolleschi\", \"@fabricator2953\"], \"2025-03-11\": [\"@migueldaipre\", \"@devanshsaini11\"], \"2025-03-18\": [\"@gammax\", \"@shubham43245\"], \"2025-03-25\": [\"@cipolleschi\", \"@princekt001\"], \"2025-04-01\": [\"@migueldaipre\", \"@fabricator2953\"], \"2025-04-08\": [\"@gammax\", \"@devanshsaini11\"], \"2025-04-15\": [\"@cipolleschi\", \"@shubham43245\"], \"2025-04-22\": [\"@migueldaipre\", \"@princekt001\"], \"2025-04-29\": [\"@gammax\", \"@fabricator2953\"], \"2025-05-06\": [\"@cipolleschi\", \"@devanshsaini11\"], \"2025-05-13\": [\"@migueldaipre\", \"@shubham43245\"], \"2025-05-20\": [\"@gammax\", \"@princekt001\"], \"2025-05-27\": [\"@migueldaipre\", \"@fabricator2953\"], \"2025-06-03\": [\"@gammax\", \"@devanshsaini11\"], \"2025-06-10\": [\"@cipolleschi\", \"@shubham43245\"], \"2025-06-17\": [\"@migueldaipre\", \"@princekt001\"], \"2025-06-24\": [\"@gammax\", \"@fabricator2953\"], \"2025-07-01\": [\"@cipolleschi\", \"@devanshsaini11\"], \"2025-07-08\": [\"@migueldaipre\", \"@shubham43245\"], \"2025-07-15\": [\"@gammax\", \"@princekt001\"], \"2025-07-22\": [\"@cipolleschi\", \"@fabricator2953\"], \"2025-07-29\": [\"@migueldaipre\", \"@devanshsaini11\"], \"2025-08-05\": [\"@gammax\", \"@shubham43245\"], \"2025-08-12\": [\"@cipolleschi\", \"@princekt001\"], \"2025-08-19\": [\"@migueldaipre\", \"@fabricator2953\"], \"2025-08-26\": [\"@gammax\", \"@devanshsaini11\"], \"2025-09-02\": [\"@cipolleschi\", \"@shubham43245\"], \"2025-09-09\": [\"@migueldaipre\", \"@princekt001\"], \"2025-09-16\": [\"@gammax\", \"@fabricator2953\"], \"2025-09-23\": [\"@cipolleschi\", \"@devanshsaini11\"], \"2025-09-30\": [\"@migueldaipre\", \"@shubham43245\"], \"2025-10-07\": [\"@gammax\", \"@princekt001\"], \"2025-10-14\": [\"@cipolleschi\", \"@fabricator2953\"], \"2025-10-21\": [\"@migueldaipre\", \"@devanshsaini11\"], \"2025-10-28\": [\"@gammax\", \"@shubham43245\"], \"2025-11-04\": [\"@cipolleschi\", \"@princekt001\"], \"2025-11-11\": [\"@migueldaipre\", \"@fabricator2953\"], \"2025-11-18\": [\"@gammax\", \"@devanshsaini11\"], \"2025-11-25\": [\"@cipolleschi\", \"@shubham43245\"], \"2025-12-02\": [\"@migueldaipre\", \"@princekt001\"], \"2025-12-09\": [\"@gammax\", \"@fabricator2953\"], \"2025-12-16\": [\"@cipolleschi\", \"@devanshsaini11\"], \"2025-12-23\": [\"@migueldaipre\", \"@shubham43245\"], \"2025-12-30\": [\"@gammax\", \"@princekt001\"]}}
|
||||
@@ -1,6 +1,7 @@
|
||||
name: Monitor React Native New Issues
|
||||
|
||||
on:
|
||||
pull_request: #to remove before landing
|
||||
schedule:
|
||||
- cron: "0 0,6,12,18 * * *"
|
||||
workflow_dispatch:
|
||||
@@ -9,19 +10,35 @@ jobs:
|
||||
monitor-issues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Monitor New Issues
|
||||
uses: react-native-community/repo-monitor@v1.0.1
|
||||
with:
|
||||
task: "monitor-issues"
|
||||
git_secret: ${{ secrets.GITHUB_TOKEN }}
|
||||
notifier: "discord"
|
||||
fetch_data_interval: 6
|
||||
repo_owner: "facebook"
|
||||
repo_name: "react-native"
|
||||
discord_webhook_url: "${{ secrets.DISCORD_WEBHOOK_URL }}"
|
||||
discord_id_type: "role"
|
||||
discord_ids: "1339243367841927228"
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/yarn-install
|
||||
- name: Extract next oncall
|
||||
run: |
|
||||
ONCALLS=$(node ./.github/workflow-scripts/extractIssueOncalls.js "${{ secrets.ONCALL_SCHEDULE }}" )
|
||||
ONCALL1=$(echo $ONCALLS | cut -d ' ' -f 1)
|
||||
ONCALL2=$(echo $ONCALLS | cut -d ' ' -f 2)
|
||||
echo "oncall1=$ONCALL1" >> $GITHUB_ENV
|
||||
echo "oncall2=$ONCALL2" >> $GITHUB_ENV
|
||||
- name: Print oncalls
|
||||
run: |
|
||||
echo "oncall1: ${{ env.oncall1 }}"
|
||||
echo "oncall2: ${{ env.oncall2 }}"
|
||||
# Uncomment before landing
|
||||
# - name: Monitor New Issues
|
||||
# uses: react-native-community/repo-monitor@v1.0.1
|
||||
# with:
|
||||
# task: "monitor-issues"
|
||||
# git_secret: ${{ secrets.GITHUB_TOKEN }}
|
||||
# notifier: "discord"
|
||||
# fetch_data_interval: 6
|
||||
# repo_owner: "facebook"
|
||||
# repo_name: "react-native"
|
||||
# discord_webhook_url: "${{ secrets.DISCORD_WEBHOOK_URL }}"
|
||||
# discord_id_type: "role"
|
||||
# discord_ids: "${{ env.oncall1 }},${{ env.oncall2 }}"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
## Summary:
|
||||
|
||||
Test Automation for issue triage
|
||||
## Changelog:
|
||||
[Internal] -
|
||||
|
||||
## Test Plan:
|
||||
GHA
|
||||
Reference in New Issue
Block a user