Skip to content

Commit

Permalink
Add alt source for PocketIC. (#12)
Browse files Browse the repository at this point in the history
* Add alt source for PocketIC.

* Change macOS bin dir.

* Update README.
  • Loading branch information
q-uint authored Apr 28, 2024
1 parent 276f896 commit d4620e1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Setup The Internet Computer SDK

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

**!** Only supports Ubuntu/MacOS virtual environments.
**!** Only supports Ubuntu/macOS virtual environments.

## Usage

```yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aviate-labs/[email protected].0
- uses: aviate-labs/[email protected].2
with:
vessel-version: 0.7.0
- run: for i in src/*.mo ; do $(vessel bin)/moc $(vessel sources) --check $i ; done
Expand All @@ -22,7 +22,7 @@ steps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aviate-labs/[email protected].0
- uses: aviate-labs/[email protected].2
with:
dfx-version: 0.18.0
env:
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
12 changes: 9 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function run() {
let pocketicBuild = 'linux';
// Alter params if running on macOS.
if (os_1.default.platform() === 'darwin') {
bin = '/usr/local/share';
bin = '/Users/runner/bin';
vesselBuild = 'macos';
pocketicBuild = 'darwin';
}
Expand Down Expand Up @@ -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');
Expand Down
17 changes: 12 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function run() {

// Alter params if running on macOS.
if (os.platform() === 'darwin') {
bin = '/usr/local/share';
bin = '/Users/runner/bin';
vesselBuild = 'macos';
pocketicBuild = 'darwin';
}
Expand Down Expand Up @@ -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`);

Expand Down

0 comments on commit d4620e1

Please sign in to comment.