Skip to content

Commit 03c0d93

Browse files
committed
CI: Switch to Lychee for link validation.
1 parent f120e7f commit 03c0d93

File tree

6 files changed

+198
-421
lines changed

6 files changed

+198
-421
lines changed

.github/workflows/test-links.yml

Lines changed: 14 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,99 +4,35 @@ on:
44
push:
55
branches:
66
- '**'
7-
workflow_dispatch:
8-
inputs:
9-
tutorial:
10-
description: 'Tutorial name to test'
11-
required: true
12-
type: string
13-
commit_sha:
14-
description: 'Commit SHA to update status for'
15-
required: false
16-
type: string
177

188
jobs:
19-
discover-tutorials:
20-
if: github.event_name == 'push'
21-
runs-on: ubuntu-latest
22-
outputs:
23-
tutorials: ${{ steps.find-tutorials.outputs.tutorials }}
24-
steps:
25-
- name: Checkout repository
26-
uses: actions/checkout@v4
27-
28-
- name: Find tutorial directories
29-
id: find-tutorials
30-
run: |
31-
tutorials=$(brev/discover-tutorials.bash | jq -R -s -c 'split("\n") | map(select(length > 0))')
32-
echo "tutorials=${tutorials}" >> $GITHUB_OUTPUT
33-
echo "Found tutorials: ${tutorials}"
34-
359
test-links:
36-
needs: [discover-tutorials]
37-
if: always() && !cancelled()
3810
runs-on: ubuntu-latest
39-
permissions:
40-
statuses: write
41-
strategy:
42-
matrix:
43-
tutorial: ${{ github.event_name == 'push' && fromJson(needs.discover-tutorials.outputs.tutorials) || fromJson(format('["{0}"]', format('tutorials/{0}', inputs.tutorial))) }}
44-
fail-fast: false
4511

4612
steps:
4713
- name: Checkout repository
4814
uses: actions/checkout@v4
4915

50-
- name: Set tutorial name
51-
id: set-tutorial
52-
run: |
53-
tutorial_name=$(basename ${{ matrix.tutorial }})
54-
echo "tutorial_name=${tutorial_name}" >> $GITHUB_OUTPUT
55-
5616
- name: Set up Python
5717
uses: actions/setup-python@v5
5818
with:
5919
python-version: '3.10'
6020

61-
- name: Install dependencies
21+
- name: Install nbconvert
6222
run: |
6323
python -m pip install --upgrade pip
64-
pip install requests
65-
66-
- name: Test Markdown Links
67-
id: test-markdown-links
68-
run: |
69-
python ./brev/test_markdown_links.py "${{ matrix.tutorial }}"
70-
71-
- name: Test Notebook Links
72-
id: test-notebook-links
73-
run: |
74-
python ./brev/test_notebook_links.py "${{ matrix.tutorial }}"
75-
76-
- name: Update commit status to success
77-
if: success() && (github.event_name == 'workflow_dispatch' && inputs.commit_sha != '')
78-
run: |
79-
gh api \
80-
--method POST \
81-
-H "Accept: application/vnd.github+json" \
82-
/repos/${{ github.repository }}/statuses/${{ inputs.commit_sha }} \
83-
-f state='success' \
84-
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
85-
-f description='Link tests passed' \
86-
-f context='test-links / ${{ steps.set-tutorial.outputs.tutorial_name }}'
87-
env:
88-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
pip install nbconvert
8925
90-
- name: Update commit status to failure
91-
if: failure() && (github.event_name == 'workflow_dispatch' && inputs.commit_sha != '')
26+
- name: Convert all Notebooks to Markdown
9227
run: |
93-
gh api \
94-
--method POST \
95-
-H "Accept: application/vnd.github+json" \
96-
/repos/${{ github.repository }}/statuses/${{ inputs.commit_sha }} \
97-
-f state='failure' \
98-
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
99-
-f description='Link tests failed' \
100-
-f context='test-links / ${{ steps.set-tutorial.outputs.tutorial_name }}'
101-
env:
102-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
echo "Converting all Jupyter notebooks to markdown..."
29+
find . -name "*.ipynb" -type f | while read notebook; do
30+
echo "Converting: $notebook"
31+
jupyter nbconvert --to markdown "$notebook"
32+
done
33+
34+
- name: Check Links with Lychee
35+
uses: lycheeverse/lychee-action@v2
36+
with:
37+
args: --verbose --no-progress '.'
38+
fail: true

brev/link_validator.py

Lines changed: 0 additions & 83 deletions
This file was deleted.

brev/test-docker-compose.bash

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,53 @@
1-
#! /bin/bash
2-
3-
# This script tests a single Docker Compose file by starting and stopping containers.
1+
#!/usr/bin/env bash
2+
#
3+
# Test a Docker Compose file by starting and stopping containers.
4+
#
5+
# This script validates Docker Compose configurations by attempting to start,
6+
# inspect, and cleanly stop containers.
47
#
58
# Usage:
6-
# ./test-docker-compose.bash <tutorial-name|docker-compose-file>
9+
# ./brev/test-docker-compose.bash <tutorial-name|docker-compose-file>
710
#
811
# Examples:
9-
# ./test-docker-compose.bash accelerated-python
10-
# ./test-docker-compose.bash tutorials/accelerated-python/brev/docker-compose.yml
12+
# ./brev/test-docker-compose.bash accelerated-python
13+
# ./brev/test-docker-compose.bash tutorials/accelerated-python/brev/docker-compose.yml
1114

