|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + go-version: ["1.26"] |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v6 |
| 24 | + with: |
| 25 | + persist-credentials: false |
| 26 | + |
| 27 | + - uses: actions/setup-go@v6 |
| 28 | + with: |
| 29 | + go-version: ${{ matrix.go-version }} |
| 30 | + |
| 31 | + - name: Run tests |
| 32 | + run: go test ./... -count=1 -race |
| 33 | + |
| 34 | + - name: Test integrations (gormguard) |
| 35 | + run: cd integrations/gormguard && go test ./... -count=1 -race |
| 36 | + |
| 37 | + - name: Test integrations (sqlxguard) |
| 38 | + run: cd integrations/sqlxguard && go test ./... -count=1 -race |
| 39 | + |
| 40 | + - name: Test integrations (pgxguard) |
| 41 | + run: cd integrations/pgxguard && go test ./... -count=1 -race |
| 42 | + |
| 43 | + - name: Test integrations (bunguard) |
| 44 | + run: cd integrations/bunguard && go test ./... -count=1 -race |
| 45 | + |
| 46 | + - name: Test integrations (xormguard) |
| 47 | + run: cd integrations/xormguard && go test ./... -count=1 -race |
| 48 | + |
| 49 | + - name: Test integrations (entguard) |
| 50 | + run: cd integrations/entguard && go test ./... -count=1 -race |
| 51 | + |
| 52 | + - name: Test parsers (pgparser) |
| 53 | + run: cd parsers/pgparser && go test ./... -count=1 -race |
| 54 | + |
| 55 | + - name: Test parsers (mysqlparser) |
| 56 | + run: cd parsers/mysqlparser && go test ./... -count=1 -race |
| 57 | + |
| 58 | + lint: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v6 |
| 62 | + with: |
| 63 | + persist-credentials: false |
| 64 | + |
| 65 | + - uses: actions/setup-go@v6 |
| 66 | + with: |
| 67 | + go-version: "1.26" |
| 68 | + |
| 69 | + - uses: golangci/golangci-lint-action@v9 |
| 70 | + with: |
| 71 | + version: v2.11 |
| 72 | + args: --timeout=5m |
| 73 | + |
| 74 | + build: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v6 |
| 78 | + with: |
| 79 | + persist-credentials: false |
| 80 | + |
| 81 | + - uses: actions/setup-go@v6 |
| 82 | + with: |
| 83 | + go-version: "1.26" |
| 84 | + |
| 85 | + - name: Build CLI |
| 86 | + run: go build -o bin/sqlguard ./cmd/sqlguard |
| 87 | + |
| 88 | + coverage: |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v6 |
| 92 | + with: |
| 93 | + persist-credentials: false |
| 94 | + |
| 95 | + - uses: actions/setup-go@v6 |
| 96 | + with: |
| 97 | + go-version: "1.26" |
| 98 | + |
| 99 | + # `make coverage` runs every module and merges into a single coverage.out |
| 100 | + # (root go test does not reach the satellite modules). |
| 101 | + - name: Generate merged coverage |
| 102 | + run: make coverage |
| 103 | + |
| 104 | + - name: Upload to Codecov |
| 105 | + uses: codecov/codecov-action@v5 |
| 106 | + with: |
| 107 | + files: ./coverage.out |
| 108 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 109 | + fail_ci_if_error: false |
0 commit comments