diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8546d42..b2a978c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,3 +25,48 @@ jobs: @semantic-release/git@9.0.0 env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + os-test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + - name: Output + run: | + echo "Get author info" + echo " - ${{ env.GIT_COMMIT_AUTHOR }}" + echo " - ${{ env.GIT_COMMIT_AUTHOR_NAME }}" + echo " - ${{ env.GIT_COMMIT_AUTHOR_EMAIL }}" + echo "Get committer info" + echo " - ${{ env.GIT_COMMIT_COMMITTER }}" + echo " - ${{ env.GIT_COMMIT_COMMITTER_NAME }}" + echo " - ${{ env.GIT_COMMIT_COMMITTER_EMAIL }}" + echo "Get message info" + echo " - ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}" + echo " - ${{ env.GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED }}" + echo " - ${{ env.GIT_COMMIT_MESSAGE_BODY }}" + + win-test: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: ./ + - name: Output + run: | + echo "Get author info" + echo " - $env:GIT_COMMIT_AUTHOR" + echo " - $env:GIT_COMMIT_AUTHOR_NAME" + echo " - $env:GIT_COMMIT_AUTHOR_EMAIL" + echo "Get committer info" + echo " - $env:GIT_COMMIT_COMMITTER" + echo " - $env:GIT_COMMIT_COMMITTER_NAME" + echo " - $env:GIT_COMMIT_COMMITTER_EMAIL" + echo "Get message info" + echo " - $env:GIT_COMMIT_MESSAGE_SUBJECT" + echo " - $env:GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED" + echo " - $env:GIT_COMMIT_MESSAGE_BODY" diff --git a/entrypoint.sh b/entrypoint.sh index f8fb6d3..017a24e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh -l +#!/bin/bash TEMPLATE_AUTHOR_FORMAT="%an <%ae>" TEMPLATE_AUTHOR_NAME_FORMAT="%an" @@ -19,15 +19,17 @@ git_log_format() { } { - echo "GIT_COMMIT_AUTHOR=$(git_log_format "$TEMPLATE_AUTHOR_FORMAT" "HEAD")" - echo "GIT_COMMIT_AUTHOR_NAME=$(git_log_format "$TEMPLATE_AUTHOR_NAME_FORMAT" "HEAD")" - echo "GIT_COMMIT_AUTHOR_EMAIL=$(git_log_format "$TEMPLATE_AUTHOR_EMAIL_FORMAT" "HEAD")" + echo "GIT_COMMIT_AUTHOR=$(git_log_format "${TEMPLATE_AUTHOR_FORMAT}" "HEAD")" + echo "GIT_COMMIT_AUTHOR_NAME=$(git_log_format "${TEMPLATE_AUTHOR_NAME_FORMAT}" "HEAD")" + echo "GIT_COMMIT_AUTHOR_EMAIL=$(git_log_format "${TEMPLATE_AUTHOR_EMAIL_FORMAT}" "HEAD")" - echo "GIT_COMMIT_COMMITTER=$(git_log_format "$TEMPLATE_COMMITTER_FORMAT" "HEAD")" - echo "GIT_COMMIT_COMMITTER_NAME=$(git_log_format "$TEMPLATE_COMMITTER_NAME_FORMAT" "HEAD")" - echo "GIT_COMMIT_COMMITTER_EMAIL=$(git_log_format "$TEMPLATE_COMMITTER_EMAIL_FORMAT" "HEAD")" + echo "GIT_COMMIT_COMMITTER=$(git_log_format "${TEMPLATE_COMMITTER_FORMAT}" "HEAD")" + echo "GIT_COMMIT_COMMITTER_NAME=$(git_log_format "${TEMPLATE_COMMITTER_NAME_FORMAT}" "HEAD")" + echo "GIT_COMMIT_COMMITTER_EMAIL=$(git_log_format "${TEMPLATE_COMMITTER_EMAIL_FORMAT}" "HEAD")" - echo "GIT_COMMIT_MESSAGE_SUBJECT=$(git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT" "HEAD")" - echo "GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED=$(git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT" "HEAD")" - echo "GIT_COMMIT_MESSAGE_BODY_BODY="$(git_log_format "$TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT" "HEAD")"" + echo "GIT_COMMIT_MESSAGE_SUBJECT=$(git_log_format "${TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT}" "HEAD")" + echo "GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED=$(git_log_format "${TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT}" "HEAD")" + echo 'GIT_COMMIT_MESSAGE_BODY<>"$GITHUB_ENV" diff --git a/tests/git_log_format.bats b/tests/git_log_format.bats index 60db246..502e459 100644 --- a/tests/git_log_format.bats +++ b/tests/git_log_format.bats @@ -2,7 +2,7 @@ apk add --no-cache git > /dev/null -TEST_COMMIT_SHA=9f2cc79 +TEST_COMMIT_SHA=f554bec # Load git_log_format function source entrypoint.sh > /dev/null 2>&1 @@ -32,15 +32,24 @@ source entrypoint.sh > /dev/null 2>&1 } @test "git_log_format: message subject" { - test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT" "build: prepare github action" + test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_FORMAT" "ci: create a commit with multiple lines" } @test "git_log_format: message subject sanitized" { - test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT" "build-prepare-github-action" + test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_SUBJECT_SANITIZED_FORMAT" "ci-create-a-commit-with-multiple-lines" } @test "git_log_format: message body" { - test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT" "" + BODY=$(cat <<-END +Line 1 +Line 2 +Line 3 +Line 4 + +Bottom line +END +) + test_git_log_format "$TEMPLATE_COMMIT_MESSAGE_BODY_FORMAT" "$BODY" } test_git_log_format() {