Skip to content

Commit af9b7ea

Browse files
ci: Update Github Action for testing snippets and build docs
1 parent 8ec10ca commit af9b7ea

File tree

1 file changed

+102
-40
lines changed

1 file changed

+102
-40
lines changed

.github/workflows/docs-action.yml

Lines changed: 102 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,129 @@ 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
4659
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
4774
48-
- name: Install dependencies
75+
- name: Run gltestserver in background
76+
shell: bash
4977
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-
78+
mkdir -p $DATA_DIR
79+
cd ./libs/gl-testserver
80+
nohup uv run gltestserver run --directory $DATA_DIR > "$DATA_DIR"/gltestserver.log 2>&1 &
81+
82+
for i in {1..300}; do
83+
if [ -f "$DATA_DIR/metadata.json" ]; then
84+
echo "✅ metadata.json found"
85+
GL_SCHEDULER_GRPC_URI=$(jq -r '.scheduler_grpc_uri' "$DATA_DIR"/metadata.json)
86+
echo "GL_SCHEDULER_GRPC_URI=$GL_SCHEDULER_GRPC_URI" >> $GITHUB_ENV
87+
echo "GL_CA_CRT=$DATA_DIR/gl-testserver/certs/ca.crt" >> $GITHUB_ENV
88+
echo "GL_NOBODY_CRT=$DATA_DIR/gl-testserver/certs/users/nobody.crt" >> $GITHUB_ENV
89+
echo "GL_NOBODY_KEY=$DATA_DIR/gl-testserver/certs/users/nobody-key.pem" >> $GITHUB_ENV
90+
break
91+
fi
92+
echo "Waiting for metadata.json... ($i)"
93+
sleep 3
94+
done
95+
96+
- name: Run Python getting_started example
97+
run: |
98+
echo "Using scheduler URI for Python snippets: $GL_SCHEDULER_GRPC_URI"
99+
uv run python examples/python/snippets/getting_started.py
100+
101+
- name: Run Rust getting_started example
102+
run: |
103+
echo "Using scheduler URI for Rust snippets: $GL_SCHEDULER_GRPC_URI"
104+
cargo run --manifest-path examples/rust/Cargo.toml --bin getting_started
105+
61106
- name: Build docs
62107
env:
63108
DOCSBRANCH: "gh-pages"
64109
DOCSREMOTE: "origin"
65110
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/
111+
run: |
112+
mkdir -p ${GITHUB_WORKSPACE}/site/
113+
cd docs
114+
uv run mkdocs build --verbose --strict --clean --site-dir=${GITHUB_WORKSPACE}/site/
68115
69-
- name: Deploy
116+
- name: Deploy to GitHub Pages
70117
uses: peaceiris/actions-gh-pages@v3
71118
with:
72119
github_token: ${{ secrets.GITHUB_TOKEN }}
73120
publish_dir: ./site
121+
122+
- name: Upload gltestserver logs
123+
if: always()
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: gltestserver-logs
127+
path: /tmp/gltests/gltestserver.log
128+
129+
- name: Stop gltestserver
130+
if: always()
131+
run: |
132+
if [ -f "$DATA_DIR"/gltestserver.pid ]; then
133+
kill $(cat "$DATA_DIR"/gltestserver.pid) || true
134+
echo "✅ gltestserver stopped"
135+
fi

0 commit comments

Comments
 (0)