|
7 | 7 | paths: |
8 | 8 | - "docs/**.md" |
9 | 9 | - "docs/mkdocs.yml" |
| 10 | + - "examples/python" |
| 11 | + - "examples/rust" |
10 | 12 | workflow_dispatch: |
11 | 13 |
|
12 | 14 | jobs: |
13 | 15 | test-examples: |
14 | 16 | permissions: |
15 | 17 | contents: read |
16 | 18 | runs-on: ubuntu-latest |
| 19 | + env: |
| 20 | + RUSTFLAGS: "-A dead-code -A unused_variables -A mismatched_lifetime_syntaxes" |
| 21 | + CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG: "true" |
| 22 | + DATA_DIR: "/tmp/gltests" |
17 | 23 | steps: |
18 | | - - uses: actions/checkout@v4 |
19 | | - - uses: actions-rs/toolchain@v1 |
20 | | - with: |
21 | | - toolchain: stable |
22 | | - - run: | |
23 | | - mkdir /tmp/protoc && \ |
24 | | - cd /tmp/protoc && \ |
25 | | - wget --quiet -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.3/protoc-3.19.3-linux-x86_64.zip && \ |
26 | | - unzip protoc.zip && \ |
27 | | - mv /tmp/protoc/bin/protoc /usr/local/bin && \ |
28 | | - chmod a+x /usr/local/bin/protoc && \ |
29 | | - rm -rf /tmp/protoc |
30 | | - - run: cargo build --manifest-path ./examples/rust/Cargo.toml |
31 | | - |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + ref: testing-doc-snippets |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - name: Install system dependencies |
| 31 | + run: | |
| 32 | + # Remove broken Git LFS source from old packagecloud, required for ACT testing |
| 33 | + sudo rm -f /etc/apt/sources.list.d/github_git-lfs.list || true |
| 34 | + sudo apt-get update |
| 35 | + sudo apt-get install -y python3 protobuf-compiler openssl libpq5 golang-cfssl ca-certificates |
| 36 | +
|
| 37 | + - name: Setup uv |
| 38 | + uses: astral-sh/setup-uv@v1 |
| 39 | + with: |
| 40 | + version: "0.9.5" |
| 41 | + |
| 42 | + - name: Setup Rust |
| 43 | + uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 44 | + with: |
| 45 | + toolchain: stable |
| 46 | + components: rustfmt |
| 47 | + |
| 48 | + - name: Install bitcoind manually |
| 49 | + run: | |
| 50 | + BITCOIN_VERSION=28.2 |
| 51 | + curl -O https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz |
| 52 | + tar -xzf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz |
| 53 | + sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-${BITCOIN_VERSION}/bin/* |
| 54 | +
|
| 55 | + - name: Build Rust packages |
| 56 | + run: cargo build --workspace |
| 57 | + |
| 58 | + - name: Run gltestserver in background |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + mkdir -p $DATA_DIR |
| 62 | + cd ./libs/gl-testserver |
| 63 | + uv lock |
| 64 | + uv sync --locked -v --no-editable |
| 65 | + |
| 66 | + # Run server detached so it survives the step |
| 67 | + nohup uv run gltestserver run --directory $DATA_DIR > "$DATA_DIR"/gltestserver.log 2>&1 & |
| 68 | +
|
| 69 | + # Wait for gltestserver metadata |
| 70 | + for i in {1..300}; do |
| 71 | + if [ -f "$DATA_DIR/metadata.json" ]; then |
| 72 | + echo "✅ metadata.json found" |
| 73 | + GL_SCHEDULER_GRPC_URI=$(jq -r '.scheduler_grpc_uri' "$DATA_DIR"/metadata.json) |
| 74 | + echo "GL_SCHEDULER_GRPC_URI=$GL_SCHEDULER_GRPC_URI" >> $GITHUB_ENV |
| 75 | + break |
| 76 | + fi |
| 77 | + echo "Waiting for metadata.json... ($i)" |
| 78 | + sleep 1 |
| 79 | + done |
| 80 | +
|
| 81 | + - name: Run Python getting_started example |
| 82 | + run: | |
| 83 | + echo "Using scheduler URI for Python snippets: $GL_SCHEDULER_GRPC_URI" |
| 84 | + GL_CA_CRT="$DATA_DIR/gl-testserver/certs/ca.crt" \ |
| 85 | + GL_NOBODY_CRT="$DATA_DIR/gl-testserver/certs/users/nobody.crt" \ |
| 86 | + GL_NOBODY_KEY="$DATA_DIR/gl-testserver/certs/users/nobody-key.pem" \ |
| 87 | + GL_SCHEDULER_GRPC_URI="$GL_SCHEDULER_GRPC_URI" \ |
| 88 | + uv run python examples/python/snippets/getting_started.py |
| 89 | +
|
| 90 | + - name: Run Rust getting_started example |
| 91 | + run: | |
| 92 | + echo "Using scheduler URI for Rust snippets: $GL_SCHEDULER_GRPC_URI" |
| 93 | + GL_CA_CRT="$DATA_DIR/gl-testserver/certs/ca.crt" \ |
| 94 | + GL_NOBODY_CRT="$DATA_DIR/gl-testserver/certs/users/nobody.crt" \ |
| 95 | + GL_NOBODY_KEY="$DATA_DIR/gl-testserver/certs/users/nobody-key.pem" \ |
| 96 | + GL_SCHEDULER_GRPC_URI="$GL_SCHEDULER_GRPC_URI" \ |
| 97 | + cargo run --manifest-path examples/rust/Cargo.toml --bin getting_started |
| 98 | +
|
| 99 | + - name: Upload gltestserver logs |
| 100 | + if: always() |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: gltestserver-logs |
| 104 | + path: /tmp/gltests/gltestserver.log |
| 105 | + |
| 106 | + - name: Stop gltestserver |
| 107 | + if: always() |
| 108 | + run: | |
| 109 | + if [ -f "$DATA_DIR"/gltestserver.pid ]; then |
| 110 | + kill $(cat "$DATA_DIR"/gltestserver.pid) || true |
| 111 | + echo "✅ gltestserver stopped" |
| 112 | + fi |
| 113 | +
|
32 | 114 | build-and-deploy: |
33 | 115 | needs: test-examples |
34 | 116 | permissions: |
|
0 commit comments