Skip to content

Commit

Permalink
Add pocket-ic bin.
Browse files Browse the repository at this point in the history
  • Loading branch information
q-uint committed Apr 24, 2024
1 parent 0762cc7 commit 557891a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
dfx-version: ${{ matrix.version }}
install-moc: true
vessel-version: 0.7.0
pocketic-version: 3.0.1
- run: |
dfx --version
moc --version
vessel --version
pocket-ic --version
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ inputs:
dfx-disable-encryption:
description: 'Whether to use the .pem encryption.'
default: "false"
pocketic-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.'
default: "false"
Expand Down
11 changes: 11 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ function run() {
// Configured to run on linux by default.
let bin = '/home/runner/bin';
let vesselBuild = 'linux64';
let pocketicBuild = 'linux';
// Alter params if running on macOS.
if (os_1.default.platform() === 'darwin') {
bin = '/usr/local/share';
vesselBuild = 'macos';
pocketicBuild = 'darwin';
}
// Die if not running on linux or macOS.
if (!['linux', 'darwin'].includes(os_1.default.platform())) {
Expand Down Expand Up @@ -125,6 +127,15 @@ function run() {
const vesselPath = yield io.which('vessel');
infoExec(`${vesselPath} --version`);
}
// Install PocketIC.
const pocketicVersion = core.getInput('pocketic-version');
if (pocketicVersion) {
child_process_1.default.execSync(`wget -O ${bin}/pocketic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`);
child_process_1.default.execSync(`gunzip ${bin}/pocket-ic.gz && mv ${bin}/pocket-ic/pocket-ic-x86_64-${pocketicBuild} ${bin}/pocket-ic`);
child_process_1.default.execSync(`chmod +x ${bin}/pocket-ic`);
const pocketicPath = yield io.which('pocket-ic');
infoExec(`${pocketicPath} --version`);
}
});
}
exports.run = run;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"keywords": [
"dfx",
"vessel",
"pocket-ic",
"moc",
"motoko",
"dfinity",
Expand Down
15 changes: 15 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export async function run() {
// Configured to run on linux by default.
let bin = '/home/runner/bin';
let vesselBuild = 'linux64';
let pocketicBuild = 'linux';

// Alter params if running on macOS.
if (os.platform() === 'darwin') {
bin = '/usr/local/share';
vesselBuild = 'macos';
pocketicBuild = 'darwin';
}

// Die if not running on linux or macOS.
Expand Down Expand Up @@ -96,6 +98,19 @@ export async function run() {
const vesselPath = await io.which('vessel');
infoExec(`${vesselPath} --version`);
}

// Install PocketIC.
const pocketicVersion = core.getInput('pocketic-version');
if (pocketicVersion) {
cp.execSync(
`wget -O ${bin}/pocketic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`
);
cp.execSync(`gunzip ${bin}/pocket-ic.gz && mv ${bin}/pocket-ic/pocket-ic-x86_64-${pocketicBuild} ${bin}/pocket-ic`);
cp.execSync(`chmod +x ${bin}/pocket-ic`);

const pocketicPath = await io.which('pocket-ic');
infoExec(`${pocketicPath} --version`);
}
}

function infoExec(command: string): string {
Expand Down

0 comments on commit 557891a

Please sign in to comment.