From 49733f0784f994c2f6fcf7d7267bd4250ff53356 Mon Sep 17 00:00:00 2001 From: Quint Daenen Date: Sun, 28 Apr 2024 12:13:03 +0200 Subject: [PATCH] Add alt source for PocketIC. --- .github/workflows/main.yml | 2 +- action.yml | 2 +- dist/index.js | 10 ++++++++-- src/main.ts | 15 +++++++++++---- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cecd98f..7c37357 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: dfx-version: ${{ matrix.version }} install-moc: true vessel-version: 0.7.0 - pocketic-version: 3.0.1 + pocket-ic-version: release-2024-04-24_23-01-base - run: | dfx --version moc --version diff --git a/action.yml b/action.yml index 6789135..bd19819 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ inputs: dfx-disable-encryption: description: 'Whether to use the .pem encryption.' default: "false" - pocketic-version: + pocket-ic-version: description: 'The pocket ic version to download. If empty pocket ic will not be installed.' install-moc: description: 'Whether to install moc through dfx.' diff --git a/dist/index.js b/dist/index.js index 37cd272..5297215 100644 --- a/dist/index.js +++ b/dist/index.js @@ -128,9 +128,15 @@ function run() { infoExec(`${vesselPath} --version`); } // Install PocketIC. - const pocketicVersion = core.getInput('pocketic-version'); + const pocketicVersion = core.getInput('pocket-ic-version'); if (pocketicVersion) { - child_process_1.default.execSync(`wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`); + try { + child_process_1.default.execSync(`wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`); + } + catch (error) { + core.debug(`Failed to download pocket-ic, trying to download from the main ic repo...`); + child_process_1.default.execSync(`wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/ic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`); + } child_process_1.default.execSync(`gunzip ${bin}/pocket-ic.gz`); child_process_1.default.execSync(`chmod +x ${bin}/pocket-ic`); const pocketicPath = yield io.which('pocket-ic'); diff --git a/src/main.ts b/src/main.ts index 7580845..b00838d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -100,11 +100,18 @@ export async function run() { } // Install PocketIC. - const pocketicVersion = core.getInput('pocketic-version'); + const pocketicVersion = core.getInput('pocket-ic-version'); if (pocketicVersion) { - cp.execSync( - `wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz` - ); + try { + cp.execSync( + `wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz` + ); + } catch (error) { + core.debug(`Failed to download pocket-ic, trying to download from the main ic repo...`); + cp.execSync( + `wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/ic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz` + ); + } cp.execSync(`gunzip ${bin}/pocket-ic.gz`); cp.execSync(`chmod +x ${bin}/pocket-ic`);