Skip to content

Commit e5489fb

Browse files
Merge branch 'main' into feat/update-satellte-template
2 parents 41a457c + 902a605 commit e5489fb

File tree

37 files changed

+422
-48
lines changed

37 files changed

+422
-48
lines changed

.github/actions/download-wasms/action.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,59 @@ name: Download WASM Artifacts
22

33
description: Downloads the WASM build artifacts
44

5+
inputs:
6+
path:
7+
description: Target directory for downloaded artifacts
8+
required: false
9+
default: "."
10+
511
runs:
612
using: "composite"
713
steps:
814
- name: Download satellite.wasm.gz
915
uses: actions/download-artifact@v4
1016
with:
1117
name: satellite.wasm.gz
12-
path: .
18+
path: ${{ inputs.path }}
1319

1420
- name: Download orbiter.wasm.gz
1521
uses: actions/download-artifact@v4
1622
with:
1723
name: orbiter.wasm.gz
18-
path: .
24+
path: ${{ inputs.path }}
1925

2026
- name: Download sputnik.wasm.gz
2127
uses: actions/download-artifact@v4
2228
with:
2329
name: sputnik.wasm.gz
24-
path: .
30+
path: ${{ inputs.path }}
2531

2632
- name: Download console.wasm.gz
2733
uses: actions/download-artifact@v4
2834
with:
2935
name: console.wasm.gz
30-
path: .
36+
path: ${{ inputs.path }}
3137

3238
- name: Download observatory.wasm.gz
3339
uses: actions/download-artifact@v4
3440
with:
3541
name: observatory.wasm.gz
36-
path: .
42+
path: ${{ inputs.path }}
3743

3844
- name: Download mission_control.wasm.gz
3945
uses: actions/download-artifact@v4
4046
with:
4147
name: mission_control.wasm.gz
42-
path: .
48+
path: ${{ inputs.path }}
4349

4450
- name: Download test_satellite.wasm.gz
4551
uses: actions/download-artifact@v4
4652
with:
4753
name: test_satellite.wasm.gz
48-
path: .
54+
path: ${{ inputs.path }}
4955

