From b9bf3592e6b967e51615b32ee5da944adf971cc5 Mon Sep 17 00:00:00 2001 From: Christian Fritsch Date: Tue, 28 Jan 2020 16:31:38 +0100 Subject: [PATCH] Initial implementation --- .github/workflows/test.yml | 9 ++--- Dockerfile | 14 ++++--- README.md | 75 +++++++------------------------------- action.yml | 4 -- entrypoint.sh | 7 +++- testdata/text.md | 3 -- 6 files changed, 31 insertions(+), 81 deletions(-) delete mode 100644 testdata/text.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 726c274..f1a69c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: pull_request: jobs: test-check: - name: runner / (github-check) + name: runner / drupal-coder (github-check) runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -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 / (github-pr-check) + name: runner / drupal-coder (github-pr-check) runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -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 / (github-pr-review) + name: runner / drupal-coder (github-pr-review) runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -41,4 +39,3 @@ jobs: github_token: ${{ secrets.github_token }} reporter: github-pr-review level: error - locale: "US" diff --git a/Dockerfile b/Dockerfile index 148d250..c4418df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index e8737c5..8b3d7dc 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,15 @@ -# action-template - - -[![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 + + +[![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 @@ -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 ### - locale: - description: '-locale flag of misspell. (US/UK)' - default: '' + ``` ## Usage @@ -51,49 +37,16 @@ on: [pull_request] jobs: # TODO: change `linter_name`. linter_name: - name: runner / + 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) - diff --git a/action.yml b/action.yml index 03db3dc..3ae8b12 100644 --- a/action.yml +++ b/action.yml @@ -12,10 +12,6 @@ inputs: reporter: description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].' default: 'github-pr-check' - ### Flags for ### - locale: - description: '-locale flag of misspell. (US/UK)' - default: '' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 259c681..71a8f76 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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}" diff --git a/testdata/text.md b/testdata/text.md deleted file mode 100644 index 9bc74f8..0000000 --- a/testdata/text.md +++ /dev/null @@ -1,3 +0,0 @@ -Determinisitic result is important. - -colour # <= Check -locale