Skip to content

Commit 234fdab

Browse files
authored
Merge pull request #2 from maximilien/main
feature: added CI via GH actions
2 parents bf8a6b3 + e67cfe9 commit 234fdab

File tree

8 files changed

+531
-0
lines changed

8 files changed

+531
-0
lines changed

.github/validate-workflows.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# GitHub Actions Workflow Validation Script
4+
# This script validates that the GitHub Actions workflows are properly configured
5+
6+
set -e
7+
8+
echo "🔍 Validating GitHub Actions Workflows..."
9+
10+
# Check if workflow files exist
11+
WORKFLOWS=(
12+
".github/workflows/ci.yml"
13+
".github/workflows/lint.yml"
14+
".github/workflows/build.yml"
15+
".github/workflows/test.yml"
16+
)
17+
18+
for workflow in "${WORKFLOWS[@]}"; do
19+
if [[ -f "$workflow" ]]; then
20+
echo "✅ Found: $workflow"
21+
else
22+
echo "❌ Missing: $workflow"
23+
exit 1
24+
fi
25+
done
26+
27+
# Validate YAML syntax
28+
echo "🔍 Validating YAML syntax..."
29+
for workflow in "${WORKFLOWS[@]}"; do
30+
if command -v yamllint >/dev/null 2>&1; then
31+
yamllint "$workflow" || echo "⚠️ YAML linting issues in $workflow (yamllint not required)"
32+
else
33+
echo "ℹ️ yamllint not installed, skipping YAML validation"
34+
fi
35+
done
36+
37+
# Check workflow triggers
38+
echo "🔍 Checking workflow triggers..."
39+
for workflow in "${WORKFLOWS[@]}"; do
40+
if grep -q "pull_request:" "$workflow"; then
41+
echo "$workflow has PR triggers"
42+
else
43+
echo "⚠️ $workflow missing PR triggers"
44+
fi
45+
46+
if grep -q "push:" "$workflow"; then
47+
echo "$workflow has push triggers"
48+
else
49+
echo "⚠️ $workflow missing push triggers"
50+
fi
51+
done
52+
53+
# Check for required steps
54+
echo "🔍 Checking for required steps..."
55+
for workflow in "${WORKFLOWS[@]}"; do
56+
if grep -q "actions/checkout@v4" "$workflow"; then
57+
echo "$workflow uses checkout@v4"
58+
else
59+
echo "⚠️ $workflow should use actions/checkout@v4"
60+
fi
61+
62+
if grep -q "actions/setup-go@v4" "$workflow"; then
63+
echo "$workflow uses setup-go@v4"
64+
else
65+
echo "⚠️ $workflow should use actions/setup-go@v4"
66+
fi
67+
68+
if grep -q "actions/upload-artifact@v4" "$workflow"; then
69+
echo "$workflow uses upload-artifact@v4"
70+
elif grep -q "actions/upload-artifact@v3" "$workflow"; then
71+
echo "$workflow uses deprecated upload-artifact@v3 (should be v4)"
72+
else
73+
echo "ℹ️ $workflow doesn't use upload-artifact"
74+
fi
75+
done
76+
77+
echo "🎉 Workflow validation completed!"
78+
echo ""
79+
echo "📋 Summary:"
80+
echo "- All workflow files are present"
81+
echo "- Workflows are configured for PR and push triggers"
82+
echo "- Using latest GitHub Actions versions"
83+
echo ""
84+
echo "🚀 Ready for CI/CD!"

