|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master, develop, claude/** ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test on Crystal ${{ matrix.crystal }} - ${{ matrix.os }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest] |
| 18 | + crystal: |
| 19 | + - 1.10.1 |
| 20 | + - 1.9.2 |
| 21 | + - 1.14.0 |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Install Crystal |
| 28 | + uses: crystal-lang/install-crystal@v1 |
| 29 | + with: |
| 30 | + crystal: ${{ matrix.crystal }} |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: shards install |
| 34 | + |
| 35 | + - name: Check formatting |
| 36 | + run: crystal tool format --check |
| 37 | + continue-on-error: true |
| 38 | + |
| 39 | + - name: Run tests |
| 40 | + run: crystal spec --error-trace |
| 41 | + |
| 42 | + - name: Build project |
| 43 | + run: crystal build --no-codegen src/oak.cr |
| 44 | + |
| 45 | + benchmark: |
| 46 | + name: Benchmark Performance |
| 47 | + runs-on: ubuntu-latest |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Install Crystal |
| 54 | + uses: crystal-lang/install-crystal@v1 |
| 55 | + with: |
| 56 | + crystal: 1.14.0 |
| 57 | + |
| 58 | + - name: Install dependencies |
| 59 | + run: shards install |
| 60 | + |
| 61 | + - name: Build benchmark (release mode) |
| 62 | + run: crystal build --release benchmark -o benchmark_binary |
| 63 | + continue-on-error: true |
| 64 | + |
| 65 | + - name: Run benchmark validation |
| 66 | + run: | |
| 67 | + if [ -f benchmark_binary ]; then |
| 68 | + echo "Benchmark binary built successfully" |
| 69 | + # Quick smoke test (don't run full benchmark in CI) |
| 70 | + echo "Benchmark is ready to run" |
| 71 | + else |
| 72 | + echo "Benchmark build skipped or failed" |
| 73 | + fi |
| 74 | + continue-on-error: true |
| 75 | + |
| 76 | + lint: |
| 77 | + name: Code Quality |
| 78 | + runs-on: ubuntu-latest |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout code |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Install Crystal |
| 85 | + uses: crystal-lang/install-crystal@v1 |
| 86 | + with: |
| 87 | + crystal: 1.14.0 |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + run: shards install |
| 91 | + |
| 92 | + - name: Run Ameba (linter) |
| 93 | + run: | |
| 94 | + if shards info ameba >/dev/null 2>&1; then |
| 95 | + crystal run lib/ameba/src/cli.cr -- --all |
| 96 | + else |
| 97 | + echo "Ameba not installed, skipping lint" |
| 98 | + fi |
| 99 | + continue-on-error: true |
| 100 | + |
| 101 | + coverage: |
| 102 | + name: Code Coverage |
| 103 | + runs-on: ubuntu-latest |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout code |
| 107 | + uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - name: Install Crystal |
| 110 | + uses: crystal-lang/install-crystal@v1 |
| 111 | + with: |
| 112 | + crystal: 1.14.0 |
| 113 | + |
| 114 | + - name: Install dependencies |
| 115 | + run: shards install |
| 116 | + |
| 117 | + - name: Generate coverage report |
| 118 | + run: | |
| 119 | + echo "Running tests with coverage..." |
| 120 | + crystal spec --error-trace |
| 121 | + echo "Coverage report would be generated here" |
| 122 | + continue-on-error: true |
| 123 | + |
| 124 | + docs: |
| 125 | + name: Documentation Build |
| 126 | + runs-on: ubuntu-latest |
| 127 | + |
| 128 | + steps: |
| 129 | + - name: Checkout code |
| 130 | + uses: actions/checkout@v4 |
| 131 | + |
| 132 | + - name: Install Crystal |
| 133 | + uses: crystal-lang/install-crystal@v1 |
| 134 | + with: |
| 135 | + crystal: 1.14.0 |
| 136 | + |
| 137 | + - name: Generate documentation |
| 138 | + run: crystal docs |
| 139 | + |
| 140 | + - name: Upload documentation |
| 141 | + uses: actions/upload-artifact@v4 |
| 142 | + with: |
| 143 | + name: documentation |
| 144 | + path: docs/ |
| 145 | + retention-days: 7 |
| 146 | + |
| 147 | + status: |
| 148 | + name: CI Status |
| 149 | + runs-on: ubuntu-latest |
| 150 | + needs: [test, benchmark, lint] |
| 151 | + if: always() |
| 152 | + |
| 153 | + steps: |
| 154 | + - name: Check CI Results |
| 155 | + run: | |
| 156 | + echo "Test Status: ${{ needs.test.result }}" |
| 157 | + echo "Benchmark Status: ${{ needs.benchmark.result }}" |
| 158 | + echo "Lint Status: ${{ needs.lint.result }}" |
| 159 | +
|
| 160 | + if [ "${{ needs.test.result }}" != "success" ]; then |
| 161 | + echo "❌ Tests failed!" |
| 162 | + exit 1 |
| 163 | + fi |
| 164 | +
|
| 165 | + echo "✅ All critical checks passed!" |
0 commit comments