Skip to content

Commit d4620e1

Browse files
authored
Add alt source for PocketIC. (#12)
* Add alt source for PocketIC. * Change macOS bin dir. * Update README.
1 parent 276f896 commit d4620e1

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
dfx-version: ${{ matrix.version }}
1414
install-moc: true
1515
vessel-version: 0.7.0
16-
pocketic-version: 3.0.1
16+
pocket-ic-version: release-2024-04-24_23-01-base
1717
- run: |
1818
dfx --version
1919
moc --version

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Setup The Internet Computer SDK
22

3-
This action sets up a `dfx` environment, also includes `moc` and `vessel`.
3+
This action sets up a `dfx` environment, also includes `moc`, `vessel` and `pocket-ic`.
44

5-
**!** Only supports Ubuntu/MacOS virtual environments.
5+
**!** Only supports Ubuntu/macOS virtual environments.
66

77
## Usage
88

99
```yml
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: aviate-labs/setup-dfx@v0.3.0
13+
- uses: aviate-labs/setup-dfx@v0.3.2
1414
with:
1515
vessel-version: 0.7.0
1616
- run: for i in src/*.mo ; do $(vessel bin)/moc $(vessel sources) --check $i ; done
@@ -22,7 +22,7 @@ steps:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v4
25-
- uses: aviate-labs/setup-dfx@v0.3.0
25+
- uses: aviate-labs/setup-dfx@v0.3.2
2626
with:
2727
dfx-version: 0.18.0
2828
env:

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ inputs:
77
dfx-disable-encryption:
88
description: 'Whether to use the .pem encryption.'
99
default: "false"
10-
pocketic-version:
10+
pocket-ic-version:
1111
description: 'The pocket ic version to download. If empty pocket ic will not be installed.'
1212
install-moc:
1313
description: 'Whether to install moc through dfx.'

dist/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function run() {
5656
let pocketicBuild = 'linux';
5757
// Alter params if running on macOS.
5858
if (os_1.default.platform() === 'darwin') {
59-
bin = '/usr/local/share';
59+
bin = '/Users/runner/bin';
6060
vesselBuild = 'macos';
6161
pocketicBuild = 'darwin';
6262
}
@@ -128,9 +128,15 @@ function run() {
128128
infoExec(`${vesselPath} --version`);
129129
}
130130
// Install PocketIC.
131-
const pocketicVersion = core.getInput('pocketic-version');
131+
const pocketicVersion = core.getInput('pocket-ic-version');
132132
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`);
133+
try {
134+
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`);
135+
}
136+
catch (error) {
137+
core.debug(`Failed to download pocket-ic, trying to download from the main ic repo...`);
138+
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`);
139+
}
134140
child_process_1.default.execSync(`gunzip ${bin}/pocket-ic.gz`);
135141
child_process_1.default.execSync(`chmod +x ${bin}/pocket-ic`);
136142
const pocketicPath = yield io.which('pocket-ic');

src/main.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function run() {
1212

1313
// Alter params if running on macOS.
1414
if (os.platform() === 'darwin') {
15-
bin = '/usr/local/share';
15+
bin = '/Users/runner/bin';
1616
vesselBuild = 'macos';
1717
pocketicBuild = 'darwin';
1818
}
@@ -100,11 +100,18 @@ export async function run() {
100100
}
101101

102102
// Install PocketIC.
103-
const pocketicVersion = core.getInput('pocketic-version');
103+
const pocketicVersion = core.getInput('pocket-ic-version');
104104
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-
);
105+
try {
106+
cp.execSync(
107+
`wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/pocketic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`
108+
);
109+
} catch (error) {
110+
core.debug(`Failed to download pocket-ic, trying to download from the main ic repo...`);
111+
cp.execSync(
112+
`wget -O ${bin}/pocket-ic.gz https://github.com/dfinity/ic/releases/download/${pocketicVersion}/pocket-ic-x86_64-${pocketicBuild}.gz`
113+
);
114+
}
108115
cp.execSync(`gunzip ${bin}/pocket-ic.gz`);
109116
cp.execSync(`chmod +x ${bin}/pocket-ic`);
110117

0 commit comments

Comments
 (0)