mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Cleanup the commitlies code (#38889)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38889 As we don't really use the commitlies code in CircleCI, I'm cleaning up some of the code used to publish artifacts to the user. Changelog: [Internal] [Changed] - Cleanup the commitlies code Reviewed By: cipolleschi Differential Revision: D48189398 fbshipit-source-id: c4591ee290eba49224322d44a32052ff292ccbed
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5140d6438d
commit
0a84952ce5
+2
-17
@@ -17,8 +17,6 @@ references:
|
||||
environment:
|
||||
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
|
||||
# The public github tokens are publicly visible by design
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_A: &github_pullbot_token_a "a6edf8e8d40ce4e8b11a"
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_B: &github_pullbot_token_b "150e1341f4dd9c944d2a"
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: &github_analysisbot_token_a "312d354b5c36f082cfe9"
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: &github_analysisbot_token_b "07973d757026bdd9f196"
|
||||
# Homebrew currently breaks while updating:
|
||||
@@ -36,8 +34,6 @@ references:
|
||||
# Repeated here, as the environment key in this executor will overwrite the one in defaults
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: *github_analysisbot_token_a
|
||||
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: *github_analysisbot_token_b
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_A: *github_pullbot_token_a
|
||||
- PUBLIC_PULLBOT_GITHUB_TOKEN_B: *github_pullbot_token_b
|
||||
|
||||
hermes_workspace_root: &hermes_workspace_root
|
||||
/tmp/hermes
|
||||
@@ -1914,7 +1910,7 @@ jobs:
|
||||
paths:
|
||||
- maven-local
|
||||
|
||||
# START: Commitlies
|
||||
# START: Dry-run
|
||||
# Provide a react-native package for this commit as a Circle CI release artifact.
|
||||
- when:
|
||||
condition:
|
||||
@@ -1936,18 +1932,7 @@ jobs:
|
||||
root: .
|
||||
paths:
|
||||
- build/*
|
||||
# END: Commitlies
|
||||
|
||||
# START: Commits from pull requests
|
||||
# When building commits from pull requests, leave a comment on the PR with a link to build artifacts
|
||||
- when:
|
||||
condition:
|
||||
matches: { pattern: '^pull\/.*$', value: << pipeline.git.branch >> }
|
||||
steps:
|
||||
- run:
|
||||
name: Post link to PR build artifacts (pull-bot)
|
||||
command: GITHUB_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" scripts/circleci/post-artifacts-link.sh || true
|
||||
# END: Commits from pull requests
|
||||
# END: Dry-run
|
||||
|
||||
# START: Stable releases
|
||||
- when:
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
'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;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
# 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.
|
||||
|
||||
GITHUB_OWNER=${CIRCLE_PROJECT_USERNAME:-facebook} \
|
||||
GITHUB_REPO=${CIRCLE_PROJECT_REPONAME:-react-native} \
|
||||
GITHUB_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" \
|
||||
GITHUB_REF=${CIRCLE_BRANCH} \
|
||||
GITHUB_SHA=${CIRCLE_SHA1} \
|
||||
exec node packages/react-native-bots/post-artifacts-link.js
|
||||
Reference in New Issue
Block a user