From 3079c538fdcac0f8b0fdf64e7ae25c951a3a0521 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 12:52:39 -0400 Subject: [PATCH 01/16] First copy of the reviewdog-flakehell-action, which is already using flakeheaven. --- .gitignore | 7 +++++- Dockerfile | 52 ++++++++++++++++++++++++++++++++------ Dockerfile.testing | 54 +++++++++++++++++++++++++++++++++++++++ action.yml | 42 +++++++++++++++++++++++-------- entrypoint.sh | 63 ++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 191 insertions(+), 27 deletions(-) create mode 100644 Dockerfile.testing diff --git a/.gitignore b/.gitignore index 34a39ac..75925e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ # Folders to ignore -.vscode/ \ No newline at end of file +.vscode/ + +# Local environment specific settings +.env +.secret +.secrets diff --git a/Dockerfile b/Dockerfile index 4ad5566..59e540f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,54 @@ -FROM alpine:3.16 +FROM ubuntu:18.04 +# For https://github.com/reviewdog/reviewdog/issues/1158 ENV REVIEWDOG_VERSION=v0.14.1 +ENV PYTHON_VERSION=python3.8 -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +RUN apt-get update -y -# hadolint ignore=DL3006 -RUN apk --no-cache add git +# Get rid of existing python and pip installations. +RUN apt-get purge python3.? python3-pip -y && apt-get clean || : -RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} +# Install wget +RUN apt-get install --no-install-recommends wget git -y +# Clean up apt-get +RUN apt-get clean && rm -rf /var/lib/apt/lists/* -# 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/ +# Install specified Python version and pip3. +RUN apt-get update && apt-get install -y --no-install-recommends \ + software-properties-common +RUN add-apt-repository ppa:deadsnakes/ppa -y +RUN apt-get update && apt-get install -y --no-install-recommends \ + ${PYTHON_VERSION} \ + python3-pip +RUN ${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-distutils \ + python3-setuptools + +# Clean up apt-get +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven +RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ + flake8 \ + flakeheaven \ + pylint \ + flake8-bugbear \ + flake8-comprehensions \ + flake8-return \ + flake8-simplify \ + flake8-spellcheck \ + flake8-functions \ + wemake-python-styleguide \ + flake8-markdown \ + flake8-docstrings \ + flake8-codes \ + flake8-import-order + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \ + | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} COPY entrypoint.sh /entrypoint.sh diff --git a/Dockerfile.testing b/Dockerfile.testing new file mode 100644 index 0000000..09e93ba --- /dev/null +++ b/Dockerfile.testing @@ -0,0 +1,54 @@ +FROM ubuntu:18.04 + +# For https://github.com/reviewdog/reviewdog/issues/1158 +ENV REVIEWDOG_VERSION=v0.14.1 +ENV PYTHON_VERSION=python3.8 + +RUN apt-get update -y + +# Get rid of existing python and pip installations. +RUN apt-get purge python3.? python3-pip -y && apt-get clean || : + +# Install wget +RUN apt-get install --no-install-recommends wget git -y +# Clean up apt-get +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install specified Python version and pip3. +RUN apt-get update && apt-get install -y --no-install-recommends \ + software-properties-common +RUN add-apt-repository ppa:deadsnakes/ppa -y +RUN apt-get update && apt-get install -y --no-install-recommends \ + ${PYTHON_VERSION} \ + python3-pip +RUN ${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-distutils \ + python3-setuptools + +# Clean up apt-get +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven + +RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ + flake8 \ + flakeheaven \ + pylint \ + flake8-bugbear \ + flake8-comprehensions \ + flake8-return \ + flake8-simplify \ + flake8-spellcheck \ + flake8-functions \ + wemake-python-styleguide \ + flake8-markdown \ + flake8-docstrings \ + flake8-codes \ + flake8-import-order + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \ + | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} + +ENTRYPOINT [ "/bin/bash" ] diff --git a/action.yml b/action.yml index 9e7aa23..2d6b2fd 100644 --- a/action.yml +++ b/action.yml @@ -1,43 +1,63 @@ -name: 'TODO: Run with reviewdog' -description: 'TODO: 🐶 Run with reviewdog on pull requests to improve code review experience.' -author: 'TODO: ' + +# GitHub Action to run flakeheaven through reviewdog. +# flakeheaven (https://github.com/flakeheaven/flakeheaven) integrates well with legacy code +# reviewdog (https://github.com/reviewdog) adds inline comments for PRs/commits +# +# This Action was created using reviewdog's Action Template +# https://github.com/reviewdog/action-template +name: 'Run flakeheaven with reviewdog' +description: '🐶 Run flakeheaven with reviewdog on pull requests to improve code review experience.' +author: 'Balint Gyimesi' inputs: github_token: description: 'GITHUB_TOKEN' default: '${{ github.token }}' + required: false workdir: description: 'Working directory relative to the root directory.' default: '.' - ### Flags for reviewdog ### + required: false + python_version: + description: 'The Python version to use for flakeheaven, e.g. python3.8' + # Don't forget to update this in the Dockerfile too until this is fixed: + # https://github.community/t/feature-request-build-args-support-in-docker-container-actions/16846/15 + default: 'python3.8' + required: false + + ### Flags for reviewdog level: description: 'Report level for reviewdog [info,warning,error]' - default: 'error' + default: 'warning' + required: false reporter: description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].' default: 'github-pr-check' + required: false filter_mode: description: | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. Default is added. default: 'added' + required: false fail_on_error: description: | Exit code for reviewdog when errors are found [true,false] Default is `false`. default: 'false' + required: false reviewdog_flags: description: 'Additional reviewdog flags' default: '' - ### Flags for ### - locale: - description: '-locale flag of misspell. (US/UK)' - default: '' + required: false + + ### Flags for flakeheaven + # None currently, flakeheaven is configured through pyproject.toml + runs: using: 'docker' image: 'Dockerfile' # Ref: https://haya14busa.github.io/github-action-brandings/ -# TODO: update branding if you want. branding: - icon: 'check' + icon: 'check-circle' color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index bf42c60..54247d1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,65 @@ -#!/bin/sh +#!/bin/bash set -e -if [ -n "${GITHUB_WORKSPACE}" ] ; then - cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit - git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 +if [ -n "${GITHUB_WORKSPACE}" ]; then + git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 + git config --global --add safe.directory "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1 + cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1 fi +export PY_EXE="${INPUT_PYTHON_VERSION}" +export INPUT_FILTER_MODE=diff_context export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" +TMPFILE=$(mktemp) +export TMPFILE -misspell -locale="${INPUT_LOCALE}" . \ - | reviewdog -efm="%f:%l:%c: %m" \ - -name="linter-name (misspell)" \ +echo "Running in: ${PWD}" +echo -e "\n=============================" +echo "flakeheaven installed plugins:" +${PY_EXE} -m flakeheaven plugins + +echo -e "\n=============================" +echo "flakeheaven config file (optional):" +ls -la pyproject.toml || : +cat pyproject.toml || : + +echo -e "\n=============================" +echo "Running flakeheaven, teeing and saving output to tmpfile: ${TMPFILE} (ignore non-zero exit)" +${PY_EXE} -m flakeheaven lint | tee "${TMPFILE}" || : + +echo -e "\n=============================" +ls -la "${TMPFILE}" +echo -e "\n=============================" +echo "Head of ${TMPFILE}:" +head "${TMPFILE}" + +echo -e "\n=============================" +echo "Running reviewdog with:" +# shellcheck disable=SC2016 +echo 'reviewdog -efm="%f:%l:%c: %m" \ + -name="flakeheaven" \ + -reporter="${INPUT_REPORTER:-github-pr-check}" \ + -filter-mode="${INPUT_FILTER_MODE}" \ + -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -level="${INPUT_LEVEL}" \ + "${INPUT_REVIEWDOG_FLAGS}" -tee < "${TMPFILE}"' +echo +echo "Where vars are:" +echo " INPUT_REPORTER=${INPUT_REPORTER}" +echo " INPUT_FILTER_MODE=${INPUT_FILTER_MODE}" +echo " INPUT_FAIL_ON_ERROR=${INPUT_FAIL_ON_ERROR}" +echo " INPUT_LEVEL=${INPUT_LEVEL}" +echo " INPUT_REVIEWDOG_FLAGS=${INPUT_REVIEWDOG_FLAGS}" + +echo -e "\n=============================" +reviewdog -efm="%f:%l:%c: %m" \ + -name="flakeheaven" \ -reporter="${INPUT_REPORTER:-github-pr-check}" \ -filter-mode="${INPUT_FILTER_MODE}" \ -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ -level="${INPUT_LEVEL}" \ - ${INPUT_REVIEWDOG_FLAGS} + "${INPUT_REVIEWDOG_FLAGS}" \ + -tee <"${TMPFILE}" + +echo -e "\n=============================" +echo "Done running reviewdog, exiting..." From 45ff4cb04ced3dcdbec2fb90dc64c7a92eb56317 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 12:59:43 -0400 Subject: [PATCH 02/16] Remove the unused env var. --- entrypoint.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 54247d1..8913378 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -42,14 +42,13 @@ echo 'reviewdog -efm="%f:%l:%c: %m" \ -filter-mode="${INPUT_FILTER_MODE}" \ -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ -level="${INPUT_LEVEL}" \ - "${INPUT_REVIEWDOG_FLAGS}" -tee < "${TMPFILE}"' + -tee < "${TMPFILE}"' echo echo "Where vars are:" echo " INPUT_REPORTER=${INPUT_REPORTER}" echo " INPUT_FILTER_MODE=${INPUT_FILTER_MODE}" echo " INPUT_FAIL_ON_ERROR=${INPUT_FAIL_ON_ERROR}" echo " INPUT_LEVEL=${INPUT_LEVEL}" -echo " INPUT_REVIEWDOG_FLAGS=${INPUT_REVIEWDOG_FLAGS}" echo -e "\n=============================" reviewdog -efm="%f:%l:%c: %m" \ @@ -58,7 +57,6 @@ reviewdog -efm="%f:%l:%c: %m" \ -filter-mode="${INPUT_FILTER_MODE}" \ -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ -level="${INPUT_LEVEL}" \ - "${INPUT_REVIEWDOG_FLAGS}" \ -tee <"${TMPFILE}" echo -e "\n=============================" From bba3d9490c493febd06f5554c17aa2046db56e56 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 13:59:13 -0400 Subject: [PATCH 03/16] Add my flakehell plugin's README to they can be merged. --- README.other.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 README.other.md diff --git a/README.other.md b/README.other.md new file mode 100644 index 0000000..4603f5a --- /dev/null +++ b/README.other.md @@ -0,0 +1,97 @@ +# Description + +This repo contains a GitHub action to run [flakehell](https://github.com/flakehell/flakehell), +using [reviewdog](https://github.com/reviewdog/reviewdog) to annotate code changes on GitHub. + +This action was created from `reviewdog`'s awesome [action template](https://github.com/reviewdog/action-template). + +## Current status + +For `push` events to the `master` branch: + +[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml) +[![Docker Image CI](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/dockerimage.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/dockerimage.yml) +[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml) +[![reviewdog](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/reviewdog.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/reviewdog.yml) +[![release](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/release.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/release.yml) + +## Usage + +```yaml +name: reviewdog-flakehell +on: [pull_request] +jobs: + flakehell: + name: runner / flakehell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: sailingpalmtree/reviewdog-flakehell-action@0.2 + 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 +``` + +## Releases + +- v0.2 - first fully tested, and actually fully used version +- v0.1 - first draft release + +## Testing + +There are three ways to test this action: + +1. The included test workflows will run some sanity tests. +2. You can test the full flow of the Action with `act`. +3. You can also test the steps the Action will invoke with a locally built `docker` container. + +### Use the included test workflows + +These are defined in [`test.yaml`](https://github.com/sailingpalmtree/reviewdog-flakehell-action/blob/master/.github/workflows/test.yml). One can further configure these, but you can see in mine how I set them up. + +### Test the action locally + +For this I used the tool [act](https://github.com/nektos/act). + +#### Platforms + +I saved the platforms I cared about in my `~/.actrc` file: + +```text +-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest +-P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04 +-P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04 +``` + +(note that you could pass these in on the command line too with `-P`) + +#### Secrets and environment variables + +In order to pass in secrets and other env variables to the action, I saved these in `.env` and `.secret` files. +(Don't forget to add these to `.gitignore` for obvious reasons) +`act` by default will read these files with these names but you can name them differently and pass them in with their flags. +Alternatively, you can pass them in on the `act` command line too. + +#### Invocation + +I ran `act` with the simple `act push` command. Here, `push` was meant to simulate a GitHub `push` event. You can use any other event, and you can further configure them if you wish. + +### With a locally built Docker image + +There's an included `Dockerfile.testing` that can be used to build a container identical to the one the Action uses when it's running. The only difference is that `Dockerfile.testing` doesn't invoke the `entrypoint.sh` script - instead it drops you into `bash` upon running the container. This is so that you can then manually inspect the contents of the container and run any commands you like, including the ones the `entrypoint.sh` script has. Naturally, you'll have to set the needed environment variables yourself in this case. + +Feel free to modify the `Dockerfile` or the `Dockerfile.testing`, but always make sure they only differ in their entrypoint. In other words, running `diff Dockerfile*` should show only the following: + +```bash +diff Dockerfile* +# [some line numbers here] +< COPY entrypoint.sh /entrypoint.sh +< +< ENTRYPOINT ["/entrypoint.sh"] +--- +> ENTRYPOINT [ "/bin/bash" ] +``` From ce7fb212685aa20d595540c00ea95e57305e2c8a Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 19:28:13 -0400 Subject: [PATCH 04/16] Add pyproject.toml. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c2ec492 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.flakeheaven] +# show line of source code in output +show_source = true From 1f52553acfab663675d71b8daaa1a258ea097813 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 19:28:38 -0400 Subject: [PATCH 05/16] Update old README to almost being complete. --- README.other.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.other.md b/README.other.md index 4603f5a..5104de0 100644 --- a/README.other.md +++ b/README.other.md @@ -1,6 +1,9 @@ # Description -This repo contains a GitHub action to run [flakehell](https://github.com/flakehell/flakehell), +This repo contains a GitHub action to run code linters and report thheir findings on GitHub. + +The currently supported code linters are: +- [flakeheaven](https://github.com/flakeheaven/flakeheaven), using [reviewdog](https://github.com/reviewdog/reviewdog) to annotate code changes on GitHub. This action was created from `reviewdog`'s awesome [action template](https://github.com/reviewdog/action-template). @@ -9,11 +12,11 @@ This action was created from `reviewdog`'s awesome [action template](https://git For `push` events to the `master` branch: -[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml) -[![Docker Image CI](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/dockerimage.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/dockerimage.yml) -[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/test.yml) -[![reviewdog](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/reviewdog.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/reviewdog.yml) -[![release](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/release.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/reviewdog-flakehell-action/actions/workflows/release.yml) +[![Test flakeheaven with Reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml) +[![Docker Image CI](https://github.com/sailingpalmtree/lint/actions/workflows/dockerimage.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/dockerimage.yml) +[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml) +[![reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/reviewdog.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/reviewdog.yml) +[![release](https://github.com/sailingpalmtree/lint/actions/workflows/release.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/release.yml) ## Usage @@ -26,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: sailingpalmtree/reviewdog-flakehell-action@0.2 + - uses: sailingpalmtree/lint@0.2 with: github_token: ${{ secrets.github_token }} # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. @@ -51,7 +54,7 @@ There are three ways to test this action: ### Use the included test workflows -These are defined in [`test.yaml`](https://github.com/sailingpalmtree/reviewdog-flakehell-action/blob/master/.github/workflows/test.yml). One can further configure these, but you can see in mine how I set them up. +These are defined in [`test.yaml`](https://github.com/sailingpalmtree/lint/blob/master/.github/workflows/test.yml). One can further configure these, but you can see in mine how I set them up. ### Test the action locally From c0922a1ad45a9a64dfcf5d0b23f1932143bf017b Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 19:32:54 -0400 Subject: [PATCH 06/16] More README updates from the unsaved file, thanks vscode. --- README.other.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/README.other.md b/README.other.md index 5104de0..67cfae5 100644 --- a/README.other.md +++ b/README.other.md @@ -1,6 +1,6 @@ # Description -This repo contains a GitHub action to run code linters and report thheir findings on GitHub. +This repo contains a GitHub action to run code linters and report their findings on GitHub. The currently supported code linters are: - [flakeheaven](https://github.com/flakeheaven/flakeheaven), @@ -21,15 +21,15 @@ For `push` events to the `master` branch: ## Usage ```yaml -name: reviewdog-flakehell +name: linting on: [pull_request] jobs: flakehell: - name: runner / flakehell + name: lint-runner runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: sailingpalmtree/lint@0.2 + - uses: sailingpalmtree/lint@latest with: github_token: ${{ secrets.github_token }} # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. @@ -39,11 +39,6 @@ jobs: level: warning ``` -## Releases - -- v0.2 - first fully tested, and actually fully used version -- v0.1 - first draft release - ## Testing There are three ways to test this action: @@ -87,6 +82,18 @@ I ran `act` with the simple `act push` command. Here, `push` was meant to simula There's an included `Dockerfile.testing` that can be used to build a container identical to the one the Action uses when it's running. The only difference is that `Dockerfile.testing` doesn't invoke the `entrypoint.sh` script - instead it drops you into `bash` upon running the container. This is so that you can then manually inspect the contents of the container and run any commands you like, including the ones the `entrypoint.sh` script has. Naturally, you'll have to set the needed environment variables yourself in this case. +Example commands for the above: +```bash +docker build . -t linter -f Dockerfile.testing +docker run -it linter +# Inside the container +mkdir /tmp/devel +cd /tmp/devel + +git clone +python3.8 -m flakeheaven lint +``` + Feel free to modify the `Dockerfile` or the `Dockerfile.testing`, but always make sure they only differ in their entrypoint. In other words, running `diff Dockerfile*` should show only the following: ```bash From 9e3e0840675dbd3471a68d9feda9a63aeda36570 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 19:34:44 -0400 Subject: [PATCH 07/16] Promote the README to the main page, save the one from reviewdog. --- README.md | 151 +++++++++++++++++++-------------------- README.md.orig.reviewdog | 114 +++++++++++++++++++++++++++++ README.other.md | 107 --------------------------- 3 files changed, 186 insertions(+), 186 deletions(-) create mode 100644 README.md.orig.reviewdog delete mode 100644 README.other.md diff --git a/README.md b/README.md index 65d1502..67cfae5 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,35 @@ -# action-template +# Description - -[![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-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) +This repo contains a GitHub action to run code linters and report their findings on GitHub. -![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) +The currently supported code linters are: +- [flakeheaven](https://github.com/flakeheaven/flakeheaven), +using [reviewdog](https://github.com/reviewdog/reviewdog) to annotate code changes on GitHub. -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:! +This action was created from `reviewdog`'s awesome [action template](https://github.com/reviewdog/action-template). -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. +## Current status -This repo contains a sample action to run [misspell](https://github.com/client9/misspell). +For `push` events to the `master` branch: -## Input - - -```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]' - default: 'error' - reporter: - description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].' - default: 'github-pr-check' - filter_mode: - description: | - Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. - Default is added. - default: 'added' - fail_on_error: - description: | - Exit code for reviewdog when errors are found [true,false] - Default is `false`. - default: 'false' - reviewdog_flags: - description: 'Additional reviewdog flags' - default: '' - ### Flags for ### - locale: - description: '-locale flag of misspell. (US/UK)' - default: '' -``` +[![Test flakeheaven with Reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml) +[![Docker Image CI](https://github.com/sailingpalmtree/lint/actions/workflows/dockerimage.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/dockerimage.yml) +[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml) +[![reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/reviewdog.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/reviewdog.yml) +[![release](https://github.com/sailingpalmtree/lint/actions/workflows/release.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/release.yml) ## Usage - ```yaml -name: reviewdog +name: linting on: [pull_request] jobs: - # TODO: change `linter_name`. - linter_name: - name: runner / + flakehell: + name: lint-runner runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: reviewdog/action-template@v1 + - uses: sailingpalmtree/lint@latest with: github_token: ${{ secrets.github_token }} # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. @@ -81,34 +39,69 @@ jobs: level: warning ``` -## Development +## Testing + +There are three ways to test this action: -### Release +1. The included test workflows will run some sanity tests. +2. You can test the full flow of the Action with `act`. +3. You can also test the steps the Action will invoke with a locally built `docker` container. -#### [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. +### Use the included test workflows -#### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver) +These are defined in [`test.yaml`](https://github.com/sailingpalmtree/lint/blob/master/.github/workflows/test.yml). One can further configure these, but you can see in mine how I set them up. -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 +### Test the action locally -### Lint - reviewdog integration +For this I used the tool [act](https://github.com/nektos/act). + +#### Platforms + +I saved the platforms I cared about in my `~/.actrc` file: + +```text +-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest +-P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04 +-P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04 +``` -This reviewdog action template itself is integrated with reviewdog to run lints -which is useful for Docker container based actions. +(note that you could pass these in on the command line too with `-P`) -![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png) +#### Secrets and environment variables -Supported linters: +In order to pass in secrets and other env variables to the action, I saved these in `.env` and `.secret` files. +(Don't forget to add these to `.gitignore` for obvious reasons) +`act` by default will read these files with these names but you can name them differently and pass them in with their flags. +Alternatively, you can pass them in on the `act` command line too. -- [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) +#### Invocation -### Dependencies Update Automation -This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update -reviewdog version. +I ran `act` with the simple `act push` command. Here, `push` was meant to simulate a GitHub `push` event. You can use any other event, and you can further configure them if you wish. -[![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/reviewdog/action-template/pull/6) +### With a locally built Docker image + +There's an included `Dockerfile.testing` that can be used to build a container identical to the one the Action uses when it's running. The only difference is that `Dockerfile.testing` doesn't invoke the `entrypoint.sh` script - instead it drops you into `bash` upon running the container. This is so that you can then manually inspect the contents of the container and run any commands you like, including the ones the `entrypoint.sh` script has. Naturally, you'll have to set the needed environment variables yourself in this case. + +Example commands for the above: +```bash +docker build . -t linter -f Dockerfile.testing +docker run -it linter +# Inside the container +mkdir /tmp/devel +cd /tmp/devel + +git clone +python3.8 -m flakeheaven lint +``` + +Feel free to modify the `Dockerfile` or the `Dockerfile.testing`, but always make sure they only differ in their entrypoint. In other words, running `diff Dockerfile*` should show only the following: + +```bash +diff Dockerfile* +# [some line numbers here] +< COPY entrypoint.sh /entrypoint.sh +< +< ENTRYPOINT ["/entrypoint.sh"] +--- +> ENTRYPOINT [ "/bin/bash" ] +``` diff --git a/README.md.orig.reviewdog b/README.md.orig.reviewdog new file mode 100644 index 0000000..65d1502 --- /dev/null +++ b/README.md.orig.reviewdog @@ -0,0 +1,114 @@ +# 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-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 repo contains a sample action to run [misspell](https://github.com/client9/misspell). + +## Input + + +```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]' + default: 'error' + reporter: + description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].' + default: 'github-pr-check' + filter_mode: + description: | + Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. + Default is added. + default: 'added' + fail_on_error: + description: | + Exit code for reviewdog when errors are found [true,false] + Default is `false`. + default: 'false' + reviewdog_flags: + description: 'Additional reviewdog flags' + default: '' + ### Flags for ### + locale: + description: '-locale flag of misspell. (US/UK)' + default: '' +``` + +## Usage + + +```yaml +name: reviewdog +on: [pull_request] +jobs: + # TODO: change `linter_name`. + linter_name: + name: runner / + 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 +``` + +## 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) diff --git a/README.other.md b/README.other.md deleted file mode 100644 index 67cfae5..0000000 --- a/README.other.md +++ /dev/null @@ -1,107 +0,0 @@ -# Description - -This repo contains a GitHub action to run code linters and report their findings on GitHub. - -The currently supported code linters are: -- [flakeheaven](https://github.com/flakeheaven/flakeheaven), -using [reviewdog](https://github.com/reviewdog/reviewdog) to annotate code changes on GitHub. - -This action was created from `reviewdog`'s awesome [action template](https://github.com/reviewdog/action-template). - -## Current status - -For `push` events to the `master` branch: - -[![Test flakeheaven with Reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml) -[![Docker Image CI](https://github.com/sailingpalmtree/lint/actions/workflows/dockerimage.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/dockerimage.yml) -[![Test Flakehell with Reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/test.yml) -[![reviewdog](https://github.com/sailingpalmtree/lint/actions/workflows/reviewdog.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/reviewdog.yml) -[![release](https://github.com/sailingpalmtree/lint/actions/workflows/release.yml/badge.svg?branch=master&event=push)](https://github.com/sailingpalmtree/lint/actions/workflows/release.yml) - -## Usage - -```yaml -name: linting -on: [pull_request] -jobs: - flakehell: - name: lint-runner - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: sailingpalmtree/lint@latest - 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 -``` - -## Testing - -There are three ways to test this action: - -1. The included test workflows will run some sanity tests. -2. You can test the full flow of the Action with `act`. -3. You can also test the steps the Action will invoke with a locally built `docker` container. - -### Use the included test workflows - -These are defined in [`test.yaml`](https://github.com/sailingpalmtree/lint/blob/master/.github/workflows/test.yml). One can further configure these, but you can see in mine how I set them up. - -### Test the action locally - -For this I used the tool [act](https://github.com/nektos/act). - -#### Platforms - -I saved the platforms I cared about in my `~/.actrc` file: - -```text --P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest --P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04 --P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04 -``` - -(note that you could pass these in on the command line too with `-P`) - -#### Secrets and environment variables - -In order to pass in secrets and other env variables to the action, I saved these in `.env` and `.secret` files. -(Don't forget to add these to `.gitignore` for obvious reasons) -`act` by default will read these files with these names but you can name them differently and pass them in with their flags. -Alternatively, you can pass them in on the `act` command line too. - -#### Invocation - -I ran `act` with the simple `act push` command. Here, `push` was meant to simulate a GitHub `push` event. You can use any other event, and you can further configure them if you wish. - -### With a locally built Docker image - -There's an included `Dockerfile.testing` that can be used to build a container identical to the one the Action uses when it's running. The only difference is that `Dockerfile.testing` doesn't invoke the `entrypoint.sh` script - instead it drops you into `bash` upon running the container. This is so that you can then manually inspect the contents of the container and run any commands you like, including the ones the `entrypoint.sh` script has. Naturally, you'll have to set the needed environment variables yourself in this case. - -Example commands for the above: -```bash -docker build . -t linter -f Dockerfile.testing -docker run -it linter -# Inside the container -mkdir /tmp/devel -cd /tmp/devel - -git clone -python3.8 -m flakeheaven lint -``` - -Feel free to modify the `Dockerfile` or the `Dockerfile.testing`, but always make sure they only differ in their entrypoint. In other words, running `diff Dockerfile*` should show only the following: - -```bash -diff Dockerfile* -# [some line numbers here] -< COPY entrypoint.sh /entrypoint.sh -< -< ENTRYPOINT ["/entrypoint.sh"] ---- -> ENTRYPOINT [ "/bin/bash" ] -``` From f09fd762e6d938046624980739f385cdccfd3002 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 19:40:16 -0400 Subject: [PATCH 08/16] Update GH action runner names for the test workflow. --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3db8a6..280e3e1 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: linter-runner (github-check) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: test-pr-check: if: github.event_name == 'pull_request' - name: runner / (github-pr-check) + name: linter-runner (github-pr-check) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -33,7 +33,7 @@ jobs: test-pr-review: if: github.event_name == 'pull_request' - name: runner / (github-pr-review) + name: linter-runner (github-pr-review) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 41815aa58e38350917f19b5d249edc601ce00241 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 21:27:20 -0400 Subject: [PATCH 09/16] Update action's name so it's unique and can be published. --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2d6b2fd..b9ff66d 100644 --- a/action.yml +++ b/action.yml @@ -5,7 +5,7 @@ # # This Action was created using reviewdog's Action Template # https://github.com/reviewdog/action-template -name: 'Run flakeheaven with reviewdog' +name: 'Python linting with flakeheaven and reviewdog' description: '🐶 Run flakeheaven with reviewdog on pull requests to improve code review experience.' author: 'Balint Gyimesi' inputs: From 29d8679dd3f73605d7d389ae90235348d9e7387e Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 22:39:42 -0400 Subject: [PATCH 10/16] Better flakeheaven config. --- pyproject.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c2ec492..2b74190 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,17 @@ [tool.flakeheaven] # show line of source code in output show_source = true +# make output nice +format = "grouped" +# 80 chars aren't enough in 21 century +max_line_length = 90 + +[tool.flakeheaven.plugins] +# enable everythind that starts with `flake8-` +"flake8-*" = ["+*"] + +mccabe = ["+*"] +pep8-naming = ["+*"] +pycodestyle = ["+*"] +pyflakes = ["+*"] +pylint = ["+*"] From a6ae6a9a9dcabf1b3ad497f249ca414999003307 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi Date: Wed, 20 Jul 2022 22:42:32 -0400 Subject: [PATCH 11/16] Remove inherited README. --- README.md.orig.reviewdog | 114 --------------------------------------- 1 file changed, 114 deletions(-) delete mode 100644 README.md.orig.reviewdog diff --git a/README.md.orig.reviewdog b/README.md.orig.reviewdog deleted file mode 100644 index 65d1502..0000000 --- a/README.md.orig.reviewdog +++ /dev/null @@ -1,114 +0,0 @@ -# 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-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 repo contains a sample action to run [misspell](https://github.com/client9/misspell). - -## Input - - -```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]' - default: 'error' - reporter: - description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].' - default: 'github-pr-check' - filter_mode: - description: | - Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. - Default is added. - default: 'added' - fail_on_error: - description: | - Exit code for reviewdog when errors are found [true,false] - Default is `false`. - default: 'false' - reviewdog_flags: - description: 'Additional reviewdog flags' - default: '' - ### Flags for ### - locale: - description: '-locale flag of misspell. (US/UK)' - default: '' -``` - -## Usage - - -```yaml -name: reviewdog -on: [pull_request] -jobs: - # TODO: change `linter_name`. - linter_name: - name: runner / - 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 -``` - -## 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) From 87da87428e8d88429ec437e681c45f3336b9c477 Mon Sep 17 00:00:00 2001 From: balint-bg Date: Wed, 3 Aug 2022 11:27:37 -0400 Subject: [PATCH 12/16] Pin flake8-simplify version to avoid pip having to look through all of their releases. --- Dockerfile | 2 +- Dockerfile.testing | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 59e540f..83bd87d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ flake8-bugbear \ flake8-comprehensions \ flake8-return \ - flake8-simplify \ + flake8-simplify>=0.19.0 \ flake8-spellcheck \ flake8-functions \ wemake-python-styleguide \ diff --git a/Dockerfile.testing b/Dockerfile.testing index 09e93ba..ac9f7df 100644 --- a/Dockerfile.testing +++ b/Dockerfile.testing @@ -30,7 +30,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven - RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ flake8 \ flakeheaven \ @@ -38,7 +37,7 @@ RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ flake8-bugbear \ flake8-comprehensions \ flake8-return \ - flake8-simplify \ + flake8-simplify>=0.19.0 \ flake8-spellcheck \ flake8-functions \ wemake-python-styleguide \ From 253b6454fab3aa3fcf63e0076b76ca285d3d1b38 Mon Sep 17 00:00:00 2001 From: balint-bg Date: Wed, 3 Aug 2022 11:51:06 -0400 Subject: [PATCH 13/16] Pin all plugin versions. --- Dockerfile | 28 ++++++++++++++-------------- Dockerfile.testing | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83bd87d..a74d51d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,20 +31,20 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ - flake8 \ - flakeheaven \ - pylint \ - flake8-bugbear \ - flake8-comprehensions \ - flake8-return \ - flake8-simplify>=0.19.0 \ - flake8-spellcheck \ - flake8-functions \ - wemake-python-styleguide \ - flake8-markdown \ - flake8-docstrings \ - flake8-codes \ - flake8-import-order + flake8>=4.0.0 \ + flakeheaven>=3.0.0 \ + pylint>=2.15.0 \ + flake8-bugbear>=22.7.1 \ + flake8-comprehensions>=3.10.0 \ + flake8-return>=1.1.3 \ + flake8-simplify>=0.19.3 \ + flake8-spellcheck>=0.28.0 \ + flake8-functions>=0.0.7 \ + wemake-python-styleguide>=0.16.1 \ + flake8-markdown>=v0.3.0 \ + flake8-docstrings>=1.6.0 \ + flake8-codes>=0.2.2 \ + flake8-import-order>=0.18.1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \ diff --git a/Dockerfile.testing b/Dockerfile.testing index ac9f7df..eb99331 100644 --- a/Dockerfile.testing +++ b/Dockerfile.testing @@ -31,20 +31,20 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ - flake8 \ - flakeheaven \ - pylint \ - flake8-bugbear \ - flake8-comprehensions \ - flake8-return \ - flake8-simplify>=0.19.0 \ - flake8-spellcheck \ - flake8-functions \ - wemake-python-styleguide \ - flake8-markdown \ - flake8-docstrings \ - flake8-codes \ - flake8-import-order + flake8>=4.0.0 \ + flakeheaven>=3.0.0 \ + pylint>=2.15.0 \ + flake8-bugbear>=22.7.1 \ + flake8-comprehensions>=3.10.0 \ + flake8-return>=1.1.3 \ + flake8-simplify>=0.19.3 \ + flake8-spellcheck>=0.28.0 \ + flake8-functions>=0.0.7 \ + wemake-python-styleguide>=0.16.1 \ + flake8-markdown>=v0.3.0 \ + flake8-docstrings>=1.6.0 \ + flake8-codes>=0.2.2 \ + flake8-import-order>=0.18.1 SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \ From a406b0f108254b10a4df833b75f811ea1fa144b6 Mon Sep 17 00:00:00 2001 From: balint-bg Date: Wed, 3 Aug 2022 13:17:11 -0400 Subject: [PATCH 14/16] Comment out pip upgrade, seems to break things. --- Dockerfile | 7 ++++--- Dockerfile.testing | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index a74d51d..83c014f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,8 @@ RUN add-apt-repository ppa:deadsnakes/ppa -y RUN apt-get update && apt-get install -y --no-install-recommends \ ${PYTHON_VERSION} \ python3-pip -RUN ${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip +# TODO(balint) this seems to break later pip commands: "/usr/bin/pip not found" +# RUN ${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip RUN apt-get update && apt-get install -y --no-install-recommends \ python3-distutils \ python3-setuptools @@ -29,11 +30,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Clean up apt-get RUN apt-get clean && rm -rf /var/lib/apt/lists/* -# Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven +# Install flake8, pylint and flakeheaven, then plugins for flakeheaven RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ flake8>=4.0.0 \ - flakeheaven>=3.0.0 \ pylint>=2.15.0 \ + flakeheaven>=3.0.0 \ flake8-bugbear>=22.7.1 \ flake8-comprehensions>=3.10.0 \ flake8-return>=1.1.3 \ diff --git a/Dockerfile.testing b/Dockerfile.testing index eb99331..6862e9c 100644 --- a/Dockerfile.testing +++ b/Dockerfile.testing @@ -21,7 +21,8 @@ RUN add-apt-repository ppa:deadsnakes/ppa -y RUN apt-get update && apt-get install -y --no-install-recommends \ ${PYTHON_VERSION} \ python3-pip -RUN ${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip +# TODO(balint) this seems to break later pip commands: "/usr/bin/pip not found" +# RUN ${PYTHON_VERSION} -m pip install --no-cache-dir --upgrade pip RUN apt-get update && apt-get install -y --no-install-recommends \ python3-distutils \ python3-setuptools @@ -29,11 +30,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Clean up apt-get RUN apt-get clean && rm -rf /var/lib/apt/lists/* -# Install reviewdog, flake8, pylint and flakeheaven, then plugins for flakeheaven +# Install flake8, pylint and flakeheaven, then plugins for flakeheaven RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ flake8>=4.0.0 \ - flakeheaven>=3.0.0 \ pylint>=2.15.0 \ + flakeheaven>=3.0.0 \ flake8-bugbear>=22.7.1 \ flake8-comprehensions>=3.10.0 \ flake8-return>=1.1.3 \ @@ -46,6 +47,7 @@ RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ flake8-codes>=0.2.2 \ flake8-import-order>=0.18.1 + SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \ | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} From d62e5b8654cbfa3de970287d0e651efab17c3da8 Mon Sep 17 00:00:00 2001 From: balint-bg Date: Wed, 3 Aug 2022 13:28:35 -0400 Subject: [PATCH 15/16] Pin flake8 version, 5.0.0> isn't compatible with flakeheaven... --- Dockerfile | 2 +- Dockerfile.testing | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83c014f..ec9472e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install flake8, pylint and flakeheaven, then plugins for flakeheaven RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ - flake8>=4.0.0 \ + flake8==4.0.1 \ pylint>=2.15.0 \ flakeheaven>=3.0.0 \ flake8-bugbear>=22.7.1 \ diff --git a/Dockerfile.testing b/Dockerfile.testing index 6862e9c..6a58ead 100644 --- a/Dockerfile.testing +++ b/Dockerfile.testing @@ -32,7 +32,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install flake8, pylint and flakeheaven, then plugins for flakeheaven RUN ${PYTHON_VERSION} -m pip install --no-cache-dir \ - flake8>=4.0.0 \ + flake8==4.0.1 \ pylint>=2.15.0 \ flakeheaven>=3.0.0 \ flake8-bugbear>=22.7.1 \ From 95a365fa9dd930cc5b0e7eab0d65d18a16e4f5b5 Mon Sep 17 00:00:00 2001 From: Balint Gyimesi <12203093+sailingpalmtree@users.noreply.github.com> Date: Wed, 9 Jul 2025 18:01:57 -0400 Subject: [PATCH 16/16] Dont default to diff context only (#9) --- entrypoint.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8913378..47d3ec7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,7 +8,6 @@ if [ -n "${GITHUB_WORKSPACE}" ]; then fi export PY_EXE="${INPUT_PYTHON_VERSION}" -export INPUT_FILTER_MODE=diff_context export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" TMPFILE=$(mktemp) export TMPFILE