Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Adding a way to start an example in the browser. #21

Adding a way to start an example in the browser.

Adding a way to start an example in the browser. #21

Workflow file for this run

# 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: Go CI
on:
push:
jobs:
build:
name: Go CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- name: Set up Go
uses: actions/setup-go@v3.4.0
with:
go-version: 1.21.2
cache: true
cache-dependency-path: go.sum
- name: Install dependencies
run: |
sudo apt install libc6-dev libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev libasound2-dev pkg-config
# Check if running "go mod tidy" changes anything. If so, the commit is dirty and needs fixed.
- name: Tidy Check
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: Build
run: go build -v ./...
- name: Vet
run: go vet ./...
- name: Test
run: |
go test -v -short ./... -coverprofile coverage.out
go tool cover -html=coverage.out -o coverage.html
# save to artifact
- name: Upload Coverage
uses: actions/upload-artifact@v3.1.1
with:
name: GolangCoverage
path: coverage.html
retention-days: 21
# https://github.com/lluuiissoo/go-testcoverage
- name: Check Coverage Threshold
env:
COVERAGE_THRESHOLD_PERCENT: 1
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $COVERAGE_THRESHOLD_PERCENT %"
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
echo "COVERAGE=$totalCoverage" >> $GITHUB_ENV
echo ${{github.ref}}
if (( $(echo "$totalCoverage $COVERAGE_THRESHOLD_PERCENT" | awk '{print ($1 >= $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
# https://eremeev.ca/posts/golang-test-coverage-github-action/
# https://dev.to/thejaredwilcurt/coverage-badge-with-github-actions-finally-59fa
- if: ${{ github.ref == 'refs/heads/main' }}
name: Create the Badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 0a036dc69ea9afb4202e2d262fec1e1d
filename: GaryBrownEEngr_scratch_main.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: green
namedLogo: jest