Skip to content

Commit

Permalink
.github: add testing job
Browse files Browse the repository at this point in the history
Run linters, CodeQL and testing benchmarks for the most common scenarious.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Nov 3, 2023
1 parent 152232a commit 81c041b
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Tests

on:
push:
branches: [ master ]
pull_request:
branches:
- master
types: [opened, synchronize]
paths-ignore:
- '**/*.md'
workflow_dispatch:
inputs:
ref:
description: 'Ref to test Bench, GoNode and SharpNode images [default: latest master; examples: 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]'
required: false
default: ''

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'

- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: cmd

codeql:
name: CodeQL
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

tests:
name: Run tests
runs-on: ubuntu-20.04
strategy:
matrix:
benchmarks: [ 'GoSingle10wrk', 'SharpSingle10wrk', 'MixedFourNodesGoRPC50rate' ]
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0

- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build Bench, GoNode and SharpNode docker images
run: make build

- name: Prepare configurations
run: make prepare

- name: Run benchmark for ${{ matrix.benchmarks }}
run: make start.${{ matrix.benchmarks }}
75 changes: 75 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

# include test files or not, default is true
tests: true

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: tab

# all available settings of specific linters
linters-settings:
exhaustive:
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
# switch
default-signifies-exhaustive: true
govet:
# report about shadowed variables
check-shadowing: false

linters:
enable:
# mandatory linters
- govet
- revive

# some default golangci-lint linters
- errcheck
- gosimple
- godot
- ineffassign
- staticcheck
- typecheck
- unused

# extra linters
# - exhaustive
# - goconst
# - goerr113
# - gomnd
# - nonamedreturns
# - unparam
- bidichk
- bodyclose
- contextcheck
- decorder
- durationcheck
- errorlint
- exportloopref
- gofmt
- misspell
- predeclared
- reassign
- whitespace
- goimports
disable-all: true
fast: false

issues:
include:
- EXC0002 # should have a comment
- EXC0003 # test/Test ... consider calling this
- EXC0004 # govet
- EXC0005 # C-style breaks
exclude-rules:
- linters:
- revive
text: "unused-parameter"

0 comments on commit 81c041b

Please sign in to comment.