|
| 1 | +# Copyright IBM Corp. All Rights Reserved. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | +# |
| 5 | +name: CI |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [ "**" ] |
| 10 | + pull_request: |
| 11 | + branches: [ "**" ] |
| 12 | + |
| 13 | +env: |
| 14 | + DB_DEPLOYMENT: local |
| 15 | + |
| 16 | +jobs: |
| 17 | + |
| 18 | + lint: |
| 19 | + name: Lint and Build |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - uses: actions/setup-go@v5 |
| 24 | + with: |
| 25 | + go-version-file: go.mod |
| 26 | + - run: scripts/install-dev-dependencies.sh |
| 27 | + |
| 28 | + - name: Lint |
| 29 | + run: | |
| 30 | + # Apply automatic formatting. |
| 31 | + gofmt -w . |
| 32 | + goimports -local "github.com/hyperledger/fabric-x-committer" -w . |
| 33 | + # Re make protobufs, overwriting any formatting |
| 34 | + PATH="$HOME/bin:$PATH" make proto |
| 35 | + # Check if original code changed due to formatting. |
| 36 | + git diff --exit-code |
| 37 | + # Fetch main to only show new lint issues. |
| 38 | + git fetch -u origin main:main |
| 39 | + make lint |
| 40 | +
|
| 41 | + - name: Build |
| 42 | + run: make build |
| 43 | + |
| 44 | + unit-test: |
| 45 | + name: Unit Test (non DB) |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + - uses: actions/setup-go@v5 |
| 50 | + with: |
| 51 | + go-version-file: go.mod |
| 52 | + - run: scripts/install-dev-dependencies.sh |
| 53 | + - run: make test-no-db |
| 54 | + |
| 55 | + fuzz-test: |
| 56 | + name: Fuzz Test (non DB) |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + - uses: actions/setup-go@v5 |
| 61 | + with: |
| 62 | + go-version-file: go.mod |
| 63 | + - run: scripts/install-dev-dependencies.sh |
| 64 | + - run: make test-fuzz |
| 65 | + |
| 66 | + db-test: |
| 67 | + name: Requires and Core DB Tests (postgres) |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + - uses: actions/setup-go@v5 |
| 72 | + with: |
| 73 | + go-version-file: go.mod |
| 74 | + - run: scripts/install-dev-dependencies.sh |
| 75 | + - run: scripts/get-and-start-postgres.sh |
| 76 | + - run: make test-requires-db test-core-db |
| 77 | + |
| 78 | + core-db-test: |
| 79 | + name: Core DB Tests (yugabyte) |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v4 |
| 83 | + - uses: actions/setup-go@v5 |
| 84 | + with: |
| 85 | + go-version-file: go.mod |
| 86 | + - run: scripts/install-dev-dependencies.sh |
| 87 | + - run: scripts/get-and-start-yuga.sh |
| 88 | + - run: make test-core-db |
| 89 | + |
| 90 | + integration-test: |
| 91 | + name: Integration Tests (yugabyte) |
| 92 | + runs-on: ubuntu-latest |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v4 |
| 95 | + - uses: actions/setup-go@v5 |
| 96 | + with: |
| 97 | + go-version-file: go.mod |
| 98 | + - run: scripts/install-dev-dependencies.sh |
| 99 | + - run: scripts/get-and-start-yuga.sh |
| 100 | + - run: make test-integration |
| 101 | + |
| 102 | + db-resiliency-test: |
| 103 | + name: Integration DB Resiliency (container) |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + - uses: actions/setup-go@v5 |
| 108 | + with: |
| 109 | + go-version-file: go.mod |
| 110 | + - run: scripts/install-dev-dependencies.sh |
| 111 | + - run: make test-integration-db-resiliency |
| 112 | + |
| 113 | + container-test: |
| 114 | + name: Build and test all-in-one test image (container) |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v4 |
| 118 | + - uses: actions/setup-go@v5 |
| 119 | + with: |
| 120 | + go-version-file: go.mod |
| 121 | + - run: scripts/install-dev-dependencies.sh |
| 122 | + - run: make test-container |
0 commit comments