5056
- name: Download test_sputnik.wasm.gz
5157
uses: actions/download-artifact@v4
5258
with:
5359
name: test_sputnik.wasm.gz
54-
path: .
60+
path: ${{ inputs.path }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run emulator
2+
3+
description: Start and config the emulator
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Run emulator
9+
shell: bash
10+
run: |
11+
set -e
12+
./scripts/emulator.sh --headless &
13+
npm run emulator:wait
14+
15+
- name: Identity Console controller locally
16+
shell: bash
17+
run: |
18+
set -e
19+
node ./scripts/console.controller.mjs --headless
20+
21+
# We have copied the WASMs into target/deploy
22+
# Therefore, the latest Satellite, Mission Control and Orbiter
23+
# were already uploaded to the Console at boot time
24+
- name: Upgrade the Console
25+
shell: bash
26+
run: |
27+
set -e
28+
node ./scripts/console.upgrade.mjs --headless

.github/workflows/tests-screenshots.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ jobs:
8484

8585
- name: Download WASM Artifacts
8686
uses: ./.github/actions/download-wasms
87+
with:
88+
path: ./target/deploy
89+
90+
- name: Run emulator
91+
uses: ./.github/actions/emulator
8792

8893
- name: Run Playwright tests
8994
run: npm run e2e:snapshots

.github/workflows/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ jobs:
116116

117117
- name: Download WASM Artifacts
118118
uses: ./.github/actions/download-wasms
119+
with:
120+
path: ./target/deploy
121+
122+
- name: Run emulator
123+
uses: ./.github/actions/emulator
119124

120125
- name: E2E tests
121126
run: npm run e2e:ci

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"e2e:ci": "playwright test --reporter=html",
5151
"e2e:snapshots": "playwright test --update-snapshots --reporter=list",
5252
"e2e:report": "playwright show-report",
53-
"e2e:playwright:install": "playwright install --with-deps",
53+
"e2e:playwright:install": "playwright install chromium --with-deps",
5454
"build:console": "scripts/cargo.sh --console",
5555
"build:observatory": "scripts/cargo.sh --observatory",
5656
"build:satellite": "scripts/cargo.sh --satellite",
@@ -61,10 +61,12 @@
6161
"build:test-satellite": "scripts/cargo.sh --test_satellite",
6262
"build:test-sputnik": "scripts/cargo.sh --test_sputnik",
6363
"build:modules": "npm run build:console && npm run build:observatory && npm run build:satellite && npm run build:mission-control && npm run build:orbiter",
64-
"emulator": "./scripts/emulator.sh"
64+
"emulator": "./scripts/emulator.sh",
65+
"emulator:wait": "node scripts/emulator.wait.mjs"
6566
},
6667
"devDependencies": {
6768
"@dfinity/eslint-config-oisy-wallet": "^0.2.2",
69+
"@dfinity/internet-identity-playwright": "^2.0.0",
6870
"@dfinity/pic": "^0.13.1",
6971
"@dfinity/response-verification": "^3.0.3",
7072
"@junobuild/cli-tools": "^0.4.1",

playwright.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export default defineConfig({
1818
caret: 'hide'
1919
}
2020
},
21+
webServer: {
22+
command: 'npm run prepare && npm run dev',
23+
url: 'http://localhost:5173',
24+
reuseExistingServer: !!process.env.CI,
25+
timeout: 120 * 1000
26+
},
2127
use: {
2228
testIdAttribute: 'data-tid',
2329
baseURL: 'http://localhost:5173',

scripts/console.config.utils.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { nonNullish } from '@dfinity/utils';
33
import { assertAnswerCtrlC } from '@junobuild/cli-tools';
44
import Conf from 'conf';
55
import prompts from 'prompts';
6+
import { isHeadless } from './utils.mjs';
67

78
const askForPassword = async () => {
89
const { encryptionKey } = await prompts([
@@ -25,7 +26,7 @@ const initConfig = async (mainnet) => {
2526
return;
2627
}
2728

28-
const encryptionKey = await askForPassword();
29+
const encryptionKey = isHeadless() ? false : await askForPassword();
2930

3031
const projectName = `juno-${mainnet ? '' : 'dev-'}console`;
3132

scripts/emulator.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33
CONTAINER_NAME="juno-console"
44
VOLUME="juno_console"
55

6+
RUN_FLAGS="-it"
7+
START_FLAGS="-i"
8+
9+
for arg in "$@"; do
10+
if [ "$arg" = "--headless" ]; then
11+
RUN_FLAGS=""
12+
START_FLAGS=""
13+
fi
14+
done
15+
616
if docker ps -a -q -f name="^/${CONTAINER_NAME}$" | grep -q .; then
717
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME")" = "true" ]; then
818
echo "✋ Container '$CONTAINER_NAME' is already running..."
919
else
1020
echo "▶️ Starting the emulator..."
11-
docker start -a -i "$CONTAINER_NAME"
21+
docker start -a $START_FLAGS "$CONTAINER_NAME"
1222
fi
1323
else
1424
echo "🚀 Running new emulator..."
1525

16-
docker run -it \
26+
docker run $RUN_FLAGS \
1727
--name "$CONTAINER_NAME" \
1828
-p 5987:5987 \
1929
-p 5999:5999 \

scripts/emulator.wait.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const DEFAULT_TIMEOUT_IN_MILLISECONDS = 2 * 60 * 1000;
2+
const RETRY_IN_MILLISECONDS = 500;
3+
4+
const waitEmulatorReady = async ({ count }) => {
5+
const ready = await isEmulatorReady();
6+
7+
if (ready) {
8+
return 'ready';
9+
}
10+
11+
const nextCount = count - 1;
12+
13+
if (nextCount === 0) {
14+
return 'timeout';
15+
}
16+
17+
await new Promise((resolve) => setTimeout(resolve, RETRY_IN_MILLISECONDS));
18+
19+
return await waitEmulatorReady({ count: nextCount });
20+
};
21+
22+
const isEmulatorReady = async () => {
23+
try {
24+
const { result } = await dispatchRequest({
25+
request: 'health'
26+
});
27+
28+
return result === 'ok';
29+
} catch (_e) {
30+
return false;
31+
}
32+
};
33+
34+
const dispatchRequest = async ({ request, timeout = 5000 }) => {
35+
const adminPort = 5999;
36+
37+
try {
38+
const response = await fetch(`http://localhost:${adminPort}/${request}`, {
39+
signal: AbortSignal.timeout(timeout)
40+
});
41+
42+
if (!response.ok) {
43+
return { result: 'not_ok', response };
44+
}
45+
46+
return { result: 'ok', response };
47+
} catch (err) {
48+
return { result: 'error', err };
49+
}
50+
};
51+
52+
console.log('Waiting for emulator...');
53+
54+
const status = await waitEmulatorReady({
55+
count: DEFAULT_TIMEOUT_IN_MILLISECONDS / RETRY_IN_MILLISECONDS
56+
});
57+
58+
if (status === 'timeout') {
59+
console.error('❌ The emulator is not ready. Operation timed out.');
60+
process.exit(1);
61+
}
62+
63+
console.log('Emulator is ready. ✅');

0 commit comments

Comments
 (0)