-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
308 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: go-lint | ||
# ~~~~~~~ | ||
# https://github.com/kunitsucom/ilog.go/workflows/go-lint/badge.svg | ||
# ~~~~~~~ | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '.github/dependabot.yml' | ||
- '.github/pull_request_template.md' | ||
- '.github/release.yml' | ||
- 'README.md' | ||
pull_request: | ||
# branches: | ||
# - main | ||
paths-ignore: | ||
- '.github/dependabot.yml' | ||
- '.github/pull_request_template.md' | ||
- '.github/release.yml' | ||
- 'README.md' | ||
workflow_dispatch: | ||
inputs: {} | ||
|
||
# NOTE: 連続で commit & push した時に最新の commit 以外のワークフローをキャンセルする | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
WORKDIR: . | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
go-lint: # NOTE: for Branch protection rule `Status checks that are required.` | ||
runs-on: ubuntu-latest # ref. https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: DEBUG | ||
run: | | ||
cat <<'DEBUG_DOC' | ||
== DEBUG ======================================================= | ||
github.ref: ${{ github.ref }} | ||
github.event_name: ${{ github.event_name }} | ||
-- toJSON(github.event.inputs) --------------------------------- | ||
${{ toJSON(github.event.inputs) }} | ||
-- toJSON(github) ---------------------------------------------- | ||
${{ toJSON(github) }} | ||
================================================================ | ||
DEBUG_DOC | ||
shell: bash | ||
- name: actions/cache for versenv | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/versenv | ||
key: versenv-${{ runner.os }}-${{ hashFiles('**/.versenv.env') }} | ||
restore-keys: | | ||
versenv-${{ runner.os }}- | ||
- name: Add GITHUB_PATH, GITHUB_ENV | ||
run: | | ||
# Update GITHUB_PATH | ||
cat <<GITHUB_PATH >> $GITHUB_PATH | ||
${PWD}/${{ env.WORKDIR }}/.local/bin | ||
${PWD}/.bin | ||
GITHUB_PATH | ||
# Update GITHUB_ENV | ||
grep -Ev '^\s*$|^\s*#' .versenv.env >> $GITHUB_ENV | ||
- name: Setup versenv | ||
run: | | ||
# Setup versenv | ||
direnv allow ${{ env.WORKDIR }} | ||
make versenv | ||
- uses: actions/setup-go@v4 # ref. https://github.com/actions/setup-go#usage | ||
id: setup-go | ||
with: | ||
cache: false | ||
go-version-file: ${{ env.WORKDIR }}/go.mod | ||
- name: Get Golang info | ||
id: golang-info | ||
run: | | ||
echo "GOVERSION=$(go version | cut -d' ' -f3)" >> "$GITHUB_OUTPUT" | ||
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" | ||
- name: actions/cache for go | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
${{ steps.golang-info.outputs.GOCACHE }} | ||
key: ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/*.go') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}-${{ hashFiles('**/go.sum') }}- | ||
${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}- | ||
${{ runner.os }}-go- | ||
- name: Run go mod tidy | ||
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
working-directory: ${{ env.WORKDIR }} | ||
run: | | ||
direnv exec . go mod tidy | ||
git diff --exit-code go.mod go.sum | ||
- uses: golangci/[email protected] # ref. https://github.com/golangci/golangci-lint-action#how-to-use | ||
with: | ||
working-directory: ${{ env.WORKDIR }} | ||
args: --timeout=600s | ||
version: ${{ env.GOLANGCI_LINT_VERSION }} |
Oops, something went wrong.