Revert "Streamline test report packaging and uploading in test.yml: archive reports, handle missing directories, and upload to Gitea packages."
This reverts commit 0d8ee099a0.
This commit is contained in:
@@ -30,58 +30,15 @@ jobs:
|
|||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
./gradlew test --no-daemon --stacktrace
|
./gradlew test --no-daemon --stacktrace
|
||||||
|
|
||||||
- name: Package and upload test reports
|
- name: Upload test reports
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
|
if [ -d "build/reports/tests/test" ]; then
|
||||||
if [ ! -d "build/reports/tests/test" ] && [ ! -d "build/test-results/test" ]; then
|
echo "Test reports available in build/reports/tests/test"
|
||||||
echo "No test reports produced, skipping upload."
|
ls -la build/reports/tests/test || true
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
if [ -d "build/test-results/test" ]; then
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
echo "Test result XMLs:"
|
||||||
ARCHIVE="test-reports-${SHORT_SHA}.tar.gz"
|
ls -la build/test-results/test || true
|
||||||
|
|
||||||
tar -czf "$ARCHIVE" \
|
|
||||||
$( [ -d build/reports/tests/test ] && echo build/reports/tests/test ) \
|
|
||||||
$( [ -d build/test-results/test ] && echo build/test-results/test )
|
|
||||||
|
|
||||||
echo "Archive size: $(du -h "$ARCHIVE" | cut -f1)"
|
|
||||||
|
|
||||||
SERVER_URL="${{ github.server_url }}"
|
|
||||||
OWNER="${{ github.repository_owner }}"
|
|
||||||
PKG_NAME="nexusweb-test-reports"
|
|
||||||
VERSION="run-${{ github.run_number }}-${SHORT_SHA}"
|
|
||||||
|
|
||||||
UPLOAD_URL="${SERVER_URL}/api/packages/${OWNER}/generic/${PKG_NAME}/${VERSION}/${ARCHIVE}"
|
|
||||||
echo "Uploading to: ${UPLOAD_URL}"
|
|
||||||
|
|
||||||
# Delete any previous package with the same version (e.g. job re-run on same commit),
|
|
||||||
# ignore failures (404 if it does not exist yet).
|
|
||||||
curl -s -o /dev/null -w "Delete previous (if any): HTTP %{http_code}\n" \
|
|
||||||
-X DELETE \
|
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
||||||
"${UPLOAD_URL}" || true
|
|
||||||
|
|
||||||
HTTP_STATUS=$(curl -s -o /tmp/upload-response.txt -w "%{http_code}" \
|
|
||||||
-X PUT \
|
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
||||||
--data-binary @"${ARCHIVE}" \
|
|
||||||
"${UPLOAD_URL}")
|
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" = "201" ] || [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "204" ]; then
|
|
||||||
echo "Upload successful (HTTP ${HTTP_STATUS})"
|
|
||||||
echo ""
|
|
||||||
echo "Test reports available at:"
|
|
||||||
echo " ${SERVER_URL}/${OWNER}/-/packages/generic/${PKG_NAME}/${VERSION}"
|
|
||||||
echo ""
|
|
||||||
echo "Or via API:"
|
|
||||||
echo " ${UPLOAD_URL}"
|
|
||||||
else
|
|
||||||
echo "Upload failed (HTTP ${HTTP_STATUS})"
|
|
||||||
cat /tmp/upload-response.txt || true
|
|
||||||
echo ""
|
|
||||||
echo "Test reports still present locally in build/reports/tests/test/index.html"
|
|
||||||
# Do not fail the workflow over the report upload.
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user