Skip to content

Commit 276f896

Browse files
authored
Add PocketIC (#11)
* Add pocket-ic bin. * Fix typo. * Remove mv after unzip.
1 parent 0762cc7 commit 276f896

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
dfx-version: ${{ matrix.version }}
1414
install-moc: true
1515
vessel-version: 0.7.0
16+
pocketic-version: 3.0.1
1617
- run: |
1718
dfx --version
1819
moc --version
1920
vessel --version
21+
pocket-ic --version

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ inputs:
77
dfx-disable-encryption:
88
description: 'Whether to use the .pem encryption.'
99
default: "false"
10+
pocketic-version:
11+
description: 'The pocket ic version to download. If empty pocket ic will not be installed.'
1012
install-moc:
1113
description: 'Whether to install moc through dfx.'
1214
default: "false"

dist/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ function run() {
5353
// Configured to run on linux by default.
5454
let bin = '/home/runner/bin';
5555
let vesselBuild = 'linux64';
56+
let pocketicBuild = 'linux';
5657
// Alter params if running on macOS.
5758
if (os_1.default.platform() === 'darwin') {
5859
bin = '/usr/local/share';
5960
vesselBuild = 'macos';
61+
pocketicBuild = 'darwin';
6062
}
6163
// Die if not running on linux or macOS.
6264
if (!['linux', 'darwin'].includes(os_1.default.platform())) {
@@ -125,6 +127,15 @@ function run() {
125127
const vesselPath = yield io.which('vessel');
126128
infoExec(`${vesselPath} --version`);
127129
}
130+
// Install PocketIC.
131+
const pocketicVersion = core.getInput('pocketic-version');
132+
if (pocketicVersion) {
133+
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`);
134+
child_process_1.default.execSync(`gunzip ${bin}/pocket-ic.gz`);
135+
child_process_1.default.execSync(`chmod +x ${bin}/pocket-ic`);
136+
const pocketicPath = yield io.which('pocket-ic');
137+
infoExec(`${pocketicPath} --version`);
138+
}
128139
});
129140
}
130141
exports.run = run;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"keywords": [
1414
"dfx",
1515
"vessel",
16+
"pocket-ic",
1617
"moc",
1718
"motoko",
1819
"dfinity",

src/main.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ export async function run() {
88
// Configured to run on linux by default.
99
let bin = '/home/runner/bin';
1010
let vesselBuild = 'linux64';
11+
let pocketicBuild = 'linux';
1112

1213
// Alter params if running on macOS.
1314
if (os.platform() === 'darwin') {
1415
bin = '/usr/local/share';
1516
vesselBuild = 'macos';
17+
pocketicBuild = 'darwin';
1618
}
1719

1820
// Die if not running on linux or macOS.
@@ -96,6 +98,19 @@ export async function run() {
9698
const vesselPath = await io.which('vessel');
9799
infoExec(`${vesselPath} --version`);
98100
}
101+
102+
// Install PocketIC.
103+
const pocketicVersion = core.getInput('pocketic-version');
104+
if (pocketicVersion) {
105+
cp.execSync(
106+
`wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`
107+
);
108+
cp.execSync(`gunzip ${bin}/pocket-ic.gz`);
109+
cp.execSync(`chmod +x ${bin}/pocket-ic`);
110+
111+
const pocketicPath = await io.which('pocket-ic');
112+
infoExec(`${pocketicPath} --version`);
113+
}
99114
}
100115

101116
function infoExec(command: string): string {

0 commit comments

Comments
 (0)