Skip to content

Add common utils package #11

Add common utils package

Add common utils package #11

Workflow file for this run

name: Code Analysis & Tests
on:
workflow_dispatch:
pull_request:
branches:
- develop
- main
jobs:
analysis:
strategy:
matrix:
os: ["ubuntu-latest"] # "self-hosted", "ubuntu-latest", "macos-latest", "windows-latest"
name: Lint, Test and Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
pr_info: |
💡 `${{ github.event.pull_request.title }}` (#${{ github.event.pull_request.number }})
🔨 Merging commit ${{ github.sha }} on branch [${{ github.head_ref }}](${{ github.event.pull_request.head.repo.html_url }}/tree/${{ github.head_ref }})
📝 Action Status [#${{ github.run_number }}](${{ github.event.pull_request.html_url }}/checks)
🤔 Requested by [${{ github.actor }}](${{ github.event.pull_request.user.html_url }})
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.work"
cache: true # caching and restoring go modules and build outputs.
- run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
- name: Update Pull Request Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: code-analysis
message: |
## 🔍🤔 Running Code Analysis & Testing (${{ env.GOVERSION }})
${{ env.pr_info }}
_Please wait for the result before merging this pull request._
# Q: Why Reviewdog ?
# A: Because golangci-lint action has some issues, not working on self-hosted runners and can't report errors detail on review comments.
# See: https://github.com/reviewdog/reviewdog
# TODO: fix for go workspaces (it's throw error: `no go files to analyze`)
# - name: Lint
# uses: reviewdog/action-golangci-lint@v2
# with: # https://github.com/reviewdog/action-golangci-lint#inputs
# go_version_file: "go.mod"
# workdir: ./
# golangci_lint_flags: "--config=./.golangci.yaml --verbose --new-from-rev=${{ github.event.pull_request.base.sha }}"
# fail_on_error: true
- name: Test
run: go list -f '{{.Dir}}/...' -m | xargs go test
# - name: Build
# run: go build ./...
- name: Update Pull Request Comment for Success
if: ${{ success() }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: code-analysis
recreate: true
message: |
## ✅ Successfully completed Code Analysis & Testing (${{ env.GOVERSION }})
${{ env.pr_info }}
_Merge this pull request if you think it's ready._
- name: Update Pull Request Comment for Failure
if: ${{ failure() }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: code-analysis
recreate: true
message: |
## ❌ Failed to complete Code Analysis & Testing (${{ env.GOVERSION }})
${{ env.pr_info }}
_Please fix the errors before merging this pull request._