From 51863c3215cb262a2c77df7c7e8624a7cd70a990 Mon Sep 17 00:00:00 2001 From: Tsuyoshi CHO Date: Sat, 6 Feb 2021 16:39:42 +0900 Subject: [PATCH] update to composition --- .github/workflows/depup.yml | 2 +- .github/workflows/dockerimage.yml | 13 -------- Dockerfile | 22 -------------- README.md | 13 +++++++- action.yml | 24 +++++++++++++-- entrypoint.sh | 30 ------------------- script.sh | 49 +++++++++++++++++++++++++++++++ 7 files changed, 83 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/dockerimage.yml delete mode 100644 Dockerfile delete mode 100755 entrypoint.sh create mode 100755 script.sh diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index dc03a09..7f2cf58 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -14,7 +14,7 @@ jobs: - uses: haya14busa/action-depup@v1 id: depup with: - file: Dockerfile + file: action.yml version_name: REVIEWDOG_VERSION repo: reviewdog/reviewdog diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index a9822c5..0000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Docker Image CI -on: - push: - branches: - - master - pull_request: -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c6d1512..0000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM python:3.9.1-alpine - -ENV REVIEWDOG_VERSION=v0.11.0 - -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] - -# hadolint ignore=DL3006,DL3018 -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} - -COPY requirements.txt /requirements.txt - -# hadolint ignore=DL3006,DL3018,DL3013 -RUN apk add --no-cache --virtual .build-deps gcc musl-dev \ - && pip install cython \ - && pip install -r requirements.txt --default-timeout=100 future \ - && apk del .build-deps - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index df79040..2426c07 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,14 @@ This is a action-mypy repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation. +Notice: +This action is `composition action`. It need `npm ci`. + +You accept below one: + +- Your workflow manually setup to run `pip install -r requirements.txt` or other setup method. +- This action automatic run `pip install mypy`. + ## Input ```yaml @@ -62,6 +70,9 @@ inputs: description: 'mypy options (default: )' required: false default: '' + tool_name: + description: 'Tool name to use for reviewdog reporter' + default: 'mypy' ``` ### Input note @@ -83,7 +94,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: tsuyoshicho/action-mypy@v2 + - uses: tsuyoshicho/action-mypy@v3 with: github_token: ${{ secrets.github_token }} # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. diff --git a/action.yml b/action.yml index 12d89bb..73f8695 100644 --- a/action.yml +++ b/action.yml @@ -48,10 +48,28 @@ inputs: description: 'mypy options (default: )' required: false default: '' + tool_name: + description: 'Tool name to use for reviewdog reporter' + default: 'mypy' runs: - using: 'docker' - image: 'Dockerfile' - + using: 'composite' + steps: + - run: $GITHUB_ACTION_PATH/script.sh + shell: sh + env: + REVIEWDOG_VERSION: v0.11.0 + # INPUT_ is not available in Composite run steps + # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 + INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} + INPUT_WORKDIR: ${{ inputs.workdir }} + INPUT_TARGET: ${{ inputs.target }} + INPUT_LEVEL: ${{ inputs.level }} + INPUT_REPORTER: ${{ inputs.reporter }} + INPUT_FILTER_MODE: ${{ inputs.filter_mode }} + INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} + INPUT_MYPY_FLAGS: ${{ inputs.mypy_flags }} + INPUT_TOOL_NAME: ${{ inputs.tool_name }} # Ref: https://haya14busa.github.io/github-action-brandings/ branding: icon: 'check' diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 638ef10..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -set -e - -if [ -n "${GITHUB_WORKSPACE}" ] ; then - cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit -fi - -export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" - -echo "[action-mypy] mypy version:" -mypy --version - -echo "[action-mypy] reviewdog version:" -reviewdog --version - -echo "[action-mypy] mypy and reviewdog output:" -# shellcheck disable=SC2086 -mypy \ - --show-column-numbers \ - --show-absolute-path \ - ${INPUT_MYPY_FLAGS} \ - "${INPUT_TARGET:-.}" \ - | reviewdog \ - -efm="%f:%l:%c: %t%*[^:]: %m" \ - -name="mypy" \ - -reporter="${INPUT_REPORTER:-github-pr-check}" \ - -filter-mode="${INPUT_FILTER_MODE}" \ - -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ - -level="${INPUT_LEVEL}" \ - ${INPUT_REVIEWDOG_FLAGS} diff --git a/script.sh b/script.sh new file mode 100755 index 0000000..3e7ffb6 --- /dev/null +++ b/script.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# shellcheck disable=SC2086,SC2089,SC2090 + +cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit + +TEMP_PATH="$(mktemp -d)" +PATH="${TEMP_PATH}:$PATH" + +echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' +curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1 +echo '::endgroup::' + +echo '::group:: Installing mypy ... https://github.com/python/mypy' +if type "mypy" > /dev/null 2>&1 ; then + echo 'already installed' +else + echo 'install mypy' + pip install mypy +fi + +if type "mypy" > /dev/null 2>&1 ; then + mypy --version +else + echo 'This repository was not configured for mypy, process done.' + exit 1 +fi +echo '::endgroup::' + +export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" + + +echo '::group:: Running mypy with reviewdog 🐶 ...' +# shellcheck disable=SC2086 +mypy \ + --show-column-numbers \ + --show-absolute-path \ + ${INPUT_MYPY_FLAGS} \ + "${INPUT_TARGET:-.}" \ + | reviewdog \ + -efm="%f:%l:%c: %t%*[^:]: %m" \ + -name="mypy" \ + -reporter="${INPUT_REPORTER:-github-pr-check}" \ + -filter-mode="${INPUT_FILTER_MODE}" \ + -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -level="${INPUT_LEVEL}" \ + ${INPUT_REVIEWDOG_FLAGS} +echo '::endgroup::' +