mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a82be3e3e | ||
|
|
020be2c617 | ||
|
|
331a5abc41 | ||
|
|
42d64cf920 | ||
|
|
65ee05557f | ||
|
|
b3e53555d9 |
No files matched your search
@@ -8,7 +8,7 @@ inputs:
|
||||
|
||||
node-version:
|
||||
description: Version of Node to use
|
||||
default: 18.x
|
||||
default: 20.x
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
@@ -38,6 +38,8 @@ jobs:
|
||||
steps:
|
||||
- name: 🏗 Setup repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.EXPOBOT_GITHUB_TOKEN }}
|
||||
|
||||
- name: 🏗 Setup runner
|
||||
uses: ./.github/actions/setup
|
||||
|
||||
@@ -89,6 +89,7 @@ jobs:
|
||||
run: |
|
||||
eas init --id ${{ secrets.EXPO_PROJECT_ID }} --force --non-interactive
|
||||
echo $(jq '.expo.runtimeVersion.policy = "sdkVersion"' app.json) > app.json
|
||||
echo $(jq '.expo.scheme = ["expogithubaction", "ega"]' app.json) > app.json
|
||||
|
||||
- name: 🚀 Create preview (without comment)
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
@@ -164,6 +165,29 @@ jobs:
|
||||
throw new Error('Message output is empty');
|
||||
}
|
||||
|
||||
- name: 🚀 Create preview (with custom app scheme)
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
uses: ./preview
|
||||
id: custom-app-scheme
|
||||
env:
|
||||
EXPO_TEST_GITHUB_PULL: 206
|
||||
with:
|
||||
app-scheme: thisisacustomscheme
|
||||
working-directory: ./temp
|
||||
command: eas update --branch test --message "This is a test"
|
||||
comment: false
|
||||
|
||||
- name: 🧪 Comment has custom app scheme
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const comment = `${{ steps.custom-app-scheme.outputs.comment }}`
|
||||
if (!comment || !comment.includes('thisisacustomscheme')) {
|
||||
console.log({ comment });
|
||||
throw new Error('Message output does not include the app scheme from action input');
|
||||
}
|
||||
|
||||
preview-comment:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
## [8.1.0](https://github.com/expo/expo-github-action/compare/8.0.0...8.1.0) (2023-11-24)
|
||||
|
||||
|
||||
### New features
|
||||
|
||||
* add fingerprint integration ([#231](https://github.com/expo/expo-github-action/issues/231)) ([e6622e0](https://github.com/expo/expo-github-action/commit/e6622e076de31220ec97e3d7494de70cf1ab85b2))
|
||||
* add readme for preview-build and fingerprint action ([#232](https://github.com/expo/expo-github-action/issues/232)) ([acc171b](https://github.com/expo/expo-github-action/commit/acc171bb5e34cd76bf152307e562bb49e7743b94)), closes [/github.com/expo/expo-github-action/pull/231#pullrequestreview-1628540314](https://github.com/expo//github.com/expo/expo-github-action/pull/231/issues/pullrequestreview-1628540314)
|
||||
* **preview:** add update manifest permalinks to the output ([#245](https://github.com/expo/expo-github-action/issues/245)) ([331a5ab](https://github.com/expo/expo-github-action/commit/331a5abc4196b7590363c2b3ec842a0a17f98fa2))
|
||||
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* **preview:** allow multiple `app.json` schemes ([#244](https://github.com/expo/expo-github-action/issues/244)) ([42d64cf](https://github.com/expo/expo-github-action/commit/42d64cf92010d7210784c0f30bcaa611d8bae55d))
|
||||
|
||||
|
||||
### Code changes
|
||||
|
||||
* update error handling to node 20 standards ([#243](https://github.com/expo/expo-github-action/issues/243)) ([65ee055](https://github.com/expo/expo-github-action/commit/65ee05557f89a7804e36b2d3fe4f3d33aea7011a))
|
||||
* update workflows and repository to use Bun ([#241](https://github.com/expo/expo-github-action/issues/241)) ([7f1c170](https://github.com/expo/expo-github-action/commit/7f1c170873ddbadfb0ba311dd94b43d14c795ee3))
|
||||
* upgrade all actions to run on node 20 ([#242](https://github.com/expo/expo-github-action/issues/242)) ([b3e5355](https://github.com/expo/expo-github-action/commit/b3e53555d9effcab01011226c5e811c263a449cb))
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* **ci:** update release flow with new service account ([#238](https://github.com/expo/expo-github-action/issues/238)) ([e289d93](https://github.com/expo/expo-github-action/commit/e289d93e119801f899eb2b94d80d92718172dba3))
|
||||
* update release workflow actions ([#239](https://github.com/expo/expo-github-action/issues/239)) ([57dcabe](https://github.com/expo/expo-github-action/commit/57dcabe749340c8c995ee0334cd7c547c35770d0))
|
||||
|
||||
|
||||
### Documentation changes
|
||||
|
||||
* add link to breaking change pull request ([9e1a8c8](https://github.com/expo/expo-github-action/commit/9e1a8c8343d0f9405717e103c71e2e3ce9286bbc))
|
||||
* fix changelog link in readme ([185932d](https://github.com/expo/expo-github-action/commit/185932d43cd424c08c2d530a3cedad352d66e78e))
|
||||
* update example to use `eas-version` ([#222](https://github.com/expo/expo-github-action/issues/222)) ([7bc946c](https://github.com/expo/expo-github-action/commit/7bc946c5f6b768b1a1858c1722b3aac4e0064c23))
|
||||
|
||||
## [8.0.0](https://github.com/expo/expo-github-action/compare/7.2.1...8.0.0) (2023-02-20)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ branding:
|
||||
icon: terminal
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: build/setup/index.js
|
||||
inputs:
|
||||
expo-version:
|
||||
|
||||
+644
-629
File diff suppressed because it is too large.
Load diff
+824
-760
File diff suppressed because it is too large.
Load diff
+793
-761
File diff suppressed because it is too large.
Load diff
+1395
-1318
File diff suppressed because it is too large.
Load diff
+588
-574
File diff suppressed because it is too large.
Load diff
+605
-582
File diff suppressed because it is too large.
Load diff
+693
-692
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -6,7 +6,7 @@ branding:
|
||||
icon: message-circle
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: ../build/command/index.js
|
||||
inputs:
|
||||
github-token:
|
||||
|
||||
@@ -6,7 +6,7 @@ branding:
|
||||
icon: smartphone
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: ../build/fingerprint/index.js
|
||||
post: ../build/fingerprint-post/index.js
|
||||
post-if: success()
|
||||
|
||||
+6
-4
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "expo-github-action",
|
||||
"version": "8.0.0",
|
||||
"version": "8.1.0",
|
||||
"description": "Expo CLI in your GitHub Actions workflow",
|
||||
"main": "build/index.js",
|
||||
"repository": {
|
||||
@@ -31,13 +31,13 @@
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@expo/config": "^7.0.3",
|
||||
"@expo/config": "^8.1.2",
|
||||
"@expo/fingerprint": "^0.1.0",
|
||||
"@expo/spawn-async": "^1.7.2",
|
||||
"@semantic-release/changelog": "^6.0.2",
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@tsconfig/node16": "^1.0.3",
|
||||
"@tsconfig/node20": "^20.1.2",
|
||||
"@types/jest": "^29.2.5",
|
||||
"@types/node": "^16.18.11",
|
||||
"@types/uuid": "^9.0.3",
|
||||
@@ -53,7 +53,9 @@
|
||||
"ts-jest": "^29.0.3",
|
||||
"typescript": "^5.3.2"
|
||||
},
|
||||
"trustedDependencies": ["sqlite3"],
|
||||
"trustedDependencies": [
|
||||
"sqlite3"
|
||||
],
|
||||
"eslintConfig": {
|
||||
"extends": "universe/node",
|
||||
"ignorePatterns": [
|
||||
|
||||
@@ -6,7 +6,7 @@ branding:
|
||||
icon: smartphone
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: ../build/preview-build/index.js
|
||||
inputs:
|
||||
command:
|
||||
|
||||
@@ -6,7 +6,7 @@ branding:
|
||||
icon: message-circle
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: ../build/preview-comment/index.js
|
||||
inputs:
|
||||
project:
|
||||
|
||||
+21
-18
@@ -46,6 +46,7 @@ Here is a summary of all the input options you can use.
|
||||
| --------------------- | --------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| **command** | - | EAS CLI command to run when creating updates |
|
||||
| **working-directory** | - | The relative directory of your Expo app |
|
||||
| **app-scheme** | - | The (custom) app scheme to use when creating the preview QR code |
|
||||
| **comment** | `true` | If the action should summarize the EAS Update information as comment on a pull request |
|
||||
| **comment-id** | _[see code][code-defaults]_ | unique id template to prevent duplicate comments ([read more](#preventing-duplicate-comments)) |
|
||||
| **github-token** | `github.token` | GitHub token to use when commenting on PR ([read more](#github-tokens)) |
|
||||
@@ -84,30 +85,32 @@ Some of the EAS Update variables can be shared for all platforms if the [runtime
|
||||
These variables contain Android-specific update information.
|
||||
When skipping the Android update, these variables are empty strings.
|
||||
|
||||
| output name | description |
|
||||
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **androidId** | Android-specific update id |
|
||||
| **androidGroupId** | Update group ID that contains one or more platform-specific updates |
|
||||
| **androidBranchName** | Branch name that was used when creating this update ([read more](https://docs.expo.dev/eas-update/getting-started/#publish-an-update)) |
|
||||
| **androidMessage** | Custom message to describe the Android-specific update |
|
||||
| **androidRuntimeVersion** | Runtime version used for the Android-specific update ([read more](https://docs.expo.dev/eas-update/runtime-versions/)) |
|
||||
| **androidQR** | Absolute URL to the QR code to load this Android-specific update |
|
||||
| **androidLink** | Absolute URL to the Android-specific update on [expo.dev](https://expo.dev) |
|
||||
| output name | description |
|
||||
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **androidId** | Android-specific update id |
|
||||
| **androidGroupId** | Update group ID that contains one or more platform-specific updates |
|
||||
| **androidBranchName** | Branch name that was used when creating this update ([read more](https://docs.expo.dev/eas-update/getting-started/#publish-an-update)) |
|
||||
| **andriodManifestPermalink** | Absolute URL to the Android-specific update manifest |
|
||||
| **androidMessage** | Custom message to describe the Android-specific update |
|
||||
| **androidRuntimeVersion** | Runtime version used for the Android-specific update ([read more](https://docs.expo.dev/eas-update/runtime-versions/)) |
|
||||
| **androidQR** | Absolute URL to the QR code to load this Android-specific update |
|
||||
| **androidLink** | Absolute URL to the Android-specific update on [expo.dev](https://expo.dev) |
|
||||
|
||||
#### iOS-specific update information
|
||||
|
||||
These variables contain iOS-specific update information.
|
||||
When skipping the iOS update, these variables are empty strings.
|
||||
|
||||
| output name | description |
|
||||
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **iosId** | iOS-specific update id |
|
||||
| **iosGroupId** | Update group ID that contains one or more platform-specific updates |
|
||||
| **iosBranchName** | Branch name that was used when creating this update ([read more](https://docs.expo.dev/eas-update/getting-started/#publish-an-update)) |
|
||||
| **iosMessage** | Custom message to describe the iOS-specific update |
|
||||
| **iosRuntimeVersion** | Runtime version used for the iOS-specific update ([read more](https://docs.expo.dev/eas-update/runtime-versions/)) |
|
||||
| **iosQR** | Absolute URL to the QR code to load this iOS-specific update |
|
||||
| **iosLink** | Absolute URL to the iOS-specific update on [expo.dev](https://expo.dev) |
|
||||
| output name | description |
|
||||
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **iosId** | iOS-specific update id |
|
||||
| **iosGroupId** | Update group ID that contains one or more platform-specific updates |
|
||||
| **iosBranchName** | Branch name that was used when creating this update ([read more](https://docs.expo.dev/eas-update/getting-started/#publish-an-update)) |
|
||||
| **iosManifestPermalink** | Absolute URL to the ios-specific update manifest |
|
||||
| **iosMessage** | Custom message to describe the iOS-specific update |
|
||||
| **iosRuntimeVersion** | Runtime version used for the iOS-specific update ([read more](https://docs.expo.dev/eas-update/runtime-versions/)) |
|
||||
| **iosQR** | Absolute URL to the QR code to load this iOS-specific update |
|
||||
| **iosLink** | Absolute URL to the iOS-specific update on [expo.dev](https://expo.dev) |
|
||||
|
||||
## Example workflows
|
||||
|
||||
|
||||
+4
-1
@@ -6,12 +6,15 @@ branding:
|
||||
icon: smartphone
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node16
|
||||
using: node20
|
||||
main: ../build/preview/index.js
|
||||
inputs:
|
||||
command:
|
||||
description: EAS CLI command to run when creating updates
|
||||
required: true
|
||||
app-scheme:
|
||||
description: The (custom) app scheme to use when creating the preview QR code
|
||||
required: false
|
||||
comment:
|
||||
description: If the action should summarize the EAS Update information as comment on a pull request
|
||||
required: false
|
||||
|
||||
+29
-6
@@ -16,6 +16,7 @@ export function previewInput() {
|
||||
commentId: getInput('comment-id') || MESSAGE_ID,
|
||||
workingDirectory: getInput('working-directory'),
|
||||
githubToken: getInput('github-token'),
|
||||
appScheme: getInput('app-scheme'),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ export async function previewAction(input = previewInput()) {
|
||||
return setFailed(`Missing 'extra.eas.projectId' in app.json or app.config.js.`);
|
||||
}
|
||||
|
||||
const variables = getVariables(config, updates);
|
||||
const variables = getVariables(config, updates, input);
|
||||
const messageId = template(input.commentId, variables);
|
||||
const messageBody = createSummary(updates, variables);
|
||||
|
||||
@@ -95,22 +96,24 @@ function sanitizeCommand(input: string): string {
|
||||
/**
|
||||
* Generate useful variables for the message body, and as step outputs.
|
||||
*/
|
||||
export function getVariables(config: ExpoConfig, updates: EasUpdate[]) {
|
||||
export function getVariables(config: ExpoConfig, updates: EasUpdate[], input: ReturnType<typeof previewInput>) {
|
||||
const projectId: string = config.extra?.eas?.projectId;
|
||||
const android = updates.find(update => update.platform === 'android');
|
||||
const ios = updates.find(update => update.platform === 'ios');
|
||||
|
||||
const appScheme = input.appScheme || getSchemeFromConfig(config) || '';
|
||||
|
||||
return {
|
||||
// EAS / Expo specific
|
||||
projectId,
|
||||
projectName: config.name,
|
||||
projectSlug: config.slug,
|
||||
projectScheme: config.scheme || '',
|
||||
projectScheme: appScheme,
|
||||
// Shared update properties
|
||||
// Note, only use these properties when the update groups are identical
|
||||
groupId: updates[0].group,
|
||||
runtimeVersion: updates[0].runtimeVersion,
|
||||
qr: getUpdateGroupQr({ projectId, updateGroupId: updates[0].group, appScheme: config.scheme }),
|
||||
qr: getUpdateGroupQr({ projectId, updateGroupId: updates[0].group, appScheme }),
|
||||
link: getUpdateGroupWebsite({ projectId, updateGroupId: updates[0].group }),
|
||||
// These are safe to access regardless of the update groups
|
||||
branchName: updates[0].branch,
|
||||
@@ -121,21 +124,41 @@ export function getVariables(config: ExpoConfig, updates: EasUpdate[]) {
|
||||
androidId: android?.id || '',
|
||||
androidGroupId: android?.group || '',
|
||||
androidBranchName: android?.branch || '',
|
||||
androidManifestPermalink: android?.manifestPermalink || '',
|
||||
androidMessage: android?.message || '',
|
||||
androidRuntimeVersion: android?.runtimeVersion || '',
|
||||
androidQR: android ? getUpdateGroupQr({ projectId, updateGroupId: android.group, appScheme: config.scheme }) : '',
|
||||
androidQR: android ? getUpdateGroupQr({ projectId, updateGroupId: android.group, appScheme }) : '',
|
||||
androidLink: android ? getUpdateGroupWebsite({ projectId, updateGroupId: android.group }) : '',
|
||||
// iOS update
|
||||
iosId: ios?.id || '',
|
||||
iosGroupId: ios?.group || '',
|
||||
iosBranchName: ios?.branch || '',
|
||||
iosManifestPermalink: ios?.manifestPermalink || '',
|
||||
iosMessage: ios?.message || '',
|
||||
iosRuntimeVersion: ios?.runtimeVersion || '',
|
||||
iosQR: ios ? getUpdateGroupQr({ projectId, updateGroupId: ios.group, appScheme: config.scheme }) : '',
|
||||
iosQR: ios ? getUpdateGroupQr({ projectId, updateGroupId: ios.group, appScheme }) : '',
|
||||
iosLink: ios ? getUpdateGroupWebsite({ projectId, updateGroupId: ios.group }) : '',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the app scheme from project config, using the following criteria:
|
||||
* - If the scheme is a string, return that.
|
||||
* - If the scheme is an array, return the longest scheme.
|
||||
*/
|
||||
export function getSchemeFromConfig(config: ExpoConfig) {
|
||||
if (typeof config.scheme === 'string') {
|
||||
return config.scheme;
|
||||
}
|
||||
|
||||
if (Array.isArray(config.scheme) && config.scheme.length > 0) {
|
||||
const longestToShortest = config.scheme.sort((a, b) => b.length - a.length);
|
||||
return longestToShortest[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the message body for a single update.
|
||||
* Note, this is not configurable, but you can use the variables used to construct your own.
|
||||
|
||||
+2
-4
@@ -4,8 +4,6 @@ import type { Platform } from '@expo/config';
|
||||
import semver from 'semver';
|
||||
import { URL } from 'url';
|
||||
|
||||
import { errorMessage } from './utils';
|
||||
|
||||
export interface EasUpdate {
|
||||
/** The unique ID of the platform specific update */
|
||||
id: string;
|
||||
@@ -60,8 +58,8 @@ export async function createUpdate(cwd: string, command: string): Promise<EasUpd
|
||||
({ stdout } = await getExecOutput((await which('eas', true)) + ` ${command}`, undefined, {
|
||||
cwd,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not create a new EAS Update, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not create a new EAS Update`, { cause: error });
|
||||
}
|
||||
|
||||
return JSON.parse(stdout);
|
||||
|
||||
+14
-16
@@ -4,8 +4,6 @@ import { which } from '@actions/io';
|
||||
import { ok as assert } from 'assert';
|
||||
import { URL } from 'url';
|
||||
|
||||
import { errorMessage } from './utils';
|
||||
|
||||
export type CliName = 'expo' | 'eas';
|
||||
|
||||
export type Command = {
|
||||
@@ -97,8 +95,8 @@ export async function projectOwner(cli: CliName = 'expo'): Promise<string> {
|
||||
|
||||
try {
|
||||
({ stdout } = await getExecOutput(await which(cli), ['whoami'], { silent: true }));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not fetch the project owner, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not fetch the project owner`, { cause: error });
|
||||
}
|
||||
|
||||
if (!stdout) {
|
||||
@@ -118,8 +116,8 @@ export async function runCommand(cmd: Command) {
|
||||
({ stderr, stdout } = await getExecOutput(await which(cmd.cli), cmd.args.concat('--non-interactive'), {
|
||||
silent: false,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not run command ${cmd.args.join(' ')}, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not run command ${cmd.args.join(' ')}`, { cause: error });
|
||||
}
|
||||
|
||||
return [stdout.trim(), stderr.trim()];
|
||||
@@ -133,8 +131,8 @@ export async function easBuild(cmd: Command): Promise<BuildInfo[]> {
|
||||
({ stdout } = await getExecOutput(await which('eas', true), args, {
|
||||
silent: false,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not run command eas build, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not run command eas build`, { cause: error });
|
||||
}
|
||||
|
||||
return JSON.parse(stdout);
|
||||
@@ -165,8 +163,8 @@ export async function createEasBuildFromRawCommandAsync(
|
||||
({ stdout } = await getExecOutput((await which('eas', true)) + ` ${cmd}`, extraArgs, {
|
||||
cwd,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not run command eas build, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not run command eas build`, { cause: error });
|
||||
}
|
||||
|
||||
return JSON.parse(stdout);
|
||||
@@ -178,8 +176,8 @@ export async function createEasBuildFromRawCommandAsync(
|
||||
export async function cancelEasBuildAsync(cwd: string, buildId: string): Promise<void> {
|
||||
try {
|
||||
await getExecOutput(await which('eas', true), ['build:cancel', buildId], { cwd });
|
||||
} catch (e) {
|
||||
info(`Failed to cancel build ${buildId}: ${errorMessage(e)}`);
|
||||
} catch (error: unknown) {
|
||||
info(`Failed to cancel build ${buildId}: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,8 +191,8 @@ export async function queryEasBuildInfoAsync(cwd: string, buildId: string): Prom
|
||||
silent: true,
|
||||
});
|
||||
return JSON.parse(stdout);
|
||||
} catch (e) {
|
||||
info(`Failed to query eas build ${buildId}: ${errorMessage(e)}`);
|
||||
} catch (error: unknown) {
|
||||
info(`Failed to query eas build ${buildId}: ${String(error)}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -210,8 +208,8 @@ export async function projectInfo(dir: string): Promise<ProjectInfo> {
|
||||
cwd: dir,
|
||||
silent: true,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not fetch the project info from ${dir}, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not fetch the project info from ${dir}`, { cause: error });
|
||||
}
|
||||
|
||||
const { name, slug, owner } = JSON.parse(stdout);
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
import { exec, getExecOutput } from '@actions/exec';
|
||||
import { mkdirP } from '@actions/io';
|
||||
|
||||
import { errorMessage } from './utils';
|
||||
import { cacheTool, tempPath } from './worker';
|
||||
|
||||
/**
|
||||
@@ -14,8 +13,8 @@ export async function resolvePackage(name: string, range: string): Promise<strin
|
||||
|
||||
try {
|
||||
({ stdout } = await getExecOutput('npm', ['info', `${name}@${range}`, 'version', '--json'], { silent: true }));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not resolve ${name}@${range}, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not resolve ${name}@${range}`, { cause: error });
|
||||
}
|
||||
|
||||
// thanks npm, for returning a "" json string value for invalid versions
|
||||
|
||||
+2
-4
@@ -1,8 +1,6 @@
|
||||
import { getExecOutput } from '@actions/exec';
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
|
||||
import { errorMessage } from './utils';
|
||||
|
||||
/**
|
||||
* Load the Expo app project config in the given directory.
|
||||
* This runs `expo config` command instead of using `@expo/config` directly,
|
||||
@@ -16,8 +14,8 @@ export async function loadProjectConfig(cwd: string): Promise<ExpoConfig> {
|
||||
cwd,
|
||||
silent: true,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw new Error(`Could not fetch the project info from ${cwd}, reason:\n${errorMessage(error)}`);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not fetch the project info from ${cwd}`, { cause: error });
|
||||
}
|
||||
|
||||
return JSON.parse(stdout);
|
||||
|
||||
@@ -9,15 +9,3 @@ export function template(template: string, replacements: Record<string, string>)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function errorMessage(error: Error | unknown): string {
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
|
||||
return 'Unknown error';
|
||||
}
|
||||
+1
-3
@@ -4,8 +4,6 @@ import { ok as assert } from 'assert';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import { errorMessage } from './utils';
|
||||
|
||||
export { find as findTool, cacheDir as cacheTool } from '@actions/tool-cache';
|
||||
|
||||
/**
|
||||
@@ -56,7 +54,7 @@ export async function patchWatchers(): Promise<void> {
|
||||
} catch (error) {
|
||||
warning(`Looks like we can't patch watchers/inotify limits, you might encouter the 'ENOSPC' error.`);
|
||||
warning('For more info: https://github.com/expo/expo-github-action/issues/20, encountered error:');
|
||||
warning(errorMessage(error));
|
||||
warning(String(error));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
|
||||
import { createSummary, getVariables } from '../../src/actions/preview';
|
||||
import { createSummary, getSchemeFromConfig, getVariables, previewInput } from '../../src/actions/preview';
|
||||
import { EasUpdate } from '../../src/eas';
|
||||
|
||||
const fakeInput = {} as unknown as ReturnType<typeof previewInput>;
|
||||
|
||||
const fakeExpoConfig = {
|
||||
slug: 'fake-project',
|
||||
extra: {
|
||||
@@ -37,10 +39,25 @@ const fakeUpdatesSingle: EasUpdate[] = [
|
||||
|
||||
const fakeUpdatesMultiple = fakeUpdatesSingle.map(update => ({ ...update, group: `fake-group-${update.id}` }));
|
||||
|
||||
describe(getSchemeFromConfig, () => {
|
||||
it('returns `null` when not defined', () => {
|
||||
expect(getSchemeFromConfig({} as ExpoConfig)).toBeNull();
|
||||
});
|
||||
|
||||
it('returns scheme when defined as string', () => {
|
||||
expect(getSchemeFromConfig({ scheme: 'ega' } as ExpoConfig)).toBe('ega');
|
||||
});
|
||||
|
||||
it('returns longest scheme when defined as array', () => {
|
||||
expect(getSchemeFromConfig({ scheme: ['ega', 'expogithubaction'] } as ExpoConfig)).toBe('expogithubaction');
|
||||
});
|
||||
});
|
||||
|
||||
describe(createSummary, () => {
|
||||
describe('single update group', () => {
|
||||
it('returns expected message for both platforms', () => {
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(fakeExpoConfig, fakeUpdatesSingle))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(fakeExpoConfig, fakeUpdatesSingle, fakeInput)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
@@ -55,8 +72,26 @@ describe(createSummary, () => {
|
||||
});
|
||||
|
||||
it('returns expected message for both platforms with custom app scheme', () => {
|
||||
const customSchemeConfig = { ...fakeExpoConfig, scheme: 'expogithubaction' };
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(customSchemeConfig, fakeUpdatesSingle)))
|
||||
const customSchemeConfig = { ...fakeExpoConfig, scheme: ['ega', 'expogithubaction'] };
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(customSchemeConfig, fakeUpdatesSingle, fakeInput)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platforms → **android**, **ios**
|
||||
- Scheme → **expogithubaction**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=expogithubaction&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=expogithubaction&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns expected message for both platforms with overwriten app scheme', () => {
|
||||
const customInput = { ...fakeInput, appScheme: 'expogithubaction' };
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(fakeExpoConfig, fakeUpdatesSingle, customInput)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
@@ -74,7 +109,7 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for android only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'android');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
@@ -90,7 +125,7 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for ios only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'ios');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
@@ -107,7 +142,7 @@ describe(createSummary, () => {
|
||||
|
||||
describe('mutliple update groups', () => {
|
||||
it('returns expected message for both platforms', () => {
|
||||
expect(createSummary(fakeUpdatesMultiple, getVariables(fakeExpoConfig, fakeUpdatesMultiple)))
|
||||
expect(createSummary(fakeUpdatesMultiple, getVariables(fakeExpoConfig, fakeUpdatesMultiple, fakeInput)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
@@ -124,7 +159,7 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for android only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'android');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
@@ -140,7 +175,7 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for ios only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'ios');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
{
|
||||
"extends": "@tsconfig/node16",
|
||||
"extends": "@tsconfig/node20",
|
||||
"compilerOptions": {
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
"rootDir": "./src",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"exclude": [
|
||||
"build",
|
||||
|
||||
Reference in new issue
Block a user