Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from docker to composite run actions #46

Merged
merged 12 commits into from
Aug 16, 2020
28 changes: 27 additions & 1 deletion .github/workflows/depup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: haya14busa/action-depup@v1
id: depup
with:
file: Dockerfile
file: action.yml
version_name: REVIEWDOG_VERSION
repo: reviewdog/reviewdog

Expand All @@ -31,3 +31,29 @@ jobs:
branch: depup/reviewdog
base: master
labels: "bump:minor"

golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: haya14busa/action-depup@v1
id: depup
with:
file: action.yml
version_name: REVIEWDOG_VERSION
repo: golangci/golangci-lint

- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "chore(deps): update golangci-lint to ${{ steps.depup.outputs.latest }}"
commit-message: "chore(deps): update golangci-lint to ${{ steps.depup.outputs.latest }}"
body: |
Update golangci-lint to [v${{ steps.depup.outputs.latest }}](https://github.com/golangci-lint/golangci/releases/tag/v${{ steps.depup.outputs.latest }})
Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/golangci/golangci-lint/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }})

This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup).
branch: depup/golangci-lint
base: master
labels: "bump:minor"
14 changes: 0 additions & 14 deletions .github/workflows/dockerimage.yml

This file was deleted.

49 changes: 27 additions & 22 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@ jobs:
# different linters and just report one of the errors?

golangci-lint:
name: runner / golangci-lint (pre-build docker image)
name: runner / golangci-lint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint
# uses: ./ # Build with Dockerfile
uses: docker://reviewdog/action-golangci-lint:v1 # Pre-built image
uses: ./
with:
github_token: ${{ secrets.github_token }}
level: warning
golangci_lint_flags: "--config=.github/.golangci.yml ./testdata"

golangci-lint-dockerfile:
name: runner / golangci-lint (Dockerfile)
runs-on: ubuntu-latest
golangci-lint-platform:
name: runner / golangci-lint-platform
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint w/ Dockerfile
uses: ./ # Build with Dockerfile
# uses: docker://reviewdog/action-golangci-lint:v1 # Pre-built image
- uses: actions/checkout@v2
- name: golangci-lint (platform)
uses: ./
with:
golangci_lint_flags: "./testdata"
tool_name: "golangci-lint-dockerfile"
github_token: ${{ secrets.github_token }}
tool_name: golangci-lint-${{ matrix.platform }}
level: warning
golangci_lint_flags: "--config=.github/.golangci.yml ./testdata"

golangci-lint-github-pr-review:
name: runner / golangci-lint (github-pr-review)
Expand All @@ -37,7 +40,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint w/ github-pr-review
uses: ./ # Build with Dockerfile
uses: ./
with:
golangci_lint_flags: "./testdata"
tool_name: "golangci-lint-github-pr-review"
Expand All @@ -50,7 +53,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint w/ github-check
uses: ./ # Build with Dockerfile
uses: ./
with:
golangci_lint_flags: "./testdata"
tool_name: "golangci-lint-github-check"
Expand All @@ -63,7 +66,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: golangci-lint (workdir)
uses: ./ # Build with Dockerfile
uses: ./
with:
workdir: "./testdata"
golangci_lint_flags: ""
Expand All @@ -79,9 +82,11 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint (All-In-One config)
uses: docker://reviewdog/action-golangci-lint:v1
uses: ./
with:
github_token: ${{ secrets.github_token }}
tool_name: "golangci-lint-all-in-one"
level: warning
golangci_lint_flags: "--enable-all --exclude-use-default=false ./testdata"

