From 0a5dac2f71380e57f77b27acf23db70a158ebb78 Mon Sep 17 00:00:00 2001 From: Luke Arms Date: Tue, 7 Jan 2025 20:20:49 +1100 Subject: [PATCH] Report changes to output vs. latest release in CI integration tests --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb1d39c..dac9bd87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -344,10 +344,39 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ needs.build.outputs.artifact_name }} + path: ~ - name: Run pretty-php + id: run-pretty-php env: artifact_path: ${{ needs.build.outputs.artifact_path }} + repository: ${{ matrix.repository }} run: | - php "$artifact_path" --print-config ${{ matrix.args }} | tee .prettyphp - php "$artifact_path" --quiet --timers || { status=$? && [[ $status -eq 4 ]] || (exit $status); } + php ~/"$artifact_path" --print-config ${{ matrix.args }} | tee .prettyphp + php ~/"$artifact_path" --quiet --timers || + { status=$? && [[ $status -eq 4 ]] || (exit $status); } + + printf '\nComparing with output from latest release\n\n' + latest_path=~/pretty-php-latest.phar + diff_path=~/${repository%/*}.diff + : >"$diff_path" + + shopt -s extglob + + curl -fLo "$latest_path" https://github.com/lkrms/pretty-php/releases/latest/download/pretty-php.phar && + git add !(.prettyphp) && + git restore -s HEAD . && + { php "$latest_path" --quiet --timers || + { status=$? && [[ $status -eq 4 ]] || (exit $status); }; } && + git diff -R --exit-code | tee "$diff_path" && + printf '\nNo differences found\n' || true + + printf 'diff_name=%s\n' "${diff_path##*/}" >>"$GITHUB_OUTPUT" + printf 'diff_path=%s\n' "$([[ ! -s $diff_path ]] || printf '%s\n' "$diff_path")" >>"$GITHUB_OUTPUT" + + - name: Upload diff artifact + if: ${{ !cancelled() && !failure() && steps.run-pretty-php.outputs.diff_path != '' }} + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.run-pretty-php.outputs.diff_name }} + path: ${{ steps.run-pretty-php.outputs.diff_path }}