Skip to content

Commit 49a272f

Browse files
ShahanaFarooquicdecker
authored andcommitted
ci: Update Github Action for testing snippets and build docs
1 parent d4dd14b commit 49a272f

File tree

1 file changed

+107
-40
lines changed

1 file changed

+107
-40
lines changed

.github/workflows/docs-action.yml

Lines changed: 107 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,134 @@ on:
77
paths:
88
- "docs/**.md"
99
- "docs/mkdocs.yml"
10+
- "examples/python/**"
11+
- "examples/rust/**"
1012
workflow_dispatch:
1113

1214
jobs:
13-
test-examples:
14-
permissions:
15-
contents: read
15+
build-and-deploy-docs:
1616
runs-on: ubuntu-latest
17-
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-
32-
build-and-deploy:
33-
needs: test-examples
3417
permissions:
3518
pages: write # to deploy to Pages
3619
id-token: write # to verify the deployment originates from an appropriate source
3720
contents: write
38-
runs-on: ubuntu-latest
21+
env:
22+
RUSTFLAGS: "-A dead-code -A unused_variables -A mismatched_lifetime_syntaxes"
23+
CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG: "true"
24+
DATA_DIR: "/tmp/gltests"
25+
3926
steps:
40-
- name: Checkout Github repo
27+
- name: Checkout repository
4128
uses: actions/checkout@v4
42-
- name: Set up Python
43-
uses: actions/setup-python@v5
4429
with:
45-
python-version: 3.9
30+
ref: testing-doc-snippets
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
fetch-depth: 0
33+
34+
- name: Install system dependencies
35+
run: |
36+
# Remove broken Git LFS source from old packagecloud, required for ACT testing
37+
sudo rm -f /etc/apt/sources.list.d/github_git-lfs.list || true
38+
sudo apt-get update
39+
sudo apt-get install -y python3 protobuf-compiler openssl libpq5 golang-cfssl ca-certificates
40+
41+
- name: Setup uv
42+
uses: astral-sh/setup-uv@v1
43+
with:
44+
version: "0.9.5"
45+
46+
- name: Setup Rust
47+
uses: actions-rust-lang/setup-rust-toolchain@v1
48+
with:
49+
toolchain: stable
50+
components: rustfmt
51+
52+
- name: Ensure protoc is available
53+
run: |
54+
mkdir -p /tmp/protoc && cd /tmp/protoc
55+
wget --quiet -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.3/protoc-3.19.3-linux-x86_64.zip
56+
unzip protoc.zip
57+
sudo mv bin/protoc /usr/local/bin
58+
sudo chmod a+x /usr/local/bin/protoc
59+
60+
- name: Install bitcoind manually
61+
run: |
62+
BITCOIN_VERSION=28.2
63+
curl -O https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
64+
tar -xzf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
65+
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-${BITCOIN_VERSION}/bin/*
66+
67+
- name: Build Rust packages
68+
run: cargo build --workspace
69+
70+
- name: Sync Python dependencies
71+
run: |
72+
uv lock
73+
uv sync --locked -v --all-packages --dev
74+
75+
- name: Install CLN versions
76+
run: |
77+
cd ./libs/cln-version-manager
78+
uv run --extra cli clnvm get-all
79+
echo "CLN Versions Installed"
80+
81+
- name: Run gltestserver in background
82+
shell: bash
83+
run: |
84+
mkdir -p $DATA_DIR
85+
cd ./libs/gl-testserver
86+
nohup uv run gltestserver run --directory $DATA_DIR > "$DATA_DIR"/gltestserver.log 2>&1 &
4687
88+
for i in {1..300}; do
89+
if [ -f "$DATA_DIR/metadata.json" ]; then
90+
echo "✅ metadata.json found"
91+
GL_SCHEDULER_GRPC_URI=$(jq -r '.scheduler_grpc_uri' "$DATA_DIR"/metadata.json)
92+
echo "GL_SCHEDULER_GRPC_URI=$GL_SCHEDULER_GRPC_URI" >> $GITHUB_ENV
93+
echo "GL_CA_CRT=$DATA_DIR/gl-testserver/certs/ca.crt" >> $GITHUB_ENV
94+
echo "GL_NOBODY_CRT=$DATA_DIR/gl-testserver/certs/users/nobody.crt" >> $GITHUB_ENV
95+
echo "GL_NOBODY_KEY=$DATA_DIR/gl-testserver/certs/users/nobody-key.pem" >> $GITHUB_ENV
96+
break
97+
fi
98+
echo "Waiting for metadata.json... ($i)"
99+
sleep 3
100+
done
47101
48-
- name: Install dependencies
102+
- name: Run Python getting_started example
49103
run: |
50-
mkdir /tmp/protoc && \
51-
cd /tmp/protoc && \
52-
wget --quiet -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.3/protoc-3.19.3-linux-x86_64.zip && \
53-
unzip protoc.zip && \
54-
mv /tmp/protoc/bin/protoc /usr/local/bin && \
55-
chmod a+x /usr/local/bin/protoc && \
56-
rm -rf /tmp/protoc \
57-
58-
- name: Install dependencies
59-
run: uv sync
60-
104+
echo "Using scheduler URI for Python snippets: $GL_SCHEDULER_GRPC_URI"
105+
uv run python examples/python/snippets/getting_started.py
106+
107+
- name: Run Rust getting_started example
108+
run: |
109+
echo "Using scheduler URI for Rust snippets: $GL_SCHEDULER_GRPC_URI"
110+
cargo run --manifest-path examples/rust/Cargo.toml --bin getting_started
111+
61112
- name: Build docs
62113
env:
63114
DOCSBRANCH: "gh-pages"
64115
DOCSREMOTE: "origin"
65116
GITHUB_TOKEN: "${{ secrets.GH_PAGES_PAT }}"
66-
run: mkdir -p ${GITHUB_WORKSPACE}/site/
67-
- run: cd docs && uv run mkdocs build --verbose --strict --clean --site-dir=${GITHUB_WORKSPACE}/site/
117+
run: |
118+
mkdir -p ${GITHUB_WORKSPACE}/site/
119+
cd docs
120+
uv run mkdocs build --verbose --strict --clean --site-dir=${GITHUB_WORKSPACE}/site/
68121
69-
- name: Deploy
122+
- name: Deploy to GitHub Pages
70123
uses: peaceiris/actions-gh-pages@v3
71124
with:
72125
github_token: ${{ secrets.GITHUB_TOKEN }}
73126
publish_dir: ./site
127+
128+
- name: Upload gltestserver logs
129+
if: failure()
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: gltestserver-logs
133+
path: /tmp/gltests/gltestserver.log
134+
135+
- name: Stop gltestserver
136+
run: |
137+
if [ -f "$DATA_DIR"/gltestserver.pid ]; then
138+
kill $(cat "$DATA_DIR"/gltestserver.pid) || true
139+
echo "✅ gltestserver stopped"
140+
fi

0 commit comments

Comments
 (0)