CI #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
create: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
name: Unit Tests | |
runs-on: [ ubuntu-latest ] | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
# Setup Go | |
- name: Setup Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.18.x' # The Go version to download (if necessary) and use. | |
# Run build of the application | |
- name: Run build | |
run: go build ./... | |
# Run gofmt on the code | |
- name: Run gofmt | |
run: gofmt -d | |
# Run testing on the code | |
- name: Run testing | |
run: | | |
go test -v -race -coverprofile=coverage.txt ./... | |
go test -race -json ./... > report.json | |
curl -s https://codecov.io/bash | bash | |
echo "codecov done" | |
# upload report as artifact | |
- name: Archive unit tests report | |
uses: actions/upload-artifact@v2 | |
with: | |
name: report | |
path: report.json | |
# upload coverage as artifact | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v2 | |
with: | |
name: coverage | |
path: coverage.txt | |
lint: | |
strategy: | |
matrix: | |
go-version: [ 1.18.x ] | |
os: [ ubuntu-latest ] | |
name: Lint | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v2 | |
with: | |
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | |
version: v1.45 | |
# Optional: working directory, useful for monorepos | |
# working-directory: somedir | |
# Optional: golangci-lint command line arguments. | |
# args: -v | |
# Optional: show only new issues if it's a pull request. The default value is `false`. | |
only-new-issues: true | |
goreportcard: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- name: Go report card | |
uses: creekorful/[email protected] | |
sonarcloud: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Download unit tests report | |
uses: actions/[email protected] | |
with: | |
name: report | |
- name: Download code coverage results | |
uses: actions/[email protected] | |
with: | |
name: coverage | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
with: | |
args: > | |
-Dproject.settings=./.sonar-project.properties | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |