|
| 1 | +--- |
| 2 | +name: CI |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + lint: |
| 7 | + name: Lint |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v2 |
| 11 | + - name: golangci-lint |
| 12 | + uses: golangci/golangci-lint-action@v2 |
| 13 | + with: |
| 14 | + version: v1.41 |
| 15 | + env: |
| 16 | + VERBOSE: "true" |
| 17 | + |
| 18 | + tidy: |
| 19 | + name: Tidy |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + - uses: actions/setup-go@v2 |
| 24 | + with: |
| 25 | + go-version: 1.15 |
| 26 | + - uses: actions/cache@v2 |
| 27 | + with: |
| 28 | + path: ~/go/pkg/mod |
| 29 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-go- |
| 32 | + - name: Check if mods are tidy |
| 33 | + run: make check-tidy |
| 34 | + |
| 35 | + benchmark: |
| 36 | + name: Benchmarks |
| 37 | + runs-on: ubuntu-latest |
| 38 | + if: github.ref != 'refs/heads/main' |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + - uses: actions/setup-go@v2 |
| 42 | + with: |
| 43 | + go-version: 1.15 |
| 44 | + - uses: actions/cache@v2 |
| 45 | + with: |
| 46 | + path: ~/go/pkg/mod |
| 47 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-go- |
| 50 | + - name: Run benchmarks |
| 51 | + run: make bench | tee output.raw |
| 52 | + - name: Fix benchmark names |
| 53 | + run: >- |
| 54 | + perl -pe 's/^(Benchmark.+?)\/(\S+)(-\d+)(\s+)/\1__\2\4/' output.raw | |
| 55 | + tr '-' '_' | tee output.txt |
| 56 | + - name: Announce benchmark result |
| 57 | + uses: rhysd/github-action-benchmark@v1 |
| 58 | + with: |
| 59 | + tool: "go" |
| 60 | + output-file-path: output.txt |
| 61 | + fail-on-alert: true |
| 62 | + comment-on-alert: true |
| 63 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + auto-push: false |
| 65 | + |
| 66 | + cov: |
| 67 | + name: Coverage |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v2 |
| 71 | + - uses: actions/setup-go@v2 |
| 72 | + with: |
| 73 | + go-version: 1.15 |
| 74 | + - uses: actions/cache@v2 |
| 75 | + with: |
| 76 | + path: ~/go/pkg/mod |
| 77 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 78 | + restore-keys: | |
| 79 | + ${{ runner.os }}-go- |
| 80 | + - name: Publish coverage |
| 81 | + uses: paambaati/codeclimate-action@v2.7.4 |
| 82 | + env: |
| 83 | + VERBOSE: "true" |
| 84 | + GOMAXPROCS: 4 |
| 85 | + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} |
| 86 | + with: |
| 87 | + coverageCommand: make cov |
| 88 | + prefix: github.com/${{ github.repository }} |
| 89 | + coverageLocations: | |
| 90 | + ${{ github.workspace }}/coverage.out:gocov |
| 91 | +
|
| 92 | + test: |
| 93 | + name: Test |
| 94 | + runs-on: ubuntu-latest |
| 95 | + strategy: |
| 96 | + fail-fast: false |
| 97 | + matrix: |
| 98 | + go_version: |
| 99 | + - "1.15" |
| 100 | + - "1.16" |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v2 |
| 103 | + - uses: actions/setup-go@v2 |
| 104 | + with: |
| 105 | + go-version: ${{ matrix.terraform_version }} |
| 106 | + - uses: actions/cache@v2 |
| 107 | + with: |
| 108 | + path: ~/go/pkg/mod |
| 109 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 110 | + restore-keys: | |
| 111 | + ${{ runner.os }}-go- |
| 112 | + - name: Run tests |
| 113 | + run: make test |
| 114 | + env: |
| 115 | + VERBOSE: "true" |
| 116 | + |
| 117 | + benchmark-store: |
| 118 | + name: Store benchmarks |
| 119 | + runs-on: ubuntu-latest |
| 120 | + if: github.ref == 'refs/heads/main' |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@v2 |
| 123 | + - uses: actions/setup-go@v2 |
| 124 | + with: |
| 125 | + go-version: 1.15 |
| 126 | + - uses: actions/cache@v2 |
| 127 | + with: |
| 128 | + path: ~/go/pkg/mod |
| 129 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 130 | + restore-keys: | |
| 131 | + ${{ runner.os }}-go- |
| 132 | + - name: Run benchmarks |
| 133 | + run: make bench | tee output.raw |
| 134 | + - name: Fix benchmark names |
| 135 | + run: >- |
| 136 | + perl -pe 's/^(Benchmark.+?)\/(\S+)(-\d+)(\s+)/\1__\2\4/' output.raw | |
| 137 | + tr '-' '_' | tee output.txt |
| 138 | + - name: Store benchmark result |
| 139 | + uses: rhysd/github-action-benchmark@v1 |
| 140 | + with: |
| 141 | + tool: "go" |
| 142 | + output-file-path: output.txt |
| 143 | + github-token: ${{ secrets.ROMDOBOT_TOKEN }} |
| 144 | + comment-on-alert: true |
| 145 | + auto-push: true |
0 commit comments