Skip to content

Commit

Permalink
Merge pull request #50 from Haraj-backend/chore/use-coveralls
Browse files Browse the repository at this point in the history
Chore: Use Coveralls
  • Loading branch information
riandyrn authored Jul 17, 2023
2 parents 6b9db1a + 776d27b commit d56678a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 167 deletions.
56 changes: 3 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,8 @@ on:
- 'docs/**'

jobs:
preparation:
name: Determine Changes
runs-on: ubuntu-latest
outputs:
exec-tests: ${{ (steps.changes.outputs.exec-tests == 'true') }}
steps:
- name: Checkout Current Commit
uses: actions/checkout@v3

- name: Determine Changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
exec-tests:
- ".github/workflows/**"
- "internal/**"
- "build/**"
- "cmd/**"
- "deploy/**"
- "go.mod"
- "go.sum"
- "Makefile"
build-all:
name: Test Build All Container Images
needs: preparation
if: needs.preparation.outputs.exec-tests == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Current Commit
uses: actions/checkout@v3

- name: Run Build All
run: make test-build-all

- name: Notify To Slack If Failed
uses: lazy-actions/[email protected]
if: failure()
with:
type: ${{ job.status }}
job_name: "*[hex-monscape]* ${{ github.job }}"
mention: "here"
mention_if: "failure"
channel: "#solutions-team-ci-cd"
icon_emoji: ":haraaj:"
username: "ci/cd-reporter"
url: ${{ secrets.SOLUTIONS_TEAM_SLACK_WEBHOOK }}
commit: true
token: ${{ secrets.GITHUB_TOKEN }}

run-tests:
name: Run Automated Tests
needs: preparation
if: needs.preparation.outputs.exec-tests == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -72,6 +19,9 @@ jobs:
- name: Run Automated Tests
run: make test

- name: Test Build All Container Images
run: make test-build-all

- name: Notify To Slack If Failed
uses: lazy-actions/[email protected]
if: failure()
Expand Down
30 changes: 5 additions & 25 deletions .github/workflows/coverage-badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,20 @@ on:
- master

jobs:
gen-badge:
name: Generate Coverage Badge
update-badge:
name: Update Coverage Badge
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Current Commit
uses: actions/checkout@v3

- name: Generate Coverage Report
run: make test

- name: Install Go
uses: actions/[email protected]

- name: Install gobadge
run: go install github.com/AlexBeauchemin/gobadge@latest

- name: Generate Coverage Badge
run: |
# generate coverage badge
gobadge \
-filename=./.output/cov-report/coverage.out \
-green=80 \
-target=README.md \
-text=coverage \
-link=./.output/cov-report/coverage.out
- name: Auto Commit & Push Coverage Badge
uses: stefanzweifel/git-auto-commit-action@v4
id: auto-commit-action
- name: Send Coverage Report to Coveralls
uses: shogo82148/actions-goveralls@v1
with:
commit_message: "chore: update coverage report & apply coverage badge to README.md"
file_pattern: 'README.md .output/cov-report/coverage.out'
path-to-profile: ./.output/cov-report/profile.cov

- name: Notify To Slack If Failed
uses: lazy-actions/[email protected]
Expand Down
3 changes: 1 addition & 2 deletions .output/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*
!.gitignore
!cov-report/
!cov-report/*
!README.md
7 changes: 7 additions & 0 deletions .output/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# About `.output` Directory

This directory is used for storing any output files generated from deployment & test commands specified in the [Makefile](../Makefile). This includes:

- go modules cache when running the `make run*` command
- server build result when running the `make run*` command
- test coverage reports when running the `make test` command
5 changes: 0 additions & 5 deletions .output/cov-report/README.md

This file was deleted.

80 changes: 0 additions & 80 deletions .output/cov-report/coverage.out

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Go Reference](https://pkg.go.dev/badge/github.com/Haraj-backend/hex-monscape.svg)](https://pkg.go.dev/github.com/Haraj-backend/hex-monscape)
[![Go Report Card](https://goreportcard.com/badge/github.com/Haraj-backend/hex-monscape)](https://goreportcard.com/report/github.com/Haraj-backend/hex-monscape)
[![coverage](https://img.shields.io/badge/coverage-82.2%25-brightgreen)](./.output/cov-report/coverage.out)
[![Coverage Status](https://coveralls.io/repos/github/Haraj-backend/hex-monscape/badge.svg?branch=master)](https://coveralls.io/github/Haraj-backend/hex-monscape?branch=master)

`Hex-Monscape` is a simple turn-based game created for Haraj Solutions Team onboarding process.

Expand Down
2 changes: 1 addition & 1 deletion build/package/tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RUN mkdir -p .cov-report

COPY ./internal ./internal

CMD go test ./... -covermode=count -coverprofile=./.cov-report/coverage.out fmt && go tool cover -func=./.cov-report/coverage.out -o=./.cov-report/coverage.out
CMD go test -v -coverprofile=./.cov-report/profile.cov ./...

0 comments on commit d56678a

Please sign in to comment.