Skip to content

Commit 1826e09

Browse files
authored
feat: support x86_64 and arm64 CPU and download.dfinity.systems in action.yml (#44)
This PR generalizes `action.yml` to - distinguish between x86_64 and arm64 CPU architectures; - support git hashes as `pocket-ic-version` to download PocketIC from download.dfinity.systems CDN.
1 parent 14e32cd commit 1826e09

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

.github/workflows/pocket-ic-server-action-test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ jobs:
1717
os: ubuntu-latest
1818
- version: '5.0.0'
1919
expected-version: '5.0.0'
20-
os: macos-latest
20+
os: macos-13 # x86_64
2121

2222
- expected-version: '10.0.0'
2323
os: ubuntu-latest
2424
- expected-version: '10.0.0'
25-
os: macos-latest
25+
os: macos-13 # x86_64
26+
- expected-version: '10.0.0'
27+
os: macos-latest # arm64
28+
29+
- version: 'ee4c728d94b10437f41edf564650ac63cd0c0c5d'
30+
expected-version: '10.0.0'
31+
os: ubuntu-latest
32+
- version: 'ee4c728d94b10437f41edf564650ac63cd0c0c5d'
33+
expected-version: '10.0.0'
34+
os: macos-13 # x86_64
35+
- version: 'ee4c728d94b10437f41edf564650ac63cd0c0c5d'
36+
expected-version: '10.0.0'
37+
os: macos-latest # arm64
2638

2739
steps:
2840
- name: Checkout
@@ -42,7 +54,7 @@ jobs:
4254
expected_pocket_ic_server_ver="pocket-ic-server ${{ matrix.expected-version }}"
4355
4456
if [ "$actual_pocket_ic_server_ver" != "$expected_pocket_ic_server_ver" ]; then
45-
echo "Error: expected PocketIC server version '$expected_pocket_ic_server_ver', but '$actual_pocket_ic_server_ver' found"
57+
echo "Error: expected PocketIC server version '$expected_pocket_ic_server_ver', but got '$actual_pocket_ic_server_ver'"
4658
exit 1
4759
fi
4860
echo "PocketIC server version '$actual_pocket_ic_server_ver' was installed correctly"

action.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
using: composite
1212
steps:
1313
- name: Install PocketIC server
14-
shell: sh
14+
shell: bash
1515
run: |
1616
export POCKET_IC_VERSION="${{ inputs.pocket-ic-server-version }}"
1717
@@ -26,11 +26,30 @@ runs:
2626
exit 1
2727
fi
2828
29+
if [ "${{ runner.arch }}" = 'X64' ]; then
30+
export ARCH="x86_64"
31+
elif [ "${{ runner.arch }}" = 'ARM64' ]; then
32+
export ARCH="arm64"
33+
else
34+
echo "Unsupported CPU architecture."
35+
exit 1
36+
fi
37+
38+
# if `${POCKET_IC_VERSION}` is a git hash, then use CDN;
39+
# otherwise use a GitHub release.
40+
if [[ "${POCKET_IC_VERSION}" =~ ^[0-9a-f]{40,40}$ ]]; then
41+
URL="https://download.dfinity.systems/ic/${POCKET_IC_VERSION}/binaries/${ARCH}-${OS}/pocket-ic.gz"
42+
else
43+
URL="https://github.com/dfinity/pocketic/releases/download/${POCKET_IC_VERSION}/pocket-ic-${ARCH}-${OS}.gz"
44+
fi
45+
2946
echo "OS is $OS"
47+
echo "ARCH is $ARCH"
48+
echo "URL is $URL"
3049
3150
# Retry up to 10 times. Each attempt has 20 seconds total to complete, 5 seconds of which is to connect.
3251
# This uses the default retry delay, which starts at 1s and doubles each time, up to 10 min.
33-
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
52+
if $(curl --fail --silent --show-error --location --retry 10 --connect-timeout 5 --max-time 20 --retry-connrefused "${URL}" -o pocket-ic.gz); then
3453
echo "Successfully downloaded PocketIC server."
3554
else
3655
echo "Failed to download PocketIC server."

0 commit comments

Comments
 (0)