Skip to content

Commit ffb0725

Browse files
author
Thomas ISAAC
authored
Merge pull request #1 from upfluence/ti-initale-version
v1
2 parents 8795683 + b20f7c7 commit ffb0725

File tree

5 files changed

+147
-2
lines changed

5 files changed

+147
-2
lines changed

.rubocop.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Style/Documentation:
2+
Enabled: false
3+
4+
Style/MultilineBlockChain:
5+
Enabled: false
6+
7+
Metrics/BlockLength:
8+
Enabled: false
9+
10+
Metrics/MethodLength:
11+
Max: 20
12+
13+
Metrics/ClassLength:
14+
Max: 1000
15+
16+
Style/FrozenStringLiteralComment:
17+
Enabled: false
18+
19+
Style/RaiseArgs:
20+
EnforcedStyle: compact
21+
22+
Layout/HashAlignment:
23+
EnforcedHashRocketStyle: table
24+
25+
Layout/LineLength:
26+
Max: 80
27+
28+
AllCops:
29+
NewCops: enable
30+
Exclude:
31+
- Gemfile.lock
32+
- db/schema.rb

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ruby:2.6-alpine
2+
3+
ENV REVIEWDOG_VERSION v0.10.0
4+
5+
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
6+
RUN apk add --update --no-cache build-base git
7+
RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ $REVIEWDOG_VERSION
8+
9+
COPY .rubocop.yml /.rubocop.yml
10+
COPY entrypoint.sh /entrypoint.sh
11+
12+
ENTRYPOINT ["/entrypoint.sh"]

README.md

+54-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,54 @@
1-
# action-rubocop
2-
Github action for ruby project
1+
2+
# GitHub Action: Run linter onto upfluence ruby project
3+
4+
## Release new version
5+
After pull request was approved and merged into master
6+
If code can work with old configuration, use same tag as before
7+
If your code include breaking change change label and inform all upfuence team about your changes.
8+
9+
10+
## Add this acton to your ruby project
11+
run command into your project directory
12+
```bash
13+
mkdir -p .github/workflows
14+
```
15+
Create file lint.yml
16+
```yml
17+
name: reviewdog
18+
on: [pull_request]
19+
20+
jobs:
21+
rubocop:
22+
name: runner / rubocop
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Check out code
26+
uses: actions/checkout@v1
27+
- name: rubocop
28+
uses: upfluence/action-rubocop@v1
29+
with:
30+
github_token: ${{ secrets.github_token }}
31+
```
32+
If you need specific rubocop_extensions, you have to add key rubocop_extensions . By default rubocop_extensions value is 'rubocop-performance:1.5.1 rubocop-minitest'
33+
#### For example:
34+
```yml
35+
name: reviewdog
36+
on: [pull_request]
37+
38+
jobs:
39+
rubocop:
40+
name: runner / rubocop
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Check out code
44+
uses: actions/checkout@v1
45+
- name: rubocop
46+
uses: upfluence/action-rubocop@v1
47+
with:
48+
rubocop_extensions: rubocop-rails
49+
github_token: ${{ secrets.github_token }}
50+
51+
```
52+
53+
## Overriding .rubocop.yml
54+
If you need to override .rubocop.yml provide by this tool, you can create .rubocop.yml into your repository and it will be use by rubocop

action.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Run rubocop linter with reviewdog'
2+
description: 'Run rubocop as github action'
3+
author: 'thomas isaac (upfluence)'
4+
inputs:
5+
github_token:
6+
description: 'GITHUB_TOKEN.'
7+
required: true
8+
rubocop_extensions:
9+
description: 'Rubocop extensions'
10+
default: 'rubocop-performance:1.5.1 rubocop-minitest'
11+
runs:
12+
using: 'docker'
13+
image: 'Dockerfile'
14+
args:
15+
- ${{ inputs.github_token }}
16+
- ${{ inputs.rubocop_extensions }}
17+
branding:
18+
icon: 'check-circle'
19+
color: 'red'

entrypoint.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
get_version_or_null() {
3+
if [ -n "$1" ]; then
4+
echo "-v $1"
5+
fi
6+
}
7+
8+
cd "${GITHUB_WORKSPACE}/" || exit 1
9+
10+
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
11+
export RUBOCOP_VERSION=''
12+
export FILTER_MODE=added
13+
export FAILED_ON_ERROR=true
14+
export LEVEL=error
15+
export REPORTER=github-pr-review
16+
17+
gem install -N rubocop $(get_version_or_null $RUBOCOP_VERSION)
18+
19+
echo $INPUT_RUBOCOP_EXTENSIONS | xargs gem install -N
20+
21+
#Check if rubocop is present into repository
22+
[ -f .rubocop.yml ] || cp /.rubocop.yml .
23+
24+
rubocop --force-exclusion \
25+
| reviewdog -f=rubocop \
26+
-name="rubocop-linter" \
27+
-reporter="${REPORTER}" \
28+
-filter-mode="${FILTER_MODE}" \
29+
-fail-on-error="${FAILED_ON_ERROR}" \
30+
-level="${LEVEL}"

0 commit comments

Comments
 (0)