Skip to content

Commit bc227db

Browse files
committed
CI: add documentation to run CI jobs with act
1 parent a1c5cd9 commit bc227db

File tree

7 files changed

+473
-0
lines changed

7 files changed

+473
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: CI Documentation Scripts
2+
3+
# This workflow tests the CI documentation setup scripts to ensure they work correctly.
4+
# It runs nightly and on-demand to avoid slowing down regular development workflow.
5+
on:
6+
pull_request:
7+
types: [labeled]
8+
# Only runs when 'test-doc-scripts' or 'test-ci' label is added to a PR
9+
schedule:
10+
# Run nightly to catch environment drift and ensure scripts stay functional
11+
- cron: '0 3 * * *'
12+
workflow_dispatch:
13+
# Allow manual triggering for testing
14+
15+
jobs:
16+
test-act-installation:
17+
name: Test Act Installation (${{ matrix.os }})
18+
runs-on: ${{ matrix.os }}
19+
# Only run if the event is scheduled, manual, or PR has test-doc-scripts or test-ci label
20+
if: |
21+
github.event_name == 'schedule' ||
22+
github.event_name == 'workflow_dispatch' ||
23+
contains(github.event.pull_request.labels.*.name, 'test-doc-scripts') ||
24+
contains(github.event.pull_request.labels.*.name, 'test-ci')
25+
strategy:
26+
matrix:
27+
os: [ubuntu-22.04, ubuntu-24.04, macos-latest]
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v5
32+
33+
- name: Test GitHub CLI installation (Ubuntu)
34+
if: startsWith(matrix.os, 'ubuntu')
35+
run: |
36+
# Execute the install-gh-cli-ubuntu.sh script as a user would
37+
bash ./website/docs/developers/scripts/ci/install-gh-cli-ubuntu.sh
38+
39+
- name: Test GitHub CLI installation (macOS)
40+
if: startsWith(matrix.os, 'macos')
41+
run: |
42+
# Execute the install-gh-cli-macos.sh script as a user would
43+
bash ./website/docs/developers/scripts/ci/install-gh-cli-macos.sh
44+
45+
- name: Test act extension installation
46+
env:
47+
GH_TOKEN: ${{ github.token }}
48+
run: |
49+
# Execute the install-act.sh script as a user would
50+
bash ./website/docs/developers/scripts/ci/install-act.sh
51+
52+
- name: Test act functionality
53+
run: |
54+
# Execute the test-act-functionality.sh script as a user would
55+
bash ./website/docs/developers/scripts/ci/test-act-functionality.sh
56+
57+
verify-ci-script-consistency:
58+
name: Verify CI Script Consistency
59+
runs-on: ubuntu-latest
60+
# Always run this check on PRs that modify CI scripts
61+
if: |
62+
github.event_name == 'pull_request' &&
63+
(contains(github.event.pull_request.labels.*.name, 'test-doc-scripts') ||
64+
contains(github.event.pull_request.labels.*.name, 'test-ci'))
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v5
69+
70+
- name: Check CI script files exist
71+
run: |
72+
# Verify all referenced CI scripts exist
73+
scripts=(
74+
"website/docs/developers/scripts/ci/install-gh-cli-ubuntu.sh"
75+
"website/docs/developers/scripts/ci/install-gh-cli-macos.sh"
76+
"website/docs/developers/scripts/ci/install-act.sh"
77+
"website/docs/developers/scripts/ci/test-act-functionality.sh"
78+
)
79+
80+
missing=0
81+
for script in "${scripts[@]}"; do
82+
if [ ! -f "$script" ]; then
83+
echo "❌ Missing script: $script"
84+
missing=$((missing + 1))
85+
else
86+
echo "✅ Found: $script"
87+
fi
88+
done
89+
90+
if [ $missing -gt 0 ]; then
91+
echo "ERROR: $missing script(s) missing"
92+
exit 1
93+
fi
94+
95+
- name: Verify CI scripts are referenced in documentation
96+
run: |
97+
# Check that all CI scripts are imported in the CI local MDX file
98+
mdx_file="website/docs/developers/testing/ci-local.mdx"
99+
100+
if [ ! -f "$mdx_file" ]; then
101+
echo "❌ CI local documentation file not found: $mdx_file"
102+
exit 1
103+
fi
104+
105+
# Check for script imports
106+
scripts=(
107+
"install-gh-cli-ubuntu.sh"
108+
"install-gh-cli-macos.sh"
109+
"install-act.sh"
110+
)
111+
112+
missing=0
113+
for script in "${scripts[@]}"; do
114+
if ! grep -q "$script" "$mdx_file"; then
115+
echo "❌ Script not referenced in docs: $script"
116+
missing=$((missing + 1))
117+
else
118+
echo "✅ Script referenced: $script"
119+
fi
120+
done
121+
122+
if [ $missing -gt 0 ]; then
123+
echo "ERROR: $missing script(s) not referenced in documentation"
124+
exit 1
125+
fi
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Install act extension for GitHub CLI
2+
if gh extension install nektos/gh-act; then
3+
echo "✅ Act extension installed successfully"
4+
# Verify installation
5+
gh act --version
6+
else
7+
echo "⚠️ Act extension installation failed - likely due to authentication"
8+
echo " This is expected in CI environments without proper GitHub authentication"
9+
echo " In a real setup, users would run: gh auth login"
10+
echo "✅ GitHub CLI is properly installed and ready for act extension"
11+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Install GitHub CLI on macOS
2+
brew install gh
3+
4+
# Verify installation
5+
gh --version
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Install GitHub CLI on Ubuntu
2+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
3+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
4+
sudo apt update
5+
sudo apt install -y gh
6+
7+
# Verify installation
8+
gh --version
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Test act can list workflows
2+
if command -v "gh act" >/dev/null 2>&1; then
3+
echo "✅ Testing act functionality..."
4+
gh act -l -W .github/workflows/test-docs-scripts-ci.yaml
5+
else
6+
echo "⚠️ Act extension not available (likely due to authentication in CI)"
7+
echo " In a real setup with authentication, you would run:"
8+
echo " gh act -l -W .github/workflows/test-docs-scripts-ci.yaml"
9+
echo "✅ Test completed - act functionality would work with proper authentication"
10+
fi

0 commit comments

Comments
 (0)