diff --git a/.github/workflow-scripts/__tests__/extractIssueOncalls-test.js b/.github/workflow-scripts/__tests__/extractIssueOncalls-test.js deleted file mode 100644 index 7ad91ddc06a1..000000000000 --- a/.github/workflow-scripts/__tests__/extractIssueOncalls-test.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * 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 {extractIssueOncalls} = require('../extractIssueOncalls'); - -const userMap = { - '@g': '1785', - '@c': '1781', - '@s': '1272', - '@d': '1332', - '@m': '9555', - '@p': '6097', - '@f': '7565', -}; - -const schedule = { - '2025-04-01': ['@m', '@f'], - '2025-04-08': ['@g', '@d'], -}; - -describe('extractIssueOncalls', () => { - beforeEach(() => { - jest.clearAllMocks(); - jest.useFakeTimers('modern'); - }); - - afterEach(() => { - jest.useRealTimers(); - }); - it('extracts m and f on 6 of April', () => { - jest.setSystemTime(new Date(2025, 3, 6)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@m'], userMap['@f']]); - }); - - it('extracts m and f on 7 of April', () => { - jest.setSystemTime(new Date(2025, 3, 7)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@m'], userMap['@f']]); - }); - - it('extracts g and d on 8 of April', () => { - jest.setSystemTime(new Date(2025, 3, 8)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@g'], userMap['@d']]); - }); - - it('extracts g and d on 9 of April', () => { - jest.setSystemTime(new Date(2025, 3, 9)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@g'], userMap['@d']]); - }); - - it('extracts g and d on 10 of April', () => { - jest.setSystemTime(new Date(2025, 3, 10)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@g'], userMap['@d']]); - }); - - it('extracts g and d on 11 of April', () => { - jest.setSystemTime(new Date(2025, 3, 11)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@g'], userMap['@d']]); - }); - - it('extracts g and d on 12 of April', () => { - jest.setSystemTime(new Date(2025, 3, 12)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@g'], userMap['@d']]); - }); - - it('extracts g and d on 13 of April', () => { - jest.setSystemTime(new Date(2025, 3, 13)); - const oncalls = extractIssueOncalls(schedule, userMap); - expect(oncalls).toEqual([userMap['@g'], userMap['@d']]); - }); -}); diff --git a/.github/workflow-scripts/extractIssueOncalls.js b/.github/workflow-scripts/extractIssueOncalls.js deleted file mode 100644 index 3aa6748d69d7..000000000000 --- a/.github/workflow-scripts/extractIssueOncalls.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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]; -} - -/** - * You can invoke this script by doing: - * ``` - * node .github/workflow-scripts/extractIssueOncalls.js $DATA - * ``` - * - * the $DATA is stored in the github secrets as ONCALL_SCHEDULE variable. - * The format of the data is: - * ``` - * { - * \"userMap\": { - * \"discord_handle1\": \"discord_id1\", - * \"discord_handle2\": \"discord_id2\", - * ... - * }, - * \"schedule\": { - * \"2025-07-29\": [\"discord_handle1\", \"discord_handle2\"], - * \"2025-08-05\": [\"discord_handle3\", \"discord_handle4\"], - * ... - * } - * ``` - * - * When uploading the secret, make sure that the JSON strings are escaped! - * The script will fail otherwise, because GitHub will remove the `"` characters. - */ -function main() { - const configuration = process.argv[2]; - const {userMap, schedule} = JSON.parse(configuration); - 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, -}; diff --git a/.github/workflows/monitor-new-issues.yml b/.github/workflows/monitor-new-issues.yml deleted file mode 100644 index 476daf11880d..000000000000 --- a/.github/workflows/monitor-new-issues.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Monitor React Native New Issues - -on: - schedule: - - cron: '0 0,6,12,18 * * *' - workflow_dispatch: - -# Reminder for when we have to update the schedule (before Jan 2026): -# the secrets.ONCALL_SCHEDULE secret must be on a single line and must have all the `"` escaped as `\"`. -# Only a meta engineer can update it through the OSS internal portal. - -jobs: - monitor-issues: - runs-on: ubuntu-latest - if: github.repository == 'react/react-native' - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Set up Node.js - uses: ./.github/actions/setup-node - - 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: 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: 'react' - repo_name: 'react-native' - discord_webhook_url: '${{ secrets.DISCORD_WEBHOOK_URL }}' - discord_id_type: 'user' - discord_ids: '${{ env.oncall1 }},${{ env.oncall2 }}'