govet:
Expand All @@ -91,7 +96,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: govet
uses: docker://reviewdog/action-golangci-lint:v1
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E govet ./testdata"
Expand All @@ -104,7 +109,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: staticcheck
uses: docker://reviewdog/action-golangci-lint:v1
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E staticcheck ./testdata"
Expand All @@ -117,7 +122,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golint
uses: docker://reviewdog/action-golangci-lint:v1
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E golint ./testdata"
Expand All @@ -131,7 +136,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: errcheck
uses: docker://reviewdog/action-golangci-lint:v1
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E errcheck ./testdata"
Expand All @@ -145,7 +150,7 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: misspell
uses: docker://reviewdog/action-golangci-lint:v1
uses: ./
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--disable-all -E misspell ./testdata"
Expand Down
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# GitHub Action: Run golangci-lint with reviewdog

[![Docker Image CI](https://github.com/reviewdog/action-golangci-lint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/reviewdog/action-golangci-lint/actions)
[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/reviewdog/action-golangci-lint)](https://hub.docker.com/r/reviewdog/action-golangci-lint)
[![Docker Pulls](https://img.shields.io/docker/pulls/reviewdog/action-golangci-lint)](https://hub.docker.com/r/reviewdog/action-golangci-lint)
[![depup](https://github.com/reviewdog/action-golangci-lint/workflows/depup/badge.svg)](https://github.com/reviewdog/action-golangci-lint/actions?query=workflow%3Adepup)
[![release](https://github.com/reviewdog/action-golangci-lint/workflows/release/badge.svg)](https://github.com/reviewdog/action-golangci-lint/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-golangci-lint?logo=github&sort=semver)](https://github.com/reviewdog/action-golangci-lint/releases)
Expand All @@ -20,7 +17,7 @@ code review experience.

### `github_token`

**Required**. Default is `${{ github.token }}`. If using a pre-built docker image, you must set it explicitly to `github_token: ${{ secrets.github_token }}`.
**Required**. Default is `${{ github.token }}`.

### `golangci_lint_flags`

Expand Down
22 changes: 20 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,26 @@ inputs:
description: 'Working directory relative to the root directory.'
default: '.'
runs:
using: 'docker'
image: 'Dockerfile'
using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/script.sh
shell: bash
env:
# We may want to allow specifing reviewdog and golangci-lint version as
# action's input, but let's start with hard coded latest stable version.
REVIEWDOG_VERSION: v0.10.2
GOLANGCI_LINT_VERSION: v1.30.0
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_GOLANGCI_LINT_FLAGS: ${{ inputs.golangci_lint_flags }}
INPUT_TOOL_NAME: ${{ inputs.tool_name }}
INPUT_LEVEL: ${{ inputs.level }}
INPUT_REPORTER: ${{ inputs.reporter }}
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }}
INPUT_WORKDIR: ${{ inputs.workdir }}
branding:
icon: 'check-circle'
color: 'blue'
15 changes: 0 additions & 15 deletions entrypoint.sh

This file was deleted.

28 changes: 28 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1

TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The install script picks the version to install based on the OS, so an ARM-based or Windows-based runner would get the expected version for their system. Nice!

echo '::endgroup::'

echo '::group:: Installing golangci-lint ... https://github.com/golangci/golangci-lint'
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${GOLANGCI_LINT_VERSION}" 2>&1
echo '::endgroup::'

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

echo '::group:: Running golangci-lint with reviewdog 🐶 ...'
# shellcheck disable=SC2086
golangci-lint run --out-format line-number ${INPUT_GOLANGCI_LINT_FLAGS} \
| reviewdog -f=golangci-lint \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE:-added}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR:-false}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
echo '::endgroup::'
12 changes: 6 additions & 6 deletions testdata/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package testdata

import (
"os"
"fmt"
"os"
)

func Main( ) {
// langauge
func Main() {
// langauge

x := 2
x := 2
x += 1
fmt.Sprintf("%d")

os.Open("main.go")
os.Open("main1.go")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint-github-pr-review] reported by reviewdog 🐶
Error return value of os.Open is not checked (errcheck)

}

func unused(unusedParam int) error {
func unused1(unusedParam int) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golangci-lint-github-pr-review] reported by reviewdog 🐶
unused1 is unused (deadcode)


return nil

Expand Down