Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
chrfritsch authored Jan 28, 2020
1 parent ee1c8fa commit b9bf359
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 81 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 / drupal-coder (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
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 / drupal-coder (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -28,11 +27,10 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: error
locale: "US"

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-review)
name: runner / drupal-coder (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -41,4 +39,3 @@ jobs:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
locale: "US"
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
FROM alpine:3.11
FROM composer:1.9.1 AS composer
FROM php:7.4-cli-alpine3.11

ENV REVIEWDOG_VERSION=v0.9.17

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 --from=composer /usr/bin/composer /usr/bin/composer

ENV PATH="${PATH}:/root/.composer/vendor/bin"

# Install phpcs and set the code sniffer path
RUN composer global require drupal/coder && \
phpcs --config-set installed_paths /root/.composer/vendor/drupal/coder/coder_sniffer/

COPY entrypoint.sh /entrypoint.sh

Expand Down
75 changes: 14 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
# action-template

<!-- 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)
# action-drupal-coder

<!-- TODO: replace chrfritsch/action-drupal-coder with your repo name -->
[![Test](https://github.com/chrfritsch/action-drupal-coder/workflows/Test/badge.svg)](https://github.com/chrfritsch/action-drupal-coder/actions?query=workflow%3ATest)
[![reviewdog](https://github.com/chrfritsch/action-drupal-coder/workflows/reviewdog/badge.svg)](https://github.com/chrfritsch/action-drupal-coder/actions?query=workflow%3Areviewdog)
[![depup](https://github.com/chrfritsch/action-drupal-coder/workflows/depup/badge.svg)](https://github.com/chrfritsch/action-drupal-coder/actions?query=workflow%3Adepup)
[![release](https://github.com/chrfritsch/action-drupal-coder/workflows/release/badge.svg)](https://github.com/chrfritsch/action-drupal-coder/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/chrfritsch/action-drupal-coder?logo=github&sort=semver)](https://github.com/chrfritsch/action-drupal-coder/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 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 is a GitHub action that checks your drupal module against the drupal coding styles (Drupal, DrupalPractice) and outputs the warnings and errors using [reviewdog](https://github.com/reviewdog/reviewdog).

This repo contains a sample action to run [misspell](https://github.com/client9/misspell).

## Input

Expand All @@ -29,17 +19,13 @@ inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
reporter:
description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].'
description: 'Reporter of reviewdog command.'
default: 'github-pr-check'
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''

```

## Usage
Expand All @@ -51,49 +37,16 @@ on: [pull_request]
jobs:
# TODO: change `linter_name`.
linter_name:
name: runner / <linter-name>
name: runner / action-drupal-coder
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-template@v1
- uses: chrfritsch/action-drupal-coder@v1
with:
github_token: ${{ secrets.github_token }}
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
# Possible reviewdog reporter [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
```
## 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 [haya14busa/action-depup](https://github.com/haya14busa/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)
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ inputs:
reporter:
description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].'
default: 'github-pr-check'
### Flags for <linter-name> ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

misspell -locale="${INPUT_LOCALE}" . \
| reviewdog -efm="%f:%l:%c: %m" -name="linter-name (misspell)" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}"
phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme' --report=checkstyle -q . \
| reviewdog -f="checkstyle" -name="drupal-coder (drupal)" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}"

phpcs --standard=DrupalPractice --extensions='php,module,inc,install,test,profile,theme,css,info,txt,md' --report=checkstyle -q . \
| reviewdog -f="checkstyle" -name="drupal-coder (drupal practice)" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}"
3 changes: 0 additions & 3 deletions testdata/text.md

This file was deleted.

0 comments on commit b9bf359

Please sign in to comment.