.github/workflows/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for the Maestro CLI project.
4+
5+
## Workflows
6+
7+
### 1. `ci.yml` - Main CI Pipeline
8+
- **Triggers**: Push to main/develop, PRs to main/develop, manual dispatch
9+
- **Jobs**:
10+
- `lint`: Runs code quality checks
11+
- `build`: Builds the maestro CLI binary
12+
- `test`: Runs all tests
13+
- `release-build`: Creates release artifacts for main branch pushes
14+
- **Matrix**: Tests on multiple Go versions and operating systems
15+
16+
### 2. `lint.yml` - Code Quality
17+
- **Triggers**: Push to main/develop, PRs to main/develop, manual dispatch
18+
- **Purpose**: Runs `./tools/lint.sh` for code quality checks
19+
- **Artifacts**: Uploads lint results on failure
20+
21+
### 3. `build.yml` - Build Verification
22+
- **Triggers**: Push to main/develop, PRs to main/develop, manual dispatch
23+
- **Purpose**: Runs `./build.sh` and verifies binary functionality
24+
- **Matrix**: Tests on Go 1.21, 1.22, and 1.23
25+
- **Artifacts**: Uploads build artifacts and logs
26+
27+
### 4. `test.yml` - Test Suite
28+
- **Triggers**: Push to main/develop, PRs to main/develop, manual dispatch
29+
- **Purpose**: Runs `./test.sh` for comprehensive testing
30+
- **Matrix**: Tests on Go 1.21, 1.22, and 1.23
31+
- **Artifacts**: Uploads test results and coverage reports
32+
33+
## Workflow Features
34+
35+
- **Parallel Execution**: Individual workflows can run in parallel
36+
- **Sequential Dependencies**: Main CI workflow runs jobs in sequence (lint → build → test)
37+
- **Matrix Testing**: Tests across multiple Go versions
38+
- **Artifact Upload**: Build artifacts and test results are preserved
39+
- **Cross-Platform**: Release builds for Ubuntu, Windows, and macOS
40+
- **Manual Triggers**: All workflows support manual dispatch
41+
42+
## Status Badges
43+
44+
Add these badges to your README.md:
45+
46+
```markdown
47+
![CI](https://github.com/your-org/maestro-cli/workflows/CI/badge.svg)
48+
![Lint](https://github.com/your-org/maestro-cli/workflows/Lint/badge.svg)
49+
![Build](https://github.com/your-org/maestro-cli/workflows/Build/badge.svg)
50+
![Test](https://github.com/your-org/maestro-cli/workflows/Test/badge.svg)
51+
```
52+
53+
## Local Development
54+
55+
To run the same checks locally:
56+
57+
```bash
58+
# Run all checks
59+
./tools/lint.sh && ./build.sh && ./test.sh
60+
61+
# Run individual checks
62+
./tools/lint.sh # Code quality
63+
./build.sh # Build verification
64+
./test.sh # Test suite
65+
```
66+
67+
## Workflow Configuration
68+
69+
- **Go Version**: Primary testing on Go 1.21, with matrix testing on 1.22 and 1.23
70+
- **Operating Systems**: Ubuntu (primary), Windows and macOS (release builds)
71+
- **Artifact Retention**: 7 days for logs, 30 days for test results, 90 days for releases
72+
- **Cache**: Go module cache is enabled for faster builds

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
name: Build Maestro CLI
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
go-version: ['1.21', '1.22', '1.23']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Go ${{ matrix.go-version }}
24+
uses: actions/setup-go@v4
25+
with:
26+
go-version: ${{ matrix.go-version }}
27+
cache: true
28+
29+
- name: Make scripts executable
30+
run: |
31+
chmod +x ./build.sh
32+
chmod +x ./test.sh
33+
34+
- name: Build maestro CLI
35+
run: ./build.sh
36+
37+
- name: Test binary functionality
38+
run: |
39+
./maestro --version
40+
./maestro --help
41+
./maestro vectordb list --dry-run
42+
43+
- name: Upload build artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: maestro-cli-${{ matrix.go-version }}
47+
path: maestro
48+
retention-days: 30
49+
50+
- name: Upload build logs
51+
if: failure()
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: build-logs-${{ matrix.go-version }}
55+
path: |
56+
*.log
57+
build-*.txt
58+
retention-days: 7

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: '1.21'
23+
cache: true
24+
25+
- name: Make scripts executable
26+
run: |
27+
chmod +x ./tools/lint.sh
28+
chmod +x ./build.sh
29+
chmod +x ./test.sh
30+
31+
- name: Run linting
32+
run: ./tools/lint.sh
33+
34+
build:
35+
name: Build
36+
runs-on: ubuntu-latest
37+
needs: lint
38+
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Go
44+
uses: actions/setup-go@v4
45+
with:
46+
go-version: '1.21'
47+
cache: true
48+
49+
- name: Make scripts executable
50+
run: |
51+
chmod +x ./build.sh
52+
chmod +x ./test.sh
53+
54+
- name: Build maestro CLI
55+
run: ./build.sh
56+
57+
- name: Test binary functionality
58+
run: |
59+
./maestro --version
60+
./maestro --help
61+
./maestro vectordb list --dry-run
62+
63+
test:
64+
name: Test
65+
runs-on: ubuntu-latest
66+
needs: build
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Go
73+
uses: actions/setup-go@v4
74+
with:
75+
go-version: '1.21'
76+
cache: true
77+
78+
- name: Make scripts executable
79+
run: |
80+
chmod +x ./build.sh
81+
chmod +x ./test.sh
82+
83+
- name: Build maestro CLI
84+
run: ./build.sh
85+
86+
- name: Run all tests
87+
run: ./test.sh
88+
89+
- name: Upload test results
90+
if: always()
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: test-results
94+
path: |
95+
test-results/
96+
coverage.out
97+
retention-days: 30
98+
99+
release-build:
100+
name: Release Build
101+
runs-on: ubuntu-latest
102+
needs: [lint, build, test]
103+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
104+
105+
strategy:
106+
matrix:
107+
os: [ubuntu-latest, windows-latest, macos-latest]
108+
109+
steps:
110+
- name: Checkout code
111+
uses: actions/checkout@v4
112+
113+
- name: Set up Go
114+
uses: actions/setup-go@v4
115+
with:
116+
go-version: '1.21'
117+
cache: true
118+
119+
- name: Make scripts executable
120+
run: |
121+
chmod +x ./build.sh
122+
chmod +x ./test.sh
123+
124+
- name: Build maestro CLI
125+
run: ./build.sh
126+
127+
- name: Upload release artifacts
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: maestro-cli-${{ matrix.os }}
131+
path: maestro*
132+
retention-days: 90

.github/workflows/lint.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
name: Code Quality and Linting
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: '1.21'
23+
cache: true
24+
25+
- name: Make scripts executable
26+
run: |
27+
chmod +x ./tools/lint.sh
28+
chmod +x ./build.sh
29+
chmod +x ./test.sh
30+
31+
- name: Run linting
32+
run: ./tools/lint.sh
33+
34+
- name: Upload lint results
35+
if: failure()
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: lint-results
39+
path: |
40+
*.log
41+
lint-*.txt
42+
retention-days: 7

0 commit comments

Comments
 (0)