From 8499faa7266fff9a1884e59deb4a4215d40f8561 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 | 8 +++++++- src/main.ts | 13 ++++++++++--- 4 files changed, 19 insertions(+), 6 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..1744725 100644 --- a/dist/index.js +++ b/dist/index.js @@ -130,7 +130,13 @@ function run() { // Install PocketIC. const pocketicVersion = core.getInput('pocketic-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..1b267de 100644 --- a/src/main.ts +++ b/src/main.ts @@ -102,9 +102,16 @@ export async function run() { // Install PocketIC. const pocketicVersion = core.getInput('pocketic-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`);