1215
set -euo pipefail
1316

17+
# Colors for output
18+
RED='\033[0;31m'
19+
GREEN='\033[0;32m'
20+
YELLOW='\033[1;33m'
21+
NC='\033[0m' # No Color
22+
1423
SCRIPT_PATH=$(cd $(dirname ${0}); pwd -P)
1524
REPO_ROOT=$(cd ${SCRIPT_PATH}/..; pwd -P)
1625

26+
# Print usage
27+
usage() {
28+
cat << EOF
29+
Usage: $(basename "$0") <tutorial-name|docker-compose-file>
30+
31+
Test a Docker Compose file by starting and stopping containers.
32+
33+
Arguments:
34+
tutorial-name Name of tutorial (e.g., accelerated-python)
35+
docker-compose-file Path to docker-compose.yml file
36+
37+
Examples:
38+
$(basename "$0") accelerated-python
39+
$(basename "$0") tutorials/accelerated-python/brev/docker-compose.yml
40+
41+
Requirements:
42+
- Docker and Docker Compose must be installed
43+
EOF
44+
exit 1
45+
}
46+
1747
# Check argument
1848
if [ $# -ne 1 ]; then
19-
echo "Error: Tutorial name or Docker Compose file path is required"
20-
echo "Usage: $0 <tutorial-name|docker-compose-file>"
21-
echo "Examples:"
22-
echo " $0 accelerated-python"
23-
echo " $0 tutorials/accelerated-python/brev/docker-compose.yml"
24-
exit 1
49+
echo -e "${RED}Error: Tutorial name or Docker Compose file path is required${NC}"
50+
usage
2551
fi
2652

2753
ARG=$1
@@ -43,7 +69,7 @@ else
4369

4470
# Check if tutorial directory exists
4571
if [ ! -d "${TUTORIAL_PATH}" ]; then
46-
echo "Error: Tutorial directory not found: ${TUTORIAL_PATH}"
72+
echo -e "${RED}Error: Tutorial directory not found: ${TUTORIAL_PATH}${NC}"
4773
exit 1
4874
fi
4975

@@ -52,21 +78,21 @@ fi
5278

5379
# Validate docker-compose file exists
5480
if [ ! -f "${COMPOSE_FILE}" ]; then
55-
echo "Error: Docker Compose file not found: ${COMPOSE_FILE}"
81+
echo -e "${RED}Error: Docker Compose file not found: ${COMPOSE_FILE}${NC}"
5682
exit 1
5783
fi
5884

59-
echo "============================================"
85+
echo "================================================================================"
6086
echo "Testing Docker Compose: ${COMPOSE_FILE}"
61-
echo "============================================"
87+
echo "================================================================================"
6288
echo ""
6389

6490
# Start containers
6591
echo "📦 Starting containers..."
6692
echo ""
6793
if docker compose -f "${COMPOSE_FILE}" up -d; then
6894
echo ""
69-
echo "✅ Containers started successfully"
95+
echo -e "${GREEN}✅ Containers started successfully${NC}"
7096
echo ""
7197

7298
# Wait a moment for containers to initialize
@@ -81,32 +107,32 @@ if docker compose -f "${COMPOSE_FILE}" up -d; then
81107

82108
# Capture and display logs
83109
echo "📋 Container logs:"
84-
echo "--------------------------------------------"
110+
echo "--------------------------------------------------------------------------------"
85111
docker compose -f "${COMPOSE_FILE}" logs
86-
echo "--------------------------------------------"
112+
echo "--------------------------------------------------------------------------------"
87113
echo ""
88114

89115
# Stop containers
90116
echo "🛑 Stopping containers..."
91117
if docker compose -f "${COMPOSE_FILE}" down; then
92-
echo "✅ Containers stopped successfully"
118+
echo -e "${GREEN}✅ Containers stopped successfully${NC}"
93119
echo ""
94120
return_code=0
95121
else
96-
echo "❌ Failed to stop containers"
122+
echo -e "${RED}❌ Failed to stop containers${NC}"
97123
echo ""
98124
return_code=1
99125
fi
100126
else
101127
echo ""
102-
echo "❌ Failed to start containers"
128+
echo -e "${RED}❌ Failed to start containers${NC}"
103129
echo ""
104130

105131
# Try to capture any logs that might be available
106132
echo "📋 Attempting to capture logs from failed startup:"
107-
echo "--------------------------------------------"
133+
echo "--------------------------------------------------------------------------------"
108134
docker compose -f "${COMPOSE_FILE}" logs || true
109-
echo "--------------------------------------------"
135+
echo "--------------------------------------------------------------------------------"
110136
echo ""
111137

112138
# Try to clean up
@@ -117,13 +143,13 @@ else
117143
return_code=1
118144
fi
119145

120-
echo "============================================"
146+
echo ""
147+
echo "================================================================================"
121148
if [ ${return_code} -eq 0 ]; then
122-
echo "✅ TEST PASSED: ${COMPOSE_FILE}"
149+
echo -e "${GREEN}✅ TEST PASSED: ${COMPOSE_FILE}${NC}"
123150
else
124-
echo "❌ TEST FAILED: ${COMPOSE_FILE}"
151+
echo -e "${RED}❌ TEST FAILED: ${COMPOSE_FILE}${NC}"
125152
fi
126-
echo "============================================"
127-
echo ""
153+
echo "================================================================================"
128154

129155
exit ${return_code}

0 commit comments

Comments
 (0)