Skip to content

[pull] master from asyncapi:master #130

[pull] master from asyncapi:master

[pull] master from asyncapi:master #130

# This action is centrally managed in https://github.com/asyncapi/.github/
# 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
# It does magic only if there is go.mod file in the root of the project
name: PR testing - if Go project
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
jobs:
lint-go-pr:
name: Lint Go PR
runs-on: ubuntu-latest
steps:
- if: >
!github.event.pull_request.draft && !(
(github.actor == 'asyncapi-bot' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'asyncapi-bot-eve' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'allcontributors[bot]' &&
startsWith(github.event.pull_request.title, 'docs: add')
)
)
id: should_run
name: Should Run
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
shell: bash
- if: steps.should_run.outputs.shouldrun == 'true'
name: Checkout repository
uses: actions/checkout@v3
- if: steps.should_run.outputs.shouldrun == 'true'
name: Check if Go project and has go.mod
id: gomod
run: test -e ./go.mod && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
shell: bash
- if: steps.gomod.outputs.exists == 'true'
name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # using 4.0.0 https://github.com/actions/setup-go/releases/tag/v4.0.0
with:
go-version: 1.18
- if: steps.gomod.outputs.exists == 'true'
name: golangci-lint
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # using v3.4.0 https://github.com/golangci/golangci-lint-action/releases/tag/v3.4.0
# golangci-lint version extracted from go.mod. `latest` if missing.
with:
skip-go-installation: true # we wanna control the version of Go in use
test-go-pr:
name: Test Go PR - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner.
# See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- if: >
!github.event.pull_request.draft && !(
(github.actor == 'asyncapi-bot' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'asyncapi-bot-eve' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'allcontributors[bot]' &&
startsWith(github.event.pull_request.title, 'docs: add')
)
)
id: should_run
name: Should Run
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
shell: bash
- if: steps.should_run.outputs.shouldrun == 'true'
name: Checkout repository
uses: actions/checkout@v3
- if: steps.should_run.outputs.shouldrun == 'true'
name: Check if Go project and has go.mod
id: gomod
run: test -e ./go.mod && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
shell: bash
- if: steps.gomod.outputs.exists == 'true'
name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # using 4.0.0 https://github.com/actions/setup-go/releases/tag/v4.0.0
with:
go-version: 1.18
- if: steps.gomod.outputs.exists == 'true'
name: Build
run: go build -v ./...
- if: steps.gomod.outputs.exists == 'true'
name: Test
run: go test -v ./...