From bc20dae76b5da22e38858d9ae812425c4fda41ca Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:23:54 +0900 Subject: [PATCH 01/10] add test for #19 --- .github/workflows/test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0598e45..089d731 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,3 +28,14 @@ jobs: with: reviewdog_version: v0.10.0 - run: test "$(reviewdog -version)" = '0.10.0' + + container: + runs-on: ubuntu-latest + container: + image: alpine:latest + steps: + - uses: actions/checkout@v3 + + - name: install reviewdog + uses: ./ + - run: reviewdog -version From e34490360bd67b045ffd90ceb74690b97ba274d1 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:30:15 +0900 Subject: [PATCH 02/10] use sh instead of bash --- .github/workflows/test.yml | 1 - action.yml | 18 +++++++++--------- install.sh | 6 +++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 089d731..6cf2186 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,6 @@ jobs: image: alpine:latest steps: - uses: actions/checkout@v3 - - name: install reviewdog uses: ./ - run: reviewdog -version diff --git a/action.yml b/action.yml index 8e916b5..746917d 100644 --- a/action.yml +++ b/action.yml @@ -1,14 +1,14 @@ -name: 'Setup reviewdog' -description: '🐶 This action sets up reviewdog' +name: "Setup reviewdog" +description: "🐶 This action sets up reviewdog" inputs: reviewdog_version: - description: 'reviewdog version. [latest,nightly,vX.Y.Z]' - default: 'latest' + description: "reviewdog version. [latest,nightly,vX.Y.Z]" + default: "latest" runs: - using: 'composite' + using: "composite" steps: - run: $GITHUB_ACTION_PATH/install.sh - shell: bash + shell: sh env: REVIEWDOG_VERSION: ${{ inputs.reviewdog_version }} REVIEWDOG_TEMPDIR: ${{ runner.temp }} @@ -20,9 +20,9 @@ runs: echo "::group::📖 reviewdog -h" reviewdog -h 2>&1 || true echo "::endgroup::" - shell: bash + shell: sh # Ref: https://haya14busa.github.io/github-action-brandings/ branding: - icon: 'terminal' - color: 'gray-dark' + icon: "terminal" + color: "gray-dark" diff --git a/install.sh b/install.sh index 424e909..fb1bc4b 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/sh -set -euo pipefail +set -eu VERSION="${REVIEWDOG_VERSION:-latest}" @@ -14,7 +14,7 @@ if [ -z "${TEMP}" ]; then fi INSTALL_SCRIPT='https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh' -if [ "${VERSION}" == 'nightly' ] ; then +if [ "${VERSION}" = 'nightly' ] ; then INSTALL_SCRIPT='https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh' VERSION='latest' fi From c403e00a1f4c1469a7632e983a47b9aaec3babc3 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:30:57 +0900 Subject: [PATCH 03/10] Update install.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index fb1bc4b..c797bd3 100755 --- a/install.sh +++ b/install.sh @@ -14,7 +14,7 @@ if [ -z "${TEMP}" ]; then fi INSTALL_SCRIPT='https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh' -if [ "${VERSION}" = 'nightly' ] ; then +if [ "${VERSION}" = 'nightly' ]; then INSTALL_SCRIPT='https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh' VERSION='latest' fi From 5188125d04b1cef56e8bca3175b21ce5b071a26a Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:32:55 +0900 Subject: [PATCH 04/10] introduce actionlint --- .github/workflows/reviewdog.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 8b91dc3..5a57b95 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -74,3 +74,14 @@ jobs: github_token: ${{ secrets.github_token }} reporter: github-check level: warning + + actionlint: + name: runner / actionlint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: reviewdog/action-actionlint@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: warning From 12f42f547ef2343e4adb264e0452e85d932f8492 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:37:43 +0900 Subject: [PATCH 05/10] add check-installed.sh --- action.yml | 17 ++++++++--------- check-installed.sh | 9 +++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100755 check-installed.sh diff --git a/action.yml b/action.yml index 746917d..f687a43 100644 --- a/action.yml +++ b/action.yml @@ -7,19 +7,18 @@ inputs: runs: using: "composite" steps: - - run: $GITHUB_ACTION_PATH/install.sh + - name: install reviewdog + run: | + set -eu + "$GITHUB_ACTION_PATH/install.sh" shell: sh env: REVIEWDOG_VERSION: ${{ inputs.reviewdog_version }} REVIEWDOG_TEMPDIR: ${{ runner.temp }} - - run: | - if ! command -v reviewdog >/dev/null 2>&1; then - echo "reviewdog was not installed" - exit 1 - fi - echo "::group::📖 reviewdog -h" - reviewdog -h 2>&1 || true - echo "::endgroup::" + - name: check reviewdog is successfully installed + run: | + set -eu + "$GITHUB_ACTION_PATH/check-installed.sh" shell: sh # Ref: https://haya14busa.github.io/github-action-brandings/ diff --git a/check-installed.sh b/check-installed.sh new file mode 100755 index 0000000..666dab7 --- /dev/null +++ b/check-installed.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if ! command -v reviewdog >/dev/null 2>&1; then + echo "reviewdog was not installed" + exit 1 +fi +echo "::group::📖 reviewdog -h" +reviewdog -h 2>&1 || true +echo "::endgroup::" From 0a5eb8edbc61b113fcc4b89537174ceb36940284 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:38:32 +0900 Subject: [PATCH 06/10] fix actionlint warning: shellcheck reported issue in this script: SC2046:warning:1:20: Quote this to prevent word splitting --- .github/workflows/reviewdog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 5a57b95..bee0c14 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -46,7 +46,7 @@ jobs: wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv sudo cp "shellcheck-${scversion}/shellcheck" /usr/local/bin/ rm -rf "shellcheck-${scversion}/shellcheck" - - run: shellcheck -f diff $(shfmt -f .) | patch -p1 + - run: shellcheck -f diff "$(shfmt -f .)" | patch -p1 - name: suggester / shellcheck uses: reviewdog/action-suggester@master with: From a94d90bc3629745caa3780013c8c13bbe0fb6fa6 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:38:56 +0900 Subject: [PATCH 07/10] Update check-installed.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- check-installed.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check-installed.sh b/check-installed.sh index 666dab7..fe649fc 100755 --- a/check-installed.sh +++ b/check-installed.sh @@ -1,8 +1,8 @@ #!/bin/sh if ! command -v reviewdog >/dev/null 2>&1; then - echo "reviewdog was not installed" - exit 1 + echo "reviewdog was not installed" + exit 1 fi echo "::group::📖 reviewdog -h" reviewdog -h 2>&1 || true From b4801f8023c273b90dd8cbc539e8db67500af49a Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:48:00 +0900 Subject: [PATCH 08/10] use wget if curl in not installed --- install.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c797bd3..d58775a 100755 --- a/install.sh +++ b/install.sh @@ -22,7 +22,16 @@ fi mkdir -p "${TEMP}/reviewdog/bin" echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' -curl -sfL "${INSTALL_SCRIPT}" | sh -s -- -b "${TEMP}/reviewdog/bin" "${VERSION}" 2>&1 +( + if command -v curl; then + curl -sfL "${INSTALL_SCRIPT}" + elif command -v wget; then + wget -O - "${INSTALL_SCRIPT}" + else + echo "curl or wget is required" >&2 + exit 1 + fi +) | sh -s -- -b "${TEMP}/reviewdog/bin" "${VERSION}" 2>&1 echo '::endgroup::' echo "${TEMP}/reviewdog/bin" >>"${GITHUB_PATH}" From d1f5cc7d070eeb68fb755c01c982716761769f3f Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:55:50 +0900 Subject: [PATCH 09/10] ignore output of command -v --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index d58775a..9f8c861 100755 --- a/install.sh +++ b/install.sh @@ -23,9 +23,9 @@ mkdir -p "${TEMP}/reviewdog/bin" echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' ( - if command -v curl; then + if command -v curl 2>&1 > /dev/null; then curl -sfL "${INSTALL_SCRIPT}" - elif command -v wget; then + elif command -v wget 2>&1 > /dev/null; then wget -O - "${INSTALL_SCRIPT}" else echo "curl or wget is required" >&2 From 07c4ffd9376ad24af8baf65b8668a29406213296 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Sat, 5 Aug 2023 20:57:36 +0900 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9f8c861..293737e 100755 --- a/install.sh +++ b/install.sh @@ -23,9 +23,9 @@ mkdir -p "${TEMP}/reviewdog/bin" echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' ( - if command -v curl 2>&1 > /dev/null; then + if command -v curl 2>&1 >/dev/null; then curl -sfL "${INSTALL_SCRIPT}" - elif command -v wget 2>&1 > /dev/null; then + elif command -v wget 2>&1 >/dev/null; then wget -O - "${INSTALL_SCRIPT}" else echo "curl or wget is required" >&2