Fix a bug where our new timeout caused the action to stay "alive" (#173)
This commit is contained in:
109
__tests__/main.test.ts
Normal file
109
__tests__/main.test.ts
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import {RunOptions, RunTarget} from 'github-action-ts-run-api';
|
||||||
|
|
||||||
|
const target = RunTarget.mainJs('action.yml');
|
||||||
|
|
||||||
|
async function expectRunInitiatesUpload(options: RunOptions) {
|
||||||
|
const result = await target.run(options)
|
||||||
|
expect(result.commands.errors.length).toBe(1)
|
||||||
|
expect(result.commands.errors).toContainEqual("The incoming JSON object does not contain a client_email field")
|
||||||
|
}
|
||||||
|
|
||||||
|
test("correct bare minimum inputs", async () => {
|
||||||
|
const minimumOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
track: "production",
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(minimumOptions)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("correct inputs for complete rollout", async () => {
|
||||||
|
// Run with the bare minimum
|
||||||
|
const minimumOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
track: "production",
|
||||||
|
status: "completed",
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(minimumOptions)
|
||||||
|
|
||||||
|
// Test with optional extras
|
||||||
|
const extraOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
releaseName: "Release name",
|
||||||
|
track: "production",
|
||||||
|
inAppUpdatePriority: "3",
|
||||||
|
status: "completed",
|
||||||
|
whatsNewDir: "./__tests__/whatsnew",
|
||||||
|
changesNotSentForReview: "true",
|
||||||
|
existingEditId: "123"
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(extraOptions)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("correct inputs for inProgress rollout", async () => {
|
||||||
|
// Run with the bare minimum
|
||||||
|
const minimumOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
track: "production",
|
||||||
|
userFraction: "0.99",
|
||||||
|
status: "inProgress",
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(minimumOptions)
|
||||||
|
|
||||||
|
// Test with optional extras
|
||||||
|
const extraOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
releaseName: "Release name",
|
||||||
|
track: "production",
|
||||||
|
inAppUpdatePriority: "3",
|
||||||
|
userFraction: "0.5",
|
||||||
|
status: "inProgress",
|
||||||
|
whatsNewDir: "./__tests__/whatsnew",
|
||||||
|
changesNotSentForReview: "true",
|
||||||
|
existingEditId: "123"
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(extraOptions)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("correct inputs for draft rollout", async () => {
|
||||||
|
// Run with the bare minimum
|
||||||
|
const minimumOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
track: "production",
|
||||||
|
status: "draft",
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(minimumOptions)
|
||||||
|
|
||||||
|
// Test with optional extras
|
||||||
|
const extraOptions = RunOptions.create()
|
||||||
|
.setInputs({
|
||||||
|
serviceAccountJsonPlainText: "{}",
|
||||||
|
packageName: "com.package.name",
|
||||||
|
releaseFiles: "./__tests__/releasefiles/*.aab",
|
||||||
|
releaseName: "Release name",
|
||||||
|
track: "production",
|
||||||
|
inAppUpdatePriority: "3",
|
||||||
|
status: "draft",
|
||||||
|
whatsNewDir: "./__tests__/whatsnew",
|
||||||
|
changesNotSentForReview: "true",
|
||||||
|
existingEditId: "123"
|
||||||
|
})
|
||||||
|
await expectRunInitiatesUpload(extraOptions)
|
||||||
|
})
|
||||||
File diff suppressed because one or more lines are too long
19
package-lock.json
generated
19
package-lock.json
generated
@@ -12,7 +12,8 @@
|
|||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@googleapis/androidpublisher": "^4.1.0",
|
"@googleapis/androidpublisher": "^4.1.0",
|
||||||
"fast-glob": "^3.2.12",
|
"fast-glob": "^3.2.12",
|
||||||
"jszip": "^3.10.1"
|
"jszip": "^3.10.1",
|
||||||
|
"p-timeout": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.2.0",
|
"@types/jest": "^29.2.0",
|
||||||
@@ -4378,6 +4379,17 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/p-timeout": {
|
||||||
|
"version": "6.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-6.1.0.tgz",
|
||||||
|
"integrity": "sha512-s0y6Le9QYGELLzNpFIt6h8B2DHTVUDLStvxtvRMSKNKeuNVVWby2dZ+pIJpW4/pWr5a3s8W85wBNtc0ZA+lzCg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.16"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/p-try": {
|
"node_modules/p-try": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
||||||
@@ -8856,6 +8868,11 @@
|
|||||||
"p-limit": "^3.0.2"
|
"p-limit": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"p-timeout": {
|
||||||
|
"version": "6.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-6.1.0.tgz",
|
||||||
|
"integrity": "sha512-s0y6Le9QYGELLzNpFIt6h8B2DHTVUDLStvxtvRMSKNKeuNVVWby2dZ+pIJpW4/pWr5a3s8W85wBNtc0ZA+lzCg=="
|
||||||
|
},
|
||||||
"p-try": {
|
"p-try": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "upload-google-play",
|
"name": "upload-google-play",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Upload an Android release (.apk or .aab) to Google Play Console",
|
"description": "Upload an Android release (.apk or .aab) to Google Play Console",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
@@ -23,7 +23,8 @@
|
|||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@googleapis/androidpublisher": "^4.1.0",
|
"@googleapis/androidpublisher": "^4.1.0",
|
||||||
"fast-glob": "^3.2.12",
|
"fast-glob": "^3.2.12",
|
||||||
"jszip": "^3.10.1"
|
"jszip": "^3.10.1",
|
||||||
|
"p-timeout": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.2.0",
|
"@types/jest": "^29.2.0",
|
||||||
|
|||||||
24
src/main.ts
24
src/main.ts
@@ -1,8 +1,9 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core'
|
||||||
import * as fs from "fs";
|
import * as fs from "fs"
|
||||||
import { runUpload } from "./edits";
|
import { runUpload } from "./edits"
|
||||||
import { validateInAppUpdatePriority, validateReleaseFiles, validateStatus, validateUserFraction } from "./input-validation"
|
import { validateInAppUpdatePriority, validateReleaseFiles, validateStatus, validateUserFraction } from "./input-validation"
|
||||||
import { unlink, writeFile } from 'fs/promises';
|
import { unlink, writeFile } from 'fs/promises'
|
||||||
|
import pTimeout from 'p-timeout'
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
@@ -65,8 +66,7 @@ export async function run() {
|
|||||||
core.warning(`Unable to find 'debugSymbols' @ ${debugSymbols}`);
|
core.warning(`Unable to find 'debugSymbols' @ ${debugSymbols}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await withTimeout(
|
await pTimeout(
|
||||||
3.6e+6, // 60 minute timeout
|
|
||||||
runUpload(
|
runUpload(
|
||||||
packageName,
|
packageName,
|
||||||
track,
|
track,
|
||||||
@@ -80,7 +80,10 @@ export async function run() {
|
|||||||
existingEditId,
|
existingEditId,
|
||||||
status,
|
status,
|
||||||
validatedReleaseFiles
|
validatedReleaseFiles
|
||||||
)
|
),
|
||||||
|
{
|
||||||
|
milliseconds: 3.6e+6
|
||||||
|
}
|
||||||
)
|
)
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
@@ -119,11 +122,4 @@ async function validateServiceAccountJson(serviceAccountJsonRaw: string | undefi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function withTimeout<T>(timeoutMillis: number, promise: Promise<T>): Promise<T> {
|
|
||||||
return Promise.race([
|
|
||||||
new Promise<never>((_, reject) => setTimeout(reject, timeoutMillis)),
|
|
||||||
promise
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|||||||
Reference in New Issue
Block a user