Skip to content

Commit

Permalink
ci: use summary in workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
vchirikov committed Oct 24, 2022
1 parent 725ad04 commit ebbba98
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
echo -e "\033[38;5;99;5;16msha: $sha\033[0m"
echo -e "\033[38;5;99;5;16mbranch: $branch\033[0m"
echo -e "\033[38;5;99;5;16minputs.ref: ${{ inputs.ref }}\033[0m"
echo "::set-output name=sha::$sha"
echo "::set-output name=branch::$branch"
echo "sha=$sha" >> $GITHUB_OUTPUT
echo "branch=$branch" >> $GITHUB_OUTPUT
echo "::add-matcher::./.github/csc.json"
# we can use [`IGNORE_GITHUB_REF: true`](https://github.com/dotnet/nbgv/issues/50) with default dotnet/nbgv@master
Expand Down Expand Up @@ -163,11 +163,19 @@ jobs:
</details>
- name: dotnet test
shell: bash --noprofile --norc {0}
id: tests
uses: vchirikov/.github/shell-action@master
with:
commands: |-
dotnet test --nologo --no-build --filter 'FullyQualifiedName~UnitTests' --blame-hang --blame-hang-timeout 60s --logger:"github;name=unit-tests;GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }};GITHUB_SHA=${{ steps.gh.outputs.sha }}" | sed -E 's/^([[:space:]]+Failed [a-z_A-Z0-9]{3,})(.*)$/- \1\2/g' | sed -E 's/^([[:space:]]+Passed [a-z_A-Z0-9]{3,})(.*)$/+ \1\2/g'
run: |-
exec 4>&1
out=$(set -o pipefail; dotnet test --nologo --no-build --filter 'FullyQualifiedName~UnitTests' --blame-hang --blame-hang-timeout 60s --logger:"github;name=unit-tests;GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }};GITHUB_SHA=${{ steps.gh.outputs.sha }}" | sed -E 's/^([[:space:]]+Failed [a-z_A-Z0-9]{3,})(.*)$/- \1\2/g' | sed -E 's/^([[:space:]]+Passed [a-z_A-Z0-9]{3,})(.*)$/+ \1\2/g' 2>&1 | tee >(cat - >&4) ; exit ${PIPESTATUS[0]})
exit_code=$?
out="${out//'%'/'%25'}" ; out="${out//$'\n'/'%0A'}" ; out="${out//$'\r'/'%0D'}"
echo "out=$out" >> $GITHUB_OUTPUT
summary=$(cat $GITHUB_STEP_SUMMARY)
summary="${summary//'%'/'%25'}" ; summary="${summary//$'\n'/'%0A'}" ; summary="${summary//$'\r'/'%0D'}"
echo "summary=$summary" >> $GITHUB_OUTPUT
exec 4>&- || true
exit $exit_code
- name: Report tests success
if: ${{ steps.tests.outcome == 'success' }}
Expand All @@ -178,7 +186,7 @@ jobs:
message: |
✅ Running unit tests on `${{ steps.nbgv.outputs.SemVer2 }}` version was successful!
${{ fromJSON(steps.tests.outputs.dynamic).summary }}
${{ steps.tests.outputs.summary }}
`(•_•) ( •_•)>⌐■-■ (⌐■_■)`
Expand All @@ -191,7 +199,7 @@ jobs:
message: |
❌ Tests failed. `(╯°□°)╯︵ ┻━┻`
${{ fromJSON(steps.tests.outputs.dynamic).summary }}
${{ steps.tests.outputs.summary }}
<details open> <summary> Tests output </summary>
Expand Down Expand Up @@ -291,16 +299,16 @@ jobs:
git switch master && git switch -c "$merge_branch"
branch_url="https://github.com/${GITHUB_REPOSITORY}/tree/$merge_branch"
branch_url="${branch_url//'%'/'%25'}" ; branch_url="${branch_url//$'\n'/'%0A'}" ; branch_url="${branch_url//$'\r'/'%0D'}"
echo "::set-output name=branch_url::$branch_url"
echo "branch_url=$branch_url" >> $GITHUB_OUTPUT
exec 4>&1
git_merge=$(set -o pipefail; git merge --commit --stat --no-progress --no-edit origin/${{ steps.gh.outputs.branch }} 2>&1 | tee >(cat - >&4) ; exit ${PIPESTATUS[0]}) || ( git merge --quit && git add . && git commit -m "Merge ${{ steps.gh.outputs.branch }} with conflicts. [skip ci]" )
git push origin "$merge_branch"
pr_url=$(set -o pipefail; gh pr create --fill --reviewer "${{ github.actor }}" | grep '^https://github.com/' 2>&1 | tee >(cat - >&4) ; exit ${PIPESTATUS[0]})
gh pr edit "$pr_url" --title "[$date] Auto-merge '${{ steps.gh.outputs.branch }}' / $sha_compact"
pr_url="${pr_url//'%'/'%25'}" ; pr_url="${pr_url//$'\n'/'%0A'}" ; pr_url="${pr_url//$'\r'/'%0D'}"
git_merge="${git_merge//'%'/'%25'}" ; git_merge="${git_merge//$'\n'/'%0A'}" ; git_merge="${git_merge//$'\r'/'%0D'}"
echo "::set-output name=pr_url::$pr_url"
echo "::set-output name=git_merge::$git_merge"
echo "pr_url=$pr_url" >> $GITHUB_OUTPUT
echo "git_merge=$git_merge" >> $GITHUB_OUTPUT
exec 4>&- || true
- name: Approve PR
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ jobs:
sha=$(git rev-parse HEAD)
echo "GITHUB_SHA=$sha" >> $GITHUB_ENV
echo "GITHUB_SHA=$sha" >> .env
branch=$(git rev-parse --abbrev-ref HEAD)
branch=$(git rev-parse --abbrev-ref HEAD)``
echo "GITHUB_REF=refs/heads/$branch" >> $GITHUB_ENV
echo "GITHUB_REF=refs/heads/$branch" >> .env
echo -e "\033[38;5;99;5;16msha: $sha\033[0m"
echo -e "\033[38;5;99;5;16mbranch: $branch\033[0m"
echo -e "\033[38;5;99;5;16minputs.ref: ${{ inputs.ref }}\033[0m"
echo "::set-output name=sha::$sha"
echo "::set-output name=branch::$branch"
echo "sha=$sha" >> $GITHUB_OUTPUT
echo "branch=$branch" >> $GITHUB_OUTPUT
echo "::add-matcher::./.github/csc.json"
# we can use [`IGNORE_GITHUB_REF: true`](https://github.com/dotnet/nbgv/issues/50) with default dotnet/nbgv@master
Expand Down Expand Up @@ -149,11 +149,19 @@ jobs:
</details>
- name: dotnet test
shell: bash --noprofile --norc {0}
id: tests
uses: vchirikov/.github/shell-action@master
with:
commands: |-
dotnet test --nologo --no-build --filter 'FullyQualifiedName~UnitTests' --blame-hang --blame-hang-timeout 60s --logger:"github;name=unit-tests;GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }};GITHUB_SHA=${{ steps.gh.outputs.sha }}" | sed -E 's/^([[:space:]]+Failed [a-z_A-Z0-9]{3,})(.*)$/- \1\2/g' | sed -E 's/^([[:space:]]+Passed [a-z_A-Z0-9]{3,})(.*)$/+ \1\2/g'
run: |-
exec 4>&1
out=$(set -o pipefail; dotnet test --nologo --no-build --filter 'FullyQualifiedName~UnitTests' --blame-hang --blame-hang-timeout 60s --logger:"github;name=unit-tests;GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }};GITHUB_SHA=${{ steps.gh.outputs.sha }}" | sed -E 's/^([[:space:]]+Failed [a-z_A-Z0-9]{3,})(.*)$/- \1\2/g' | sed -E 's/^([[:space:]]+Passed [a-z_A-Z0-9]{3,})(.*)$/+ \1\2/g' 2>&1 | tee >(cat - >&4) ; exit ${PIPESTATUS[0]})
exit_code=$?
out="${out//'%'/'%25'}" ; out="${out//$'\n'/'%0A'}" ; out="${out//$'\r'/'%0D'}"
echo "out=$out" >> $GITHUB_OUTPUT
summary=$(cat $GITHUB_STEP_SUMMARY)
summary="${summary//'%'/'%25'}" ; summary="${summary//$'\n'/'%0A'}" ; summary="${summary//$'\r'/'%0D'}"
echo "summary=$summary" >> $GITHUB_OUTPUT
exec 4>&- || true
exit $exit_code
- name: Report tests success
if: ${{ steps.tests.outcome == 'success' }}
Expand All @@ -164,7 +172,7 @@ jobs:
message: |
✅ Running unit tests on `${{ steps.nbgv.outputs.SemVer2 }}` version was successful!
${{ fromJSON(steps.tests.outputs.dynamic).summary }}
${{ steps.tests.outputs.summary }}
`(•_•) ( •_•)>⌐■-■ (⌐■_■)`
Expand All @@ -177,7 +185,7 @@ jobs:
message: |
❌ Tests failed. `(╯°□°)╯︵ ┻━┻`
${{ fromJSON(steps.tests.outputs.dynamic).summary }}
${{ steps.tests.outputs.summary }}
<details open> <summary> Tests output </summary>
Expand Down

0 comments on commit ebbba98

Please sign in to comment.