diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dde5e126..6c7aaa8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/slatify@v3.0.0 - 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 @@ -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/slatify@v3.0.0 if: failure() diff --git a/.github/workflows/coverage-badge.yml b/.github/workflows/coverage-badge.yml index 1e98b179..d764765b 100644 --- a/.github/workflows/coverage-badge.yml +++ b/.github/workflows/coverage-badge.yml @@ -10,11 +10,9 @@ 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 @@ -22,28 +20,10 @@ jobs: - name: Generate Coverage Report run: make test - - name: Install Go - uses: actions/setup-go@v4.0.1 - - - 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/slatify@v3.0.0 diff --git a/.output/.gitignore b/.output/.gitignore index 03b0a738..e5af87e9 100644 --- a/.output/.gitignore +++ b/.output/.gitignore @@ -1,4 +1,3 @@ * !.gitignore -!cov-report/ -!cov-report/* \ No newline at end of file +!README.md \ No newline at end of file diff --git a/.output/README.md b/.output/README.md new file mode 100644 index 00000000..6f8e4df6 --- /dev/null +++ b/.output/README.md @@ -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 \ No newline at end of file diff --git a/.output/cov-report/README.md b/.output/cov-report/README.md deleted file mode 100644 index 9abad87a..00000000 --- a/.output/cov-report/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Coverage Report - -The [coverage.out](./coverage.out) file was generated by [this command](../../build/package/tests/Dockerfile#L11). It will be automatically updated when [ci.yaml](../../.github/workflows/ci.yml) workflow is triggered. - -The coverage report is one of the requirements for submitting this project to [Awesome Go](https://github.com/avelino/awesome-go). \ No newline at end of file diff --git a/.output/cov-report/coverage.out b/.output/cov-report/coverage.out deleted file mode 100644 index 01b1e49d..00000000 --- a/.output/cov-report/coverage.out +++ /dev/null @@ -1,80 +0,0 @@ -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:24: PartnerAttack 80.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:48: PartnerSurrender 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:60: EnemyAttack 80.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:83: IsEnded 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:90: DecideTurn 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:128: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/battle.go:133: NewBattle 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/game.go:32: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/game.go:40: AdvanceScenario 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/game.go:57: IncBattleWon 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/game.go:62: NewGame 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/monster.go:14: ResetBattleStats 0.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/monster.go:18: IsDead 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/monster.go:24: InflictDamage 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/entity/monster.go:38: max 66.7% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:52: StartBattle 75.0% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:90: GetBattle 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:103: getGameAndBattleInstance 72.7% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:121: DecideTurn 56.2% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:146: Attack 52.4% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:178: Surrender 66.7% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:203: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/service/battle/service.go:208: NewService 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/service/play/service.go:36: GetAvailablePartners 75.0% -github.com/Haraj-backend/hex-monscape/internal/core/service/play/service.go:44: NewGame 69.2% -github.com/Haraj-backend/hex-monscape/internal/core/service/play/service.go:71: GetGame 83.3% -github.com/Haraj-backend/hex-monscape/internal/core/service/play/service.go:88: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/core/service/play/service.go:93: NewService 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/model.go:14: toDDBKey 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/model.go:27: toBattleRow 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/model.go:40: toBattle 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/storage.go:19: GetBattle 84.6% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/storage.go:46: SaveBattle 83.3% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/storage.go:67: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/battlestrg/storage.go:72: New 80.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/model.go:14: toDDBKey 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/model.go:28: toGameRow 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/model.go:39: toGame 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/storage.go:19: GetGame 83.3% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/storage.go:44: SaveGame 83.3% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/storage.go:64: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/gamestrg/storage.go:69: New 80.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/model.go:16: toDDBKey 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/model.go:21: toMonsters 87.5% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/storage.go:16: New 80.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/storage.go:33: GetAvailablePartners 71.4% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/storage.go:55: GetPossibleEnemies 66.7% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/storage.go:71: GetPartner 81.8% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/dynamodb/monstrg/storage.go:99: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/battlestrg/storage.go:13: GetBattle 75.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/battlestrg/storage.go:21: SaveBattle 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/battlestrg/storage.go:26: New 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/gamestrg/storage.go:13: GetGame 75.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/gamestrg/storage.go:21: SaveGame 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/gamestrg/storage.go:26: New 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/monstrg/model.go:19: toMonster 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/monstrg/storage.go:17: GetAvailablePartners 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/monstrg/storage.go:25: GetPartner 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/monstrg/storage.go:33: GetPossibleEnemies 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/monstrg/storage.go:45: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/memory/monstrg/storage.go:49: New 86.7% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/battlestrg/model.go:30: ToBattle 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/battlestrg/model.go:65: newBattleRow 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/battlestrg/storage.go:21: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/battlestrg/storage.go:25: New 80.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/battlestrg/storage.go:34: GetBattle 85.7% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/battlestrg/storage.go:46: SaveBattle 83.3% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/gamestrg/model.go:17: ToGame 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/gamestrg/model.go:28: NewGameRow 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/gamestrg/storage.go:21: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/gamestrg/storage.go:25: New 80.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/gamestrg/storage.go:34: GetGame 85.7% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/gamestrg/storage.go:67: SaveGame 83.3% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/monstrg/storage.go:22: Validate 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/monstrg/storage.go:31: New 80.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/monstrg/storage.go:40: GetAvailablePartners 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/monstrg/storage.go:44: GetPossibleEnemies 100.0% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/monstrg/storage.go:48: GetPartner 85.7% -github.com/Haraj-backend/hex-monscape/internal/driven/storage/mysql/monstrg/storage.go:75: getMonsterByRole 72.7% -total: (statements) 82.2% diff --git a/README.md b/README.md index adb76f82..d9fa1512 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build/package/tests/Dockerfile b/build/package/tests/Dockerfile index 5d30116f..2abdeb79 100644 --- a/build/package/tests/Dockerfile +++ b/build/package/tests/Dockerfile @@ -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 \ No newline at end of file +CMD go test -v -coverprofile=./.cov-report/profile.cov ./...