Skip to content

Commit e6622e0

Browse files
authored
feature: add fingerprint integration (#231)
# Why to dogfood `@expo/fingerprint`, this pr tries to the fingerprint integration. close [ENG-8599](https://linear.app/expo/issue/ENG-8599/integrate-expofingerprint-to-expo-github-action) # How this pr introduces two new actions, mainly designed for pull requests. ## fingerprint the action will check the fingerprint from the pr head commit against base commit and just output the fingerprint diff. this could be used for something like [pr labeler](https://github.com/Kudo/eas-app/blob/main/.github/workflows/pr-labeler.yml). ## preview-build the action will check the fingerprint from the pr head commit against base commit and create eas builds if necessary. [example workflow](https://github.com/Kudo/eas-app/blob/main/.github/workflows/pr-preview-eas-build.yml)
1 parent 7bc946c commit e6622e0

30 files changed

Lines changed: 239990 additions & 586 deletions

build/command/index.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20150,6 +20150,14 @@ module.exports = require("https");
2015020150

2015120151
/***/ }),
2015220152

20153+
/***/ 8188:
20154+
/***/ ((module) => {
20155+
20156+
"use strict";
20157+
module.exports = require("module");
20158+
20159+
/***/ }),
20160+
2015320161
/***/ 1808:
2015420162
/***/ ((module) => {
2015520163

@@ -20518,6 +20526,58 @@ async function easBuild(cmd) {
2051820526
}
2051920527
return JSON.parse(stdout);
2052020528
}
20529+
/**
20530+
* Create an new EAS build using the user-provided command.
20531+
*/
20532+
async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) {
20533+
let stdout = '';
20534+
let cmd = command;
20535+
if (!cmd.includes('--json')) {
20536+
cmd += ' --json';
20537+
}
20538+
if (!cmd.includes('--non-interactive')) {
20539+
cmd += ' --non-interactive';
20540+
}
20541+
if (!cmd.includes('--no-wait')) {
20542+
cmd += ' --no-wait';
20543+
}
20544+
try {
20545+
({ stdout } = await getExecOutput((await which('eas', true)) + ` ${cmd}`, extraArgs, {
20546+
cwd,
20547+
}));
20548+
}
20549+
catch (error) {
20550+
throw new Error(`Could not run command eas build, reason:\n${errorMessage(error)}`);
20551+
}
20552+
return JSON.parse(stdout);
20553+
}
20554+
/**
20555+
* Cancel an EAS build.
20556+
*/
20557+
async function cancelEasBuildAsync(cwd, buildId) {
20558+
try {
20559+
await getExecOutput(await which('eas', true), ['build:cancel', buildId], { cwd });
20560+
}
20561+
catch (e) {
20562+
info(`Failed to cancel build ${buildId}: ${errorMessage(e)}`);
20563+
}
20564+
}
20565+
/**
20566+
* Query the EAS BuildInfo from given buildId.
20567+
*/
20568+
async function queryEasBuildInfoAsync(cwd, buildId) {
20569+
try {
20570+
const { stdout } = await getExecOutput(await which('eas', true), ['build:view', buildId, '--json'], {
20571+
cwd,
20572+
silent: true,
20573+
});
20574+
return JSON.parse(stdout);
20575+
}
20576+
catch (e) {
20577+
info(`Failed to query eas build ${buildId}: ${errorMessage(e)}`);
20578+
}
20579+
return null;
20580+
}
2052120581
/**
2052220582
* Try to resolve the project info, by running 'expo config --type prebuild'.
2052320583
*/
@@ -20687,6 +20747,39 @@ function issueComment() {
2068720747
},
2068820748
];
2068920749
}
20750+
/**
20751+
* Get the commit message for a specific commit hash.
20752+
*/
20753+
async function getGitCommandMessageAsync(options, gitCommitHash) {
20754+
const github = githubApi({ token: options.token });
20755+
const result = await github.rest.git.getCommit({
20756+
...context.repo,
20757+
commit_sha: gitCommitHash,
20758+
});
20759+
return result.data.message;
20760+
}
20761+
/**
20762+
* True if the current event is a push to the default branch.
20763+
*/
20764+
function isPushDefaultBranchContext() {
20765+
return context.eventName === 'push' && context.ref === `refs/heads/${context.payload?.repository?.default_branch}`;
20766+
}
20767+
/**
20768+
* Get the pull request information that associated with a specific commit hash.
20769+
*/
20770+
async function getPullRequestFromGitCommitShaAsync(options, gitCommitHash) {
20771+
const github = githubApi({ token: options.token });
20772+
const results = await github.rest.repos.listPullRequestsAssociatedWithCommit({
20773+
...context.repo,
20774+
commit_sha: gitCommitHash,
20775+
});
20776+
return results.data.map(pr => ({
20777+
id: pr.id,
20778+
prNumber: pr.number,
20779+
prHeadCommitSha: pr.head.sha,
20780+
mergeCommitSha: pr.merge_commit_sha,
20781+
}));
20782+
}
2069020783

2069120784
// EXTERNAL MODULE: external "os"
2069220785
var external_os_ = __nccwpck_require__(2037);
@@ -20764,6 +20857,17 @@ function toolPath(name, version) {
2076420857
assert(process.env['RUNNER_TOOL_CACHE'], 'Could not resolve the local tool cache, RUNNER_TOOL_CACHE not defined');
2076520858
return path.join(process.env['RUNNER_TOOL_CACHE'], name, version, os.arch());
2076620859
}
20860+
/**
20861+
* Add extra `searchPath` to the global search path for require()
20862+
*/
20863+
function addGlobalNodeSearchPath(searchPath) {
20864+
const nodePath = process.env['NODE_PATH'] || '';
20865+
const delimiter = process.platform === 'win32' ? ';' : ':';
20866+
const nodePaths = nodePath.split(delimiter);
20867+
nodePaths.push(searchPath);
20868+
process.env['NODE_PATH'] = nodePaths.join(delimiter);
20869+
(__nccwpck_require__(8188).Module._initPaths)();
20870+
}
2076720871

2076820872
;// CONCATENATED MODULE: ./src/actions/command.ts
2076920873

0 commit comments

Comments
 (0)