|
| 1 | +# this workflow will run on all pushes. |
| 2 | +on: |
| 3 | + push: |
| 4 | + |
| 5 | +name: "push" |
| 6 | +jobs: |
| 7 | + # run golangci-lint to lint the golang source code. |
| 8 | + # the configuration is at /.golangci.yml. |
| 9 | + linter: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - |
| 13 | + |
| 14 | + - |
| 15 | + name: lint |
| 16 | + |
| 17 | + with: |
| 18 | + version: latest |
| 19 | + # optional: show only new issues if it's a pull request. The default value is `false`. |
| 20 | + # only-new-issues: true |
| 21 | + |
| 22 | + # use nancy to scan for vulnerabilities. |
| 23 | + vulnerability_scanner: |
| 24 | + name: Vulnerability scanner |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - |
| 28 | + |
| 29 | + - |
| 30 | + uses: actions/setup-go@v2 |
| 31 | + # we cannot use nancy-github-action because it is outdated, so it's better to use the latest |
| 32 | + # docker image for the validation |
| 33 | + - |
| 34 | + name: nancy |
| 35 | + run: go list -json -m all | docker run -i sonatypecommunity/nancy:latest |
| 36 | + |
| 37 | + # run golang test suite and collect their coverage. |
| 38 | + test: |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + platform: [ ubuntu-latest, macos-latest, windows-latest ] |
| 42 | + runs-on: ${{ matrix.platform }} |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + |
| 46 | + - name: Get go.mod details |
| 47 | + |
| 48 | + id: go-mod-details |
| 49 | + - name: Install Go |
| 50 | + uses: actions/setup-go@v1 |
| 51 | + with: |
| 52 | + go-version: ${{ steps.go-mod-details.outputs.go_version }} |
| 53 | + - name: Test |
| 54 | + env: |
| 55 | + COVERAGE_PREFIX: coverage-${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}- |
| 56 | + run: go test -v -count=1 |
| 57 | + - name: Send coverage (Bucket 1) |
| 58 | + uses: shogo82148/[email protected] |
| 59 | + with: |
| 60 | + path-to-profile: coverage-${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-bucket0.cov |
| 61 | + flag-name: ${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-bucket1 |
| 62 | + parallel: true |
| 63 | + - name: Send coverage (Bucket 2) |
| 64 | + uses: shogo82148/[email protected] |
| 65 | + with: |
| 66 | + path-to-profile: coverage-${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-bucket1.cov |
| 67 | + flag-name: ${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-bucket2 |
| 68 | + parallel: true |
| 69 | + - name: Send coverage (Exclude Package) |
| 70 | + uses: shogo82148/[email protected] |
| 71 | + with: |
| 72 | + path-to-profile: coverage-${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-exclude-package.cov |
| 73 | + flag-name: ${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-exclude-package |
| 74 | + parallel: true |
| 75 | + - name: Send coverage (Exclude Directory) |
| 76 | + uses: shogo82148/[email protected] |
| 77 | + with: |
| 78 | + path-to-profile: coverage-${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-exclude-directory.cov |
| 79 | + flag-name: ${{ matrix.platform }}-${{ steps.go-mod-details.outputs.go_version }}-exclude-directory |
| 80 | + parallel: true |
| 81 | + |
| 82 | + # notifies that all test jobs are finished. |
| 83 | + finish: |
| 84 | + needs: test |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - uses: shogo82148/[email protected] |
| 88 | + with: |
| 89 | + parallel-finished: true |
| 90 | + |
| 91 | + |
| 92 | + # draft your next release notes as pull requests are merged into "master" |
| 93 | + # the configuration is at /.github/release-drafter.yml. |
| 94 | + update_release_draft: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: release-drafter/release-drafter@v5 |
| 98 | + if: github.ref == 'refs/heads/master' |
| 99 | + with: |
| 100 | + config-name: release-drafter.yml |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments