Skip to content

Commit f5554d0

Browse files
authored
Merge pull request #22 from FuzzingLabs/ci/worker-validation-and-docker-builds
ci: add worker validation and Docker build checks
2 parents 7319276 + 3e949b2 commit f5554d0

File tree

3 files changed

+209
-1
lines changed

3 files changed

+209
-1
lines changed

.github/pull_request_template.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
## Description
2+
3+
<!-- Provide a brief description of the changes in this PR -->
4+
5+
## Type of Change
6+
7+
<!-- Mark the appropriate option with an 'x' -->
8+
9+
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
10+
- [ ] ✨ New feature (non-breaking change which adds functionality)
11+
- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
12+
- [ ] 📝 Documentation update
13+
- [ ] 🔧 Configuration change
14+
- [ ] ♻️ Refactoring (no functional changes)
15+
- [ ] 🎨 Style/formatting changes
16+
- [ ] ✅ Test additions or updates
17+
18+
## Related Issues
19+
20+
<!-- Link to related issues using #issue_number -->
21+
<!-- Example: Closes #123, Relates to #456 -->
22+
23+
## Changes Made
24+
25+
<!-- List the specific changes made in this PR -->
26+
27+
-
28+
-
29+
-
30+
31+
## Testing
32+
33+
<!-- Describe the tests you ran to verify your changes -->
34+
35+
### Tested Locally
36+
37+
- [ ] All tests pass (`pytest`, `uv build`, etc.)
38+
- [ ] Linting passes (`ruff check`)
39+
- [ ] Code builds successfully
40+
41+
### Worker Changes (if applicable)
42+
43+
- [ ] Docker images build successfully (`docker compose build`)
44+
- [ ] Worker containers start correctly
45+
- [ ] Tested with actual workflow execution
46+
47+
### Documentation
48+
49+
- [ ] Documentation updated (if needed)
50+
- [ ] README updated (if needed)
51+
- [ ] CHANGELOG.md updated (if user-facing changes)
52+
53+
## Pre-Merge Checklist
54+
55+
<!-- Ensure all items are completed before requesting review -->
56+
57+
- [ ] My code follows the project's coding standards
58+
- [ ] I have performed a self-review of my code
59+
- [ ] I have commented my code, particularly in hard-to-understand areas
60+
- [ ] I have made corresponding changes to the documentation
61+
- [ ] My changes generate no new warnings
62+
- [ ] I have added tests that prove my fix is effective or that my feature works
63+
- [ ] New and existing unit tests pass locally with my changes
64+
- [ ] Any dependent changes have been merged and published
65+
66+
### Worker-Specific Checks (if workers/ modified)
67+
68+
- [ ] All worker files properly tracked by git (not gitignored)
69+
- [ ] Worker validation script passes (`.github/scripts/validate-workers.sh`)
70+
- [ ] Docker images build without errors
71+
- [ ] Worker configuration updated in `docker-compose.yml` (if needed)
72+
73+
## Screenshots (if applicable)
74+
75+
<!-- Add screenshots to help explain your changes -->
76+
77+
## Additional Notes
78+
79+
<!-- Any additional information that reviewers should know -->
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
# Worker Validation Script
3+
# Ensures all workers defined in docker-compose.yml exist in the repository
4+
# and are properly tracked by git.
5+
6+
set -e
7+
8+
echo "🔍 Validating worker completeness..."
9+
10+
# Colors for output
11+
RED='\033[0;31m'
12+
GREEN='\033[0;32m'
13+
YELLOW='\033[1;33m'
14+
NC='\033[0m' # No Color
15+
16+
ERRORS=0
17+
WARNINGS=0
18+
19+
# Extract worker service names from docker-compose.yml
20+
echo ""
21+
echo "📋 Checking workers defined in docker-compose.yml..."
22+
WORKERS=$(grep -E "^\s+worker-" docker-compose.yml | grep -v "#" | cut -d: -f1 | tr -d ' ' | sort -u)
23+
24+
if [ -z "$WORKERS" ]; then
25+
echo -e "${RED}❌ No workers found in docker-compose.yml${NC}"
26+
exit 1
27+
fi
28+
29+
echo "Found workers:"
30+
for worker in $WORKERS; do
31+
echo " - $worker"
32+
done
33+
34+
# Check each worker
35+
echo ""
36+
echo "🔎 Validating worker files..."
37+
for worker in $WORKERS; do
38+
WORKER_DIR="workers/${worker#worker-}"
39+
40+
echo ""
41+
echo "Checking $worker ($WORKER_DIR)..."
42+
43+
# Check if directory exists
44+
if [ ! -d "$WORKER_DIR" ]; then
45+
echo -e "${RED} ❌ Directory not found: $WORKER_DIR${NC}"
46+
ERRORS=$((ERRORS + 1))
47+
continue
48+
fi
49+
50+
# Check required files
51+
REQUIRED_FILES=("Dockerfile" "requirements.txt" "worker.py")
52+
for file in "${REQUIRED_FILES[@]}"; do
53+
FILE_PATH="$WORKER_DIR/$file"
54+
55+
if [ ! -f "$FILE_PATH" ]; then
56+
echo -e "${RED} ❌ Missing file: $FILE_PATH${NC}"
57+
ERRORS=$((ERRORS + 1))
58+
else
59+
# Check if file is tracked by git
60+
if ! git ls-files --error-unmatch "$FILE_PATH" &> /dev/null; then
61+
echo -e "${RED} ❌ File not tracked by git: $FILE_PATH${NC}"
62+
echo -e "${YELLOW} Check .gitignore patterns!${NC}"
63+
ERRORS=$((ERRORS + 1))
64+
else
65+
echo -e "${GREEN}$file (tracked)${NC}"
66+
fi
67+
fi
68+
done
69+
done
70+
71+
# Check for any ignored worker files
72+
echo ""
73+
echo "🚫 Checking for gitignored worker files..."
74+
IGNORED_FILES=$(git check-ignore workers/*/* 2>/dev/null || true)
75+
if [ -n "$IGNORED_FILES" ]; then
76+
echo -e "${YELLOW}⚠️ Warning: Some worker files are being ignored:${NC}"
77+
echo "$IGNORED_FILES" | while read -r file; do
78+
echo -e "${YELLOW} - $file${NC}"
79+
done
80+
WARNINGS=$((WARNINGS + 1))
81+
fi
82+
83+
# Summary
84+
echo ""
85+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
86+
if [ $ERRORS -eq 0 ] && [ $WARNINGS -eq 0 ]; then
87+
echo -e "${GREEN}✅ All workers validated successfully!${NC}"
88+
exit 0
89+
elif [ $ERRORS -eq 0 ]; then
90+
echo -e "${YELLOW}⚠️ Validation passed with $WARNINGS warning(s)${NC}"
91+
exit 0
92+
else
93+
echo -e "${RED}❌ Validation failed with $ERRORS error(s) and $WARNINGS warning(s)${NC}"
94+
exit 1
95+
fi

.github/workflows/test.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ on:
77
branches: [ main, master, develop ]
88

99
jobs:
10+
validate-workers:
11+
name: Validate Workers
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Run worker validation
17+
run: |
18+
chmod +x .github/scripts/validate-workers.sh
19+
.github/scripts/validate-workers.sh
20+
21+
build-workers:
22+
name: Build Worker Docker Images
23+
runs-on: ubuntu-latest
24+
# Only run if workers directory is modified
25+
if: |
26+
github.event_name == 'pull_request' &&
27+
contains(github.event.pull_request.changed_files, 'workers/')
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Build worker images
35+
run: |
36+
echo "Building worker Docker images..."
37+
docker compose build worker-python worker-secrets worker-rust worker-android worker-ossfuzz --no-cache
38+
continue-on-error: false
39+
1040
lint:
1141
name: Lint
1242
runs-on: ubuntu-latest
@@ -143,11 +173,15 @@ jobs:
143173
test-summary:
144174
name: Test Summary
145175
runs-on: ubuntu-latest
146-
needs: [lint, unit-tests]
176+
needs: [validate-workers, lint, unit-tests]
147177
if: always()
148178
steps:
149179
- name: Check test results
150180
run: |
181+
if [ "${{ needs.validate-workers.result }}" != "success" ]; then
182+
echo "Worker validation failed"
183+
exit 1
184+
fi
151185
if [ "${{ needs.unit-tests.result }}" != "success" ]; then
152186
echo "Unit tests failed"
153187
exit 1

0 commit comments

Comments
 (0)