Skip to content

Workflow file for this run

name: This workflow will build a golang project on push
on:
push:
branches:
- issue*
- tests*
- optimization-tests*
env:
GO111MODULE: "on"
jobs:
build:
runs-on: ubuntu-latest
if: ${{ !contains(github.ref, 'issue') && !contains(github.ref, 'tests') }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21'
- name: Check out code
uses: actions/checkout@v2
- name: Extract branch name
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Build
run: go build -v ./...
- name: Unit tests
run: go test -v ./...
issue:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'issue') }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21'
- uses: actions/checkout@v3
- name: Extract branch name
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Env
run: env
- name: Build
run: go build -v ./...
working-directory: ${{ env.BRANCH }}
- name: Linters
uses: golangci/golangci-lint-action@v2
with:
version: 'v1.41.1'
working-directory: ${{ env.BRANCH }}
tests:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'tests') }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.21'
- name: Check out code
uses: actions/checkout@v2
- name: Extract branch name
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Env
run: env
- name: Build
run: go build -v ./...
working-directory: ${{ env.BRANCH }}
- name: Unit tests
run: go test -v -count=1 -race -timeout=1m ./...
working-directory: ${{ env.BRANCH }}
- name: Optimization tests
run: go test -v -count=1 -timeout=1m -tags bench ./...
if: contains('optimization-tests', env.BRANCH)
working-directory: ${{ env.BRANCH }}
- name: Bash tests
shell: bash
run: ./test.sh
if: contains('tests-sh', env.BRANCH)
working-directory: ${{ env.BRANCH }}