Skip to content

Commit

Permalink
Merge pull request #1 from yoheimuta/adjust-template
Browse files Browse the repository at this point in the history
feat: Adjust the template to working with protolint
  • Loading branch information
yoheimuta authored Jul 3, 2022
2 parents eeab37c + b8cd9d2 commit d2a490d
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 108 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
jobs:
test-check:
name: runner / <linter-name> (github-check)
name: runner / protolint (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -15,11 +15,10 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
locale: "US"

test-pr-check:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-check)
name: runner / protolint (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -28,12 +27,11 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
locale: "US"
workdir: ./testdata/subdir/

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-review)
name: runner / protolint (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -42,5 +40,4 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
locale: "US"
reviewdog_flags: -filter-mode=file -fail-on-error
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/action-protolint.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Development

### Release

#### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr)
You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch).
Pushing tag manually by yourself also work.

#### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver)

This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3.
ref: https://help.github.com/en/articles/about-actions#versioning-your-action

### Lint - reviewdog integration

This reviewdog action template itself is integrated with reviewdog to run lints
which is useful for Docker container based actions.

![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png)

Supported linters:

- [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck)
- [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint)
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell)

### Dependencies Update Automation
This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update
reviewdog version.

[![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/yoheimuta/action-protolint/pull/6)
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ ENV REVIEWDOG_VERSION=v0.14.1

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# hadolint ignore=DL3006
RUN apk --no-cache add git

RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}

# TODO: Install a linter and/or change docker image as you need.
RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
120 changes: 36 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# action-template
# reviewdog-action-protolint

