|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, develop] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + schedule: |
| 10 | + - cron: "0 3 * * *" |
| 11 | + |
| 12 | +env: |
| 13 | + GO_VERSION: "1.25.x" |
| 14 | + |
| 15 | +jobs: |
| 16 | + ci-unit: |
| 17 | + name: ci-unit |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 45 |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 23 | + |
| 24 | + - name: Set up Go |
| 25 | + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 |
| 26 | + with: |
| 27 | + go-version: ${{ env.GO_VERSION }} |
| 28 | + cache: true |
| 29 | + |
| 30 | + - name: Download dependencies |
| 31 | + run: go mod download |
| 32 | + |
| 33 | + - name: Run unit tests with race and coverage |
| 34 | + run: go test -short -race -coverprofile=unit.coverage.out -covermode=atomic ./pkg/... |
| 35 | + |
| 36 | + - name: Enforce unit coverage >= 70% |
| 37 | + run: | |
| 38 | + COVERAGE=$(go tool cover -func=unit.coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}') |
| 39 | + echo "Unit coverage: ${COVERAGE}%" |
| 40 | + awk "BEGIN {exit !($COVERAGE >= 70)}" || (echo "Coverage below 70%" && exit 1) |
| 41 | +
|
| 42 | + - name: Flaky retry summary |
| 43 | + run: | |
| 44 | + set +e |
| 45 | + OUT=flaky-summary.txt |
| 46 | + echo "Flakiness retry summary" > "$OUT" |
| 47 | + echo "" >> "$OUT" |
| 48 | + PACKAGES=( |
| 49 | + "./pkg/httpclient" |
| 50 | + "./pkg/apiclient" |
| 51 | + "./pkg/hecate/api" |
| 52 | + ) |
| 53 | + FAIL=0 |
| 54 | + for PKG in "${PACKAGES[@]}"; do |
| 55 | + echo "Testing ${PKG} 3x..." | tee -a "$OUT" |
| 56 | + if go test -count=3 -race "${PKG}" >> "$OUT" 2>&1; then |
| 57 | + echo " stable" | tee -a "$OUT" |
| 58 | + else |
| 59 | + echo " flaky_or_failing" | tee -a "$OUT" |
| 60 | + FAIL=1 |
| 61 | + fi |
| 62 | + echo "" >> "$OUT" |
| 63 | + done |
| 64 | + if [ "$FAIL" -ne 0 ]; then |
| 65 | + echo "Flaky retry summary found failures" |
| 66 | + cat "$OUT" |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | +
|
| 70 | + - name: Upload unit artifacts |
| 71 | + if: always() |
| 72 | + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 |
| 73 | + with: |
| 74 | + name: ci-unit-artifacts |
| 75 | + path: | |
| 76 | + unit.coverage.out |
| 77 | + flaky-summary.txt |
| 78 | +
|
| 79 | + ci-integration: |
| 80 | + name: ci-integration |
| 81 | + runs-on: ubuntu-latest |
| 82 | + timeout-minutes: 45 |
| 83 | + services: |
| 84 | + vault: |
| 85 | + image: hashicorp/vault:1.16 |
| 86 | + env: |
| 87 | + VAULT_DEV_ROOT_TOKEN_ID: test-token |
| 88 | + VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 |
| 89 | + ports: |
| 90 | + - 8200:8200 |
| 91 | + options: >- |
| 92 | + --cap-add=IPC_LOCK |
| 93 | + postgres: |
| 94 | + image: postgres:15 |
| 95 | + env: |
| 96 | + POSTGRES_PASSWORD: testpass |
| 97 | + POSTGRES_DB: testdb |
| 98 | + ports: |
| 99 | + - 5432:5432 |
| 100 | + options: >- |
| 101 | + --health-cmd "pg_isready -U postgres" |
| 102 | + --health-interval 10s |
| 103 | + --health-timeout 5s |
| 104 | + --health-retries 10 |
| 105 | + steps: |
| 106 | + - name: Checkout |
| 107 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 108 | + |
| 109 | + - name: Set up Go |
| 110 | + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 |
| 111 | + with: |
| 112 | + go-version: ${{ env.GO_VERSION }} |
| 113 | + cache: true |
| 114 | + |
| 115 | + - name: Download dependencies |
| 116 | + run: go mod download |
| 117 | + |
| 118 | + - name: Wait for Vault |
| 119 | + run: | |
| 120 | + for i in $(seq 1 30); do |
| 121 | + if curl -sf http://127.0.0.1:8200/v1/sys/health >/dev/null; then |
| 122 | + echo "Vault is ready" |
| 123 | + exit 0 |
| 124 | + fi |
| 125 | + sleep 2 |
| 126 | + done |
| 127 | + echo "Vault failed to start" |
| 128 | + exit 1 |
| 129 | +
|
| 130 | + - name: Run integration test suite |
| 131 | + env: |
| 132 | + VAULT_ADDR: http://127.0.0.1:8200 |
| 133 | + VAULT_TOKEN: test-token |
| 134 | + POSTGRES_URL: postgres://postgres:testpass@localhost:5432/testdb?sslmode=disable |
| 135 | + run: | |
| 136 | + go test -v -timeout=15m ./test/integration_test.go ./test/integration_scenarios_test.go |
| 137 | + # Backup integration layer (20% test pyramid allocation for backup workflow) |
| 138 | + go test -v -timeout=15m -run Integration ./pkg/backup/... |
| 139 | + go test -v -timeout=15m -tags=integration ./pkg/vault/... |
| 140 | +
|
| 141 | + ci-e2e-smoke: |
| 142 | + name: ci-e2e-smoke |
| 143 | + runs-on: ubuntu-latest |
| 144 | + timeout-minutes: 20 |
| 145 | + steps: |
| 146 | + - name: Checkout |
| 147 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 148 | + |
| 149 | + - name: Set up Go |
| 150 | + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 |
| 151 | + with: |
| 152 | + go-version: ${{ env.GO_VERSION }} |
| 153 | + cache: true |
| 154 | + |
| 155 | + - name: Download dependencies |
| 156 | + run: go mod download |
| 157 | + |
| 158 | + - name: Run smoke e2e tests |
| 159 | + run: go test -v -tags=e2e_smoke -timeout=10m ./test/e2e/smoke/... |
| 160 | + |
| 161 | + - name: Run backup e2e smoke tests |
| 162 | + run: | |
| 163 | + # Backup e2e layer (10% test pyramid allocation for backup workflow) |
| 164 | + go test -v -tags=e2e_smoke -timeout=10m -run Backup ./test/e2e/smoke/... |
| 165 | +
|
| 166 | + ci-e2e-full: |
| 167 | + name: ci-e2e-full |
| 168 | + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' |
| 169 | + runs-on: ubuntu-latest |
| 170 | + timeout-minutes: 90 |
| 171 | + steps: |
| 172 | + - name: Checkout |
| 173 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 174 | + |
| 175 | + - name: Set up Go |
| 176 | + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 |
| 177 | + with: |
| 178 | + go-version: ${{ env.GO_VERSION }} |
| 179 | + cache: true |
| 180 | + |
| 181 | + - name: Run full e2e tests (guarded) |
| 182 | + env: |
| 183 | + EOS_E2E_FULL_APPROVED: "true" |
| 184 | + run: go test -v -tags=e2e_full -timeout=60m ./test/e2e/full/... |
0 commit comments