From 803b3956fa288c65015075e8fddd414f3a14f2db Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sun, 21 Aug 2022 13:59:45 -0700 Subject: [PATCH] Add actionlint to testing pipelines (#1555) * add actionlint for github actions to testing suite * add quotes around vars per shellcheck * change expression per shellcheck * put more quotes around vars per shellcheck * put quotes around entire string * use find instead of ls to better handle non-alphanumberic filenames * update release workflow input types to have actual typese and fix typo --- .github/actionlint-matcher.json | 17 ++++++++++++ .github/workflows/changelog.yaml | 22 +++++++++------- .github/workflows/docs.yaml | 4 +-- .github/workflows/release.yaml | 24 ++++++++++------- .github/workflows/testing_pipelines.yaml | 33 ++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 .github/actionlint-matcher.json create mode 100644 .github/workflows/testing_pipelines.yaml diff --git a/.github/actionlint-matcher.json b/.github/actionlint-matcher.json new file mode 100644 index 00000000..4613e161 --- /dev/null +++ b/.github/actionlint-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "actionlint", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + } + ] +} diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml index ba1ad405..c8ac0581 100644 --- a/.github/workflows/changelog.yaml +++ b/.github/workflows/changelog.yaml @@ -52,12 +52,12 @@ jobs: if [[ ! ${GITHUB_REF##*/} =~ $prerelease_regex ]]; then echo '::debug::Actual release (not a prerelease)' TAG_REGEX="$prerelease_regex" - echo "FULL_RELEASE=true" >> $GITHUB_ENV + echo "FULL_RELEASE=true" >> "$GITHUB_ENV" fi fi echo "::debug::TAG_REGEX: $TAG_REGEX" - if [[ "$(git rev-parse "origin/$BRANCH")" != $GITHUB_SHA ]]; then + if [[ "$(git rev-parse "origin/$BRANCH")" != "$GITHUB_SHA" ]]; then # Normal build on a branch (no tag) echo "::debug::BRANCH: $BRANCH $(git rev-parse origin/$BRANCH)" echo "::debug::GITHUB_SHA: $GITHUB_SHA" @@ -72,10 +72,12 @@ jobs: echo "::debug::FILENAME: CHANGELOG.md" echo "::debug::SINCE_TAG: $SINCE_TAG" - echo "BRANCH=$BRANCH" >> $GITHUB_ENV - echo "TAG_REGEX=$TAG_REGEX" >> $GITHUB_ENV - echo "FILENAME=CHANGELOG.md" >> $GITHUB_ENV - echo "SINCE_TAG=$SINCE_TAG" >> $GITHUB_ENV + { + echo "BRANCH=$BRANCH" + echo "TAG_REGEX=$TAG_REGEX" + echo "FILENAME=CHANGELOG.md" + echo "SINCE_TAG=$SINCE_TAG" + } >> "$GITHUB_ENV" - name: Prep changelog file (clear out old lines) run: | @@ -95,7 +97,7 @@ jobs: exit 1 fi - sed -i "1,$(expr $tagline - 1)d" "$FILENAME" + sed -i "1,$(( tagline - 1 ))d" "$FILENAME" # delete generated line (or it will be added multiple times) sed -i '/This Changelog was automatically generated by/d' "$FILENAME" # delete trailing empty lines @@ -139,7 +141,7 @@ jobs: SOMETHING_CHANGED=false git diff --exit-code || SOMETHING_CHANGED=true echo "::debug::SOMETHING_CHANGED: $SOMETHING_CHANGED" - echo "SOMETHING_CHANGED=$SOMETHING_CHANGED" >> $GITHUB_ENV + echo "SOMETHING_CHANGED=$SOMETHING_CHANGED" >> "$GITHUB_ENV" - name: Commit if: env.SOMETHING_CHANGED == 'true' @@ -148,13 +150,13 @@ jobs: git config --global user.email "${{ secrets.JRNL_BOT_EMAIL }}" git add "$FILENAME" git commit -m "Update changelog [ci skip]" - git push origin $BRANCH + git push origin "$BRANCH" - name: Merge to Release branch if: env.FULL_RELEASE == 'true' run: | git fetch --unshallow origin git checkout release - git merge --ff-only $BRANCH + git merge --ff-only "$BRANCH" git push origin release diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 12fda5e2..c3cd4fa9 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -43,7 +43,7 @@ jobs: uses: actions/setup-node@main - name: Capture full Python version in env - run: echo "PYTHON_FULL_VERSION=$(python --version)" >> $GITHUB_ENV + run: echo "PYTHON_FULL_VERSION=$(python --version)" >> "$GITHUB_ENV" - name: poetry cache uses: actions/cache@v2 @@ -63,7 +63,7 @@ jobs: poetry config --local virtualenvs.in-project true poetry install --no-root --remove-untracked npm install - echo "node_modules/.bin" >> $GITHUB_PATH + echo "node_modules/.bin" >> "$GITHUB_PATH" - name: Start docs server run: poetry run poe docs-run & diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3eb8c8f4..aebc2308 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,17 +7,21 @@ on: inputs: version: description: 'Version (e.g. v2.5, v2.5.1-beta, v2.6-beta2)' + type: string required: true include_repo_version: description: 'Update version in repo? (true/false)' - require: true + type: boolean + required: true default: true include_pypi: description: 'Publish to PyPI? (true/false)' + type: boolean required: true default: true include_brew: description: 'Publish to Homebrew? (true/false)' + type: boolean required: true default: true @@ -59,7 +63,7 @@ jobs: run: | JRNL_VERSION="${{ github.event.inputs.version }}" echo "::debug::version: $JRNL_VERSION" - echo "JRNL_VERSION=$JRNL_VERSION" >> $GITHUB_ENV + echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV" - name: Set up Python uses: actions/setup-python@v2 @@ -83,7 +87,7 @@ jobs: if: ${{ github.event.inputs.include_repo_version == 'true' }} run: | poetry version "$JRNL_VERSION" - echo __version__ = \"$JRNL_VERSION\" > jrnl/__version__.py + echo "__version__ = \"$JRNL_VERSION\"" > jrnl/__version__.py - name: Commit updated files if: ${{ github.event.inputs.include_repo_version == 'true' && github.repository == env.HOME_REPO }} @@ -106,7 +110,7 @@ jobs: - name: Get PyPI version id: pypi-version-getter run: | - pypi_version="$(ls dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')" + pypi_version="$(find dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')" echo "::set-output name=pypi_version::$pypi_version" release_homebrew: @@ -127,8 +131,8 @@ jobs: echo "::debug::jrnl version: $JRNL_VERSION" echo "::debug::pypi version: $PYPI_VERSION" - echo "JRNL_VERSION=$JRNL_VERSION" >> $GITHUB_ENV - echo "PYPI_VERSION=$PYPI_VERSION" >> $GITHUB_ENV + echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV" + echo "PYPI_VERSION=$PYPI_VERSION" >> "$GITHUB_ENV" - name: Set env variables env: @@ -141,7 +145,7 @@ jobs: echo "FORMULA_REPO=${REPO_OWNER}/homebrew-prerelease" echo "BOT_REPO=jrnl-bot/homebrew-prerelease" echo "FORMULA_NAME=jrnl-beta" - } >> $GITHUB_ENV + } >> "$GITHUB_ENV" else echo '::debug::Full release (not a prerelease)' if [[ "${{ github.repository }}" == "${HOME_REPO}" ]]; then @@ -152,14 +156,14 @@ jobs: echo "FORMULA_REPO=${REPO_OWNER}/homebrew-core" echo "BOT_REPO=jrnl-bot/homebrew-core" echo "FORMULA_NAME=jrnl" - } >> $GITHUB_ENV + } >> "$GITHUB_ENV" fi - name: Tap formula run: | - brew tap ${FORMULA_REPO} + brew tap "${FORMULA_REPO}" echo '::debug::Set tap directory' - echo "BREW_TAP_DIRECTORY=$(brew --repo ${FORMULA_REPO})" >> $GITHUB_ENV + echo "BREW_TAP_DIRECTORY=$(brew --repo "${FORMULA_REPO}")" >> "$GITHUB_ENV" - name: Install dependencies run: brew install pipgrip diff --git a/.github/workflows/testing_pipelines.yaml b/.github/workflows/testing_pipelines.yaml new file mode 100644 index 00000000..3b562e05 --- /dev/null +++ b/.github/workflows/testing_pipelines.yaml @@ -0,0 +1,33 @@ +# Copyright (C) 2012-2022 jrnl contributors +# License: https://www.gnu.org/licenses/gpl-3.0.html + +name: Testing Pipeline Files + +on: + push: + branches: [ develop, release ] + paths: + - '.github/workflows/**' + - '.github/actions/**' + pull_request: + branches: [ develop ] + paths: + - '.github/workflows/**' + - '.github/actions/**' + +jobs: + test: + if: > + ! contains(github.event.head_commit.message, '[ci skip]') + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + steps: + - run: git config --global core.autocrlf false + - uses: actions/checkout@v2 + - name: Check workflow files + uses: docker://rhysd/actionlint:latest + with: + args: -color