<!-- TODO: replace reviewdog/action-template with your repo name -->
[![Test](https://github.com/reviewdog/action-template/workflows/Test/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3ATest)
[![reviewdog](https://github.com/reviewdog/action-template/workflows/reviewdog/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Areviewdog)
[![depup](https://github.com/reviewdog/action-template/workflows/depup/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Adepup)
[![release](https://github.com/reviewdog/action-template/workflows/release/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-template?logo=github&sort=semver)](https://github.com/reviewdog/action-template/releases)
[![Test](https://github.com/yoheimuta/action-protolint/workflows/Test/badge.svg)](https://github.com/yoheimuta/action-protolint/actions?query=workflow%3ATest)
[![reviewdog](https://github.com/yoheimuta/action-protolint/workflows/reviewdog/badge.svg)](https://github.com/yoheimuta/action-protolint/actions?query=workflow%3Areviewdog)
[![depup](https://github.com/yoheimuta/action-protolint/workflows/depup/badge.svg)](https://github.com/yoheimuta/action-protolint/actions?query=workflow%3Adepup)
[![release](https://github.com/yoheimuta/action-protolint/workflows/release/badge.svg)](https://github.com/yoheimuta/action-protolint/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/yoheimuta/action-protolint?logo=github&sort=semver)](https://github.com/yoheimuta/action-protolint/releases)
[![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr)

![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png)
![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png)
This GitHub Action runs [protolint](https://github.com/yoheimuta/protolint) with reviewdog.

This is a template repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation.
Click `Use this template` button to create your reviewdog action :dog:!

If you want to create your own reviewdog action from scratch without using this
template, please check and copy release automation flow.
It's important to manage release workflow and sync reviewdog version for all
reviewdog actions.

This repo contains a sample action to run [misspell](https://github.com/client9/misspell).
## Usage
```yaml
name: reviewdog
on: [pull_request]
jobs:
linter_name:
name: runner / protolint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: yoheimuta/action-protolint@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
reporter: github-pr-review
# Change reporter level if you need.
# GitHub Status Check won't become failure with warning.
level: warning
```
## Input
<!-- TODO: update -->
```yaml
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
default: '.'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
Expand All @@ -52,63 +53,14 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
```
## Usage
<!-- TODO: update. replace `template` with the linter name -->

```yaml
name: reviewdog
on: [pull_request]
jobs:
# TODO: change `linter_name`.
linter_name:
name: runner / <linter-name>
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-template@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
reporter: github-pr-review
# Change reporter level if you need.
# GitHub Status Check won't become failure with warning.
level: warning
### Flags for protolint ###
protolint_version:
description: 'Protolint version to be installed'
default: '0.38.2'
protolint_flags:
description: |
Flags and args to pass to protolint.
The path provided here is relative to the workdir path, provided in the workdir input.
Default is `.`, which makes protolint run on the path provided in the workdir input.
default: '.'
```
## Development
### Release
#### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr)
You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch).
Pushing tag manually by yourself also work.
#### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver)
This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3.
ref: https://help.github.com/en/articles/about-actions#versioning-your-action
### Lint - reviewdog integration
This reviewdog action template itself is integrated with reviewdog to run lints
which is useful for Docker container based actions.
![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png)
Supported linters:
- [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck)
- [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint)
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell)
### Dependencies Update Automation
This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update
reviewdog version.
[![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/reviewdog/action-template/pull/6)
22 changes: 15 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'TODO: Run <linter-name> with reviewdog'
description: 'TODO: 🐶 Run <linter-name> with reviewdog on pull requests to improve code review experience.'
author: 'TODO: <your-name>'
name: 'Run protolint with reviewdog'
description: '🐶 Run protolint with reviewdog on pull requests to improve code review experience.'
author: 'yoheimuta'
inputs:
github_token:
description: 'GITHUB_TOKEN'
Expand Down Expand Up @@ -28,10 +28,18 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
### Flags for protolint ###
protolint_version:
description: 'Protolint version to be installed'
default: '0.38.2'
required: false
protolint_flags:
description: |
Flags and args to pass to protolint.
The path provided here is relative to the workdir path, provided in the workdir input.
Default is `.`, which makes protolint run on the path provided in the workdir input.
default: '.'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
16 changes: 11 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/bin/sh
set -e
set -ex

if [ -n "${GITHUB_WORKSPACE}" ] ; then
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1
fi

# Install protolint
if ! [ -f "protolint" ]; then
echo "🔄 Installing protolint v${INPUT_PROTOLINT_VERSION}..."
wget https://github.com/yoheimuta/protolint/releases/download/v"${INPUT_PROTOLINT_VERSION}"/protolint_"${INPUT_PROTOLINT_VERSION}"_Linux_x86_64.tar.gz
tar zxf protolint_"${INPUT_PROTOLINT_VERSION}"_Linux_x86_64.tar.gz
fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

misspell -locale="${INPUT_LOCALE}" . \
| reviewdog -efm="%f:%l:%c: %m" \
-name="linter-name (misspell)" \
./protolint "${INPUT_PROTOLINT_FLAGS}" \
| reviewdog -efm="[%f:%l:%c] %m" \
-name="linter-name (protolint)" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
Expand Down
18 changes: 18 additions & 0 deletions testdata/subdir/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
import public "other.proto";
option java_package = "com.example.foo";
enum EnumAllowingAlias {
option allow_alias = true;
ENUM_ALLOWING_ALIAS_UNKNOWN = 0;
ENUM_ALLOWING_ALIAS_STARTED = 1;
ENUM_ALLOWING_ALIAS_RUNNING = 2 [(custom_option) = "hello world"];
}
message Outer {
option (my_option).a = true;
message Inner { // Level 2
int64 ival = 1;
}
repeated Inner inner_messages = 2;
EnumAllowingAlias enum_field =3;
map<int32, string> my_map = 4;
}
18 changes: 18 additions & 0 deletions testdata/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
import public "other.proto";
option java_package = "com.example.foo";
enum EnumAllowingAlias {
option allow_alias = true;
ENUM_ALLOWING_ALIAS_UNKNOWN = 0;
STARTED = 1;
RUNNING = 2 [(custom_option) = "hello world"];
}
message Outer {
option (my_option).a = true;
message Inner { // Level 2
int64 ival = 1;
}
repeated Inner inner_message = 2;
EnumAllowingAlias enum_field =3;
map<int32, string> my_map = 4;
}

0 comments on commit d2a490d

Please sign in to comment.