-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a GitHub Action for installing the PocketIC server and a test for this GitHub Action.
- Loading branch information
Showing
3 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
|
||
jobs: | ||
test_pocket_ic_server_action: | ||
runs-on: ${{ matrix.os }} | ||
name: Test the PocketIC server action (action.yml) | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- version: '5.0.0' | ||
expected-version: '5.0.0' | ||
os: ubuntu-latest | ||
- version: '5.0.0' | ||
expected-version: '5.0.0' | ||
os: macos-latest | ||
|
||
- expected-version: '6.0.0' | ||
os: ubuntu-latest | ||
- expected-version: '6.0.0' | ||
os: macos-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install latest PocketIC server and check its version | ||
if: "${{ matrix.version == '' }}" | ||
uses: ./ | ||
- name: Install PocketIC server and check its version | ||
if: "${{ matrix.version != '' }}" | ||
uses: ./ | ||
with: | ||
pocket-ic-server-version: ${{ matrix.version }} | ||
- name: Check if the proper PocketIC server version is installed | ||
run: | | ||
actual_pocket_ic_server_ver="$(${POCKET_IC_BIN} --version)" | ||
expected_pocket_ic_server_ver="pocket-ic-server ${{ matrix.expected-version }}" | ||
if [ "$actual_pocket_ic_server_ver" != "$expected_pocket_ic_server_ver" ]; then | ||
echo "Error: expected PocketIC server version '$expected_pocket_ic_server_ver', but '$actual_pocket_ic_server_ver' found" | ||
exit 1 | ||
fi | ||
echo "PocketIC server version '$actual_pocket_ic_server_ver' was installed correctly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 'Install PocketIC server' | ||
description: 'Install the PocketIC server at a particular version' | ||
inputs: | ||
pocket-ic-server-version: | ||
description: > | ||
The PocketIC server version to install. | ||
If omitted, the latest version will be installed. | ||
default: '6.0.0' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install PocketIC server | ||
shell: sh | ||
run: | | ||
export POCKET_IC_VERSION="${{ inputs.pocket-ic-server-version }}" | ||
echo "POCKET_IC_VERSION is $POCKET_IC_VERSION" | ||
if [ "${{ runner.os }}" = 'Linux' ]; then | ||
export OS="linux" | ||
elif [ "${{ runner.os }}" = 'macOS' ]; then | ||
export OS="darwin" | ||
else | ||
echo "Unsupported OS." | ||
exit 1 | ||
fi | ||
echo "OS is $OS" | ||
# Retry up to 10 times. Each attempt has 20 seconds total to complete, 5 seconds of which is to connect. | ||
# This uses the default retry delay, which starts at 1s and doubles each time, up to 10 min. | ||
if $(curl --fail --silent --show-error --location --retry 10 --connect-timeout 5 --max-time 20 --retry-connrefused https://github.com/dfinity/pocketic/releases/download/${POCKET_IC_VERSION}/pocket-ic-x86_64-${OS}.gz -o pocket-ic.gz); then | ||
echo "Successfully downloaded PocketIC server." | ||
else | ||
echo "Failed to download PocketIC server." | ||
exit 1 | ||
fi | ||
gzip -d pocket-ic.gz | ||
chmod +x pocket-ic | ||
export POCKET_IC_BIN="$(pwd)/pocket-ic" | ||
echo "POCKET_IC_BIN=$POCKET_IC_BIN" >> $GITHUB_ENV |