Skip to content

Commit 1ec8cef

Browse files
committed
fix: fix nim interop env setup file
1 parent 9fce759 commit 1ec8cef

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

.github/workflows/tox.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ jobs:
3636
- uses: actions/setup-python@v5
3737
with:
3838
python-version: ${{ matrix.python }}
39-
- run: |
40-
python -m pip install --upgrade pip
41-
python -m pip install tox
39+
40+
# Add Nim installation for interop tests
4241
- name: Install Nim for interop testing
4342
if: matrix.toxenv == 'interop'
4443
run: |
@@ -47,12 +46,18 @@ jobs:
4746
echo "$HOME/.nimble/bin" >> $GITHUB_PATH
4847
echo "$HOME/.choosenim/toolchains/nim-stable/bin" >> $GITHUB_PATH
4948
50-
- name: Verify Nim installation
49+
# Cache nimble packages - ADD THIS
50+
- name: Cache nimble packages
5151
if: matrix.toxenv == 'interop'
52-
run: |
53-
export PATH="$HOME/.nimble/bin:$HOME/.choosenim/toolchains/nim-stable/bin:$PATH"
54-
nim --version
55-
nimble --version
52+
uses: actions/cache@v4
53+
with:
54+
path: |
55+
~/.nimble
56+
~/.choosenim/toolchains/*/lib
57+
key: ${{ runner.os }}-nimble-${{ hashFiles('**/nim_echo_server.nim') }}
58+
restore-keys: |
59+
${{ runner.os }}-nimble-
60+
5661
- name: Build nim interop binaries
5762
if: matrix.toxenv == 'interop'
5863
run: |
@@ -61,6 +66,11 @@ jobs:
6166
./scripts/setup_nim_echo.sh
6267
6368
- run: |
69+
python -m pip install --upgrade pip
70+
python -m pip install tox
71+
72+
- name: Run Tests or Generate Docs
73+
run: |
6474
if [[ "${{ matrix.toxenv }}" == 'docs' ]]; then
6575
export TOXENV=docs
6676
else

tests/interop/nim_libp2p/scripts/setup_nim_echo.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# tests/interop/nim_libp2p/scripts/setup_nim_echo.sh
3+
# Cache-aware setup that skips installation if packages exist
24

35
set -euo pipefail
46

@@ -8,9 +10,11 @@ PROJECT_DIR="${SCRIPT_DIR}/.."
810
# Colors
911
GREEN='\033[0;32m'
1012
RED='\033[0;31m'
13+
YELLOW='\033[1;33m'
1114
NC='\033[0m'
1215

1316
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
17+
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
1418
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
1519

1620
main() {
@@ -33,23 +37,32 @@ main() {
3337
return 0
3438
fi
3539

36-
log_info "Installing nim-libp2p globally..."
37-
# Install libp2p globally so nim can find it
38-
nimble install -y libp2p
40+
# Check if libp2p is already installed (cache-aware)
41+
if nimble list -i | grep -q "libp2p"; then
42+
log_info "libp2p already installed, skipping installation"
43+
else
44+
log_info "Installing nim-libp2p globally..."
45+
nimble install -y libp2p
46+
fi
3947

4048
log_info "Building nim echo server..."
4149
# Compile the echo server
4250
nim c \
4351
-d:release \
4452
-d:chronicles_log_level=INFO \
53+
-d:libp2p_quic_support \
54+
-d:chronos_event_loop=iocp \
55+
-d:ssl \
4556
--opt:speed \
4657
--mm:orc \
58+
--verbosity:1 \
4759
-o:nim_echo_server \
4860
nim_echo_server.nim
4961

5062
# Verify binary was created
5163
if [[ -f "nim_echo_server" ]]; then
5264
log_info "✅ nim_echo_server built successfully"
65+
log_info "Binary size: $(ls -lh nim_echo_server | awk '{print $5}')"
5366
else
5467
log_error "❌ Failed to build nim_echo_server"
5568
exit 1

0 commit comments

Comments
 (0)