Merge pull request #1 from golangci/action-update

Action update
This commit is contained in:
Aleksandr Razumov 2020-04-26 04:51:18 +03:00 committed by GitHub
commit 7a50c22d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 2 deletions

View File

@ -1,4 +1,4 @@
name: Docker Image CI
name: docker image
on: [push]

16
.github/workflows/golangci.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: golangci
on: [pull_request]
jobs:
golangci-lint-dockerfile:
name: lint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint
uses: ./
with:
github_token: ${{ secrets.github_token }}
directory: sample
format: colored-line-number
flags: --issues-exit-code 0

View File

@ -1 +1,5 @@
FROM golangci/golangci-lint:v1.25
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -1,3 +1,5 @@
# golangci-lint-action
Work in progress
Based on [reviewdog action](https://github.com/reviewdog/action-golangci-lint).

View File

@ -6,6 +6,19 @@ inputs:
github_token:
description: 'GITHUB_TOKEN'
required: true
flags:
description: 'GolangCI command line flags'
required: false
directory:
description: 'Working directory'
required: false
default: ''
format:
description: 'Output format of issues'
default: 'github-actions'
required: false
runs:
using: 'docker'
image: 'Dockerfile'

9
entrypoint.sh Normal file → Executable file
View File

@ -1,3 +1,10 @@
#!/bin/bash
golangci-lint run --out-format github-actions
echo 'golangci-lint-action: start'
echo " flags: ${INPUT_FLAGS}"
echo " format: ${INPUT_FORMAT}"
cd "${GITHUB_WORKSPACE}/${INPUT_DIRECTORY}" || exit 1
# shellcheck disable=SC2086
golangci-lint run --out-format ${INPUT_FORMAT} ${INPUT_FLAGS}

14
sample/sample.go Normal file
View File

@ -0,0 +1,14 @@
// Package sample is used as test input for golangci action.
package sample
import (
"crypto/md5"
"encoding/hex"
)
// Hash~
func Hash(data string) string {
h := md5.New()
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}