|
| 1 | +#This action is centrally managed in https://github.com/asyncapi/.github/ |
| 2 | +#Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo |
| 3 | +#It does magic only if there is go.mod file in the root of the project |
| 4 | +name: PR testing - if Go project |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + types: [opened, reopened, synchronize, ready_for_review] |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + if: github.event.pull_request.draft == false |
| 13 | + name: lint |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v2 |
| 18 | + - name: Check if Go project and has go.mod |
| 19 | + id: gomod |
| 20 | + run: test -e ./go.mod && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" |
| 21 | + shell: bash |
| 22 | + - if: steps.gomod.outputs.exists == 'true' |
| 23 | + name: Setup Go |
| 24 | + |
| 25 | + with: |
| 26 | + go-version: 1.16 |
| 27 | + - if: steps.gomod.outputs.exists == 'true' |
| 28 | + name: golangci-lint |
| 29 | + uses: golangci/golangci-lint-action@v2 # golangci-lint version extracted from go.mod. `latest` if missing. |
| 30 | + with: |
| 31 | + skip-go-installation: true # we wanna control the version of Go in use |
| 32 | + |
| 33 | + test: |
| 34 | + if: github.event.pull_request.draft == false |
| 35 | + name: ${{ matrix.os }} |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + strategy: |
| 38 | + matrix: |
| 39 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 40 | + steps: |
| 41 | + - name: Checkout repository |
| 42 | + uses: actions/checkout@v2 |
| 43 | + - name: Check if Go project and has go.mod |
| 44 | + id: gomod |
| 45 | + run: test -e ./go.mod && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" |
| 46 | + shell: bash |
| 47 | + - if: steps.gomod.outputs.exists == 'true' |
| 48 | + name: Setup Go |
| 49 | + |
| 50 | + with: |
| 51 | + go-version: 1.16 |
| 52 | + - if: steps.gomod.outputs.exists == 'true' |
| 53 | + name: Build |
| 54 | + run: go build -v ./... |
| 55 | + - if: steps.gomod.outputs.exists == 'true' |
| 56 | + name: Test |
| 57 | + run: go test -v ./... |
| 58 | + |
0 commit comments