Skip to content

Commit

Permalink
Feat: Run unit tests in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Anoop Gopalakrishnan <[email protected]>
  • Loading branch information
anoop2811 committed Jan 18, 2024
1 parent 96ae866 commit 1829fe7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version-file: go.mod
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: |
docker build -t docker.io/anoop2811/fern-reporter:${{ github.sha }} .
- name: Run Trivy vulnerability scanner for vela core
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'docker.io/anoop2811/fern-reporter:${{ github.sha }}'
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Unit-Test

on:
push:
branches:
- main
workflow_dispatch: { }
pull_request:
branches:
- main

permissions:
contents: read

jobs:

detect-noop:
permissions:
actions: write # for fkirc/skip-duplicate-actions to skip or stop workflow runs
runs-on: ubuntu-22.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
- name: Detect No-op Changes
id: noop
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
continue-on-error: true

unit-tests:
runs-on: ubuntu-22.04
needs: detect-noop
permissions:
actions: write
if: needs.detect-noop.outputs.noop != 'true'

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

- name: Check out code
uses: actions/checkout@v3

- name: Install ginkgo
run: |
go install github.com/onsi/ginkgo/v2/ginkgo
- name: Run Make test
run: make test

- name: Update coverage report
uses: ncruces/go-coverage-report@v0
with:
report: true
chart: true
amend: true
if: |
github.event_name == 'push'
continue-on-error: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cross-compile:
# Testing
test:
@echo "Testing..."
@go test ./...
@ginkgo -r

docker-build-local: cross-compile
@echo "Building Local Docker image..."
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/Guidewire/fern-reporter/badge)](https://securityscorecards.dev/viewer/?uri=github.com/Guidewire/fern-reporter)
[![Go Coverage](https://github.com/Guidewire/fern-reporter/wiki/coverage.svg)](https://raw.githack.com/wiki/Guidewire/fern-reporter/coverage.html)

![Fern](https://github.com/guidewire/fern-reporter/raw/main/docs/images/logo-no-background.png)

Expand Down

0 comments on commit 1829fe7

Please sign in to comment.