Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow: Add github test & coverage actions #9

Merged
merged 13 commits into from
Aug 9, 2024
30 changes: 30 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Sonar Report

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Generate Sonar Report
run: go test -coverprofile=coverage.out -json ./... > sonar-report.json

- name: Upload coverage reports to Sonar
uses: sonarsource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Run Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
strategy:
matrix:
go: [ '1.21', '1.22', '1' ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Vet
run: go vet -v ./...

- name: Test
run: go test -v ./...
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
<div align="center">
<img src="./logo/workflow.png" width="500" alt="Workflow Logo">
<img src="./logo/workflow.png" width="500" alt="Workflow Logo">
<div align="center" style="max-width: 750px">
<a style="padding: 0 5px" href="https://goreportcard.com/report/github.com/luno/workflow" >
<img src="https://goreportcard.com/badge/github.com/luno/workflow"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=coverage"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=alert_status"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=bugs"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=reliability_rating"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=security_rating"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=sqale_rating"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=vulnerabilities"/>
</a>
<a style="padding: 0 5px" href="https://sonarcloud.io/summary/new_code?id=luno_workflow" >
<img src="https://sonarcloud.io/api/project_badges/measure?project=luno_workflow&metric=duplicated_lines_density"/>
</a>
</div>
</div>

## Workflow is a Golang workflow framework that encompasses these main features:
- Defining small units of work called "Steps"
- Consumer management and graceful shutdown
Expand Down
11 changes: 11 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.organization = luno
sonar.projectKey = luno_workflow
sonar.projectName = workflow
sonar.links.scm = https://github.com/luno/workflow

sonar.sources = .
sonar.exclusions=**/*_test.go
sonar.go.coverage.reportPaths = coverage.out
sonar.go.tests.reportPaths = sonar-report.json
sonar.tests = .
sonar.test.inclusions = **/*_test.go
Loading