mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
767f8e0249
Summary: allow-large-files When working on https://github.com/facebook/react-native/pull/34614, danger is failing because it doesn't share `node_modules` with the root directory where `typescript` is installed as we added it as a parser in our eslint config. By setting `bots` as a yarn workspace, dependencies are all installed under the root `node_modules` folder and in local testing (detailed in test section) we no longer have the `typescript module not found` error. However, danger will continue to fail on https://github.com/facebook/react-native/pull/34614 as the `danger_pr` Github action runs from what's defined on `main`. Once these changes land, I can rebase https://github.com/facebook/react-native/pull/34614 on it and danger's eslint should pass. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal][Fixed] - Add `bots` directory as a yarn workspace and update `danger_pr` Github action Pull Request resolved: https://github.com/facebook/react-native/pull/34652 Test Plan: To verify this fix I had to run: ``` react-native $ yarn && cd bots react-native/bots$ yarn run danger pr https://github.com/facebook/react-native/pull/34614 ``` which resulted in ``` ❯ yarn run danger pr https://github.com/facebook/react-native/pull/34614 yarn run v1.22.19 $ lunaleaps/react-native/node_modules/.bin/danger pr https://github.com/facebook/react-native/pull/34614 Starting Danger PR on facebook/react-native#34614 Danger: ✓ found only warnings, not failing the build ## Warnings 🔒 package.json - <i>Changes were made to package.json. This will require a manual import by a Facebook employee.</i> ✨ Done in 12.78s. ``` Verified this also on another PR: ``` yarn run danger pr https://github.com/facebook/react-native/pull/34650 ``` Reviewed By: NickGerleman Differential Revision: D39435286 Pulled By: lunaleaps fbshipit-source-id: 8c82f49facf162f4fc0918e3abd95eb7e4ad1e37
87 lines
2.2 KiB
JavaScript
87 lines
2.2 KiB
JavaScript
/**
|
|
* 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
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const {
|
|
CIRCLE_BUILD_URL,
|
|
GITHUB_OWNER,
|
|
GITHUB_PR_NUMBER,
|
|
GITHUB_REPO,
|
|
GITHUB_SHA,
|
|
GITHUB_TOKEN,
|
|
} = process.env;
|
|
|
|
const {
|
|
createOrUpdateComment,
|
|
validateEnvironment: validateEnvironmentForMakeComment,
|
|
} = require('./make-comment');
|
|
|
|
/**
|
|
* Creates or updates a comment with specified pattern.
|
|
* @param {{ auth: string; owner: string; repo: string; issue_number: string; }} params
|
|
* @param {string} buildURL link to circleCI build
|
|
* @param {string} commitSha github sha of PR
|
|
*/
|
|
function postArtifactLink(params, buildUrl, commitSha) {
|
|
// build url link is redirected by CircleCI so appending `/artifacts` doesn't work
|
|
const artifactLink = buildUrl;
|
|
const comment = [
|
|
`PR build artifact${
|
|
commitSha != null ? ` for ${commitSha}` : ''
|
|
} is ready.`,
|
|
`To use, download tarball from "Artifacts" tab in [this CircleCI job](${artifactLink}) then run \`yarn add <path to tarball>\` in your React Native project.`,
|
|
].join('\n');
|
|
createOrUpdateComment(params, comment);
|
|
}
|
|
|
|
/**
|
|
* Validates that required environment variables are set.
|
|
* @returns {boolean} `true` if everything is in order; `false` otherwise.
|
|
*/
|
|
function validateEnvironment() {
|
|
if (
|
|
!validateEnvironmentForMakeComment() ||
|
|
!CIRCLE_BUILD_URL ||
|
|
!GITHUB_SHA
|
|
) {
|
|
if (!GITHUB_SHA) {
|
|
console.error("Missing GITHUB_SHA. This should've been set by the CI.");
|
|
}
|
|
if (!CIRCLE_BUILD_URL) {
|
|
console.error(
|
|
"Missing CIRCLE_BUILD_URL. This should've been set by the CI.",
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
console.log(` GITHUB_SHA=${GITHUB_SHA}`);
|
|
console.log(` CIRCLE_BUILD_URL=${CIRCLE_BUILD_URL}`);
|
|
|
|
return true;
|
|
}
|
|
|
|
if (!validateEnvironment()) {
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
const params = {
|
|
auth: GITHUB_TOKEN,
|
|
owner: GITHUB_OWNER,
|
|
repo: GITHUB_REPO,
|
|
issue_number: GITHUB_PR_NUMBER,
|
|
};
|
|
postArtifactLink(params, CIRCLE_BUILD_URL, GITHUB_SHA);
|
|
} catch (error) {
|
|
console.error(error);
|
|
process.exitCode = 1;
|
|
}
|