From b965138078209ff055bb96853c477c5d594865f2 Mon Sep 17 00:00:00 2001 From: TeamSPoon Date: Sat, 17 Aug 2024 17:55:47 -0700 Subject: [PATCH] Towards Feature Request: Include Historical Data in Allure Reports with Commit References https://github.com/trueagi-io/metta-wam/issues/89 --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b70a5e2f36a..d19fed4a674 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,16 @@ jobs: - name: Make Shell Script Executable run: chmod +x scripts/run_commit_tests.sh + - name: Download Historical JUnit Reports + uses: actions/download-artifact@v4 + with: + name: junit-history + path: ./history + + - name: Unzip Historical Reports + run: | + unzip -o ./history/junit-history.zip -d ./allure-results + - name: Run Shell Script to Generate Input File continue-on-error: true run: | @@ -43,22 +53,33 @@ jobs: run: | python scripts/into_junit.py /tmp/SHARED.UNITS > junit.xml + - name: Store JUnit Report with Timestamp and Metadata + run: | + TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S') + COMMIT_SHA=$(git rev-parse HEAD) + BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) + mv junit.xml junit-${TIMESTAMP}.xml + echo "Commit SHA: ${COMMIT_SHA}" > ./allure-results/environment-${TIMESTAMP}.properties + echo "Branch: ${BRANCH_NAME}" >> ./allure-results/environment-${TIMESTAMP}.properties + cp junit-${TIMESTAMP}.xml ./allure-results/ + cp ./allure-results/environment-${TIMESTAMP}.properties ./allure-results/environment.properties + - name: Convert JUnit XML to Standard HTML Report continue-on-error: true run: | - junit2html junit.xml junit-standard-report.html + junit2html junit-${TIMESTAMP}.xml junit-standard-report.html - name: Convert JUnit XML to Matrix HTML Report continue-on-error: true run: | - junit2html --report-matrix junit-matrix-report.html junit.xml + junit2html --report-matrix junit-matrix-report.html junit-${TIMESTAMP}.xml - name: Upload JUnit XML Report continue-on-error: true uses: actions/upload-artifact@v4 with: name: junit-report - path: junit.xml + path: junit-${TIMESTAMP}.xml - name: Upload Standard HTML Report continue-on-error: true @@ -79,24 +100,17 @@ jobs: uses: dorny/test-reporter@v1 with: name: 'JUnit Results' - path: 'junit.xml' + path: junit-${TIMESTAMP}.xml reporter: 'java-junit' fail-on-error: false - - name: Download Previous JUnit Results - continue-on-error: true - uses: actions/download-artifact@v4 - with: - name: junit-report - path: previous-junit.xml - - name: Install ReportGenerator run: | dotnet tool install -g dotnet-reportgenerator-globaltool - name: Compare JUnit Test Results with ReportGenerator run: | - reportgenerator -reports:"previous-junit.xml;junit.xml" -targetdir:"./comparison-report" -reporttypes:"HtmlSummary;HtmlChart" + reportgenerator -reports:"./allure-results/*.xml" -targetdir:"./comparison-report" -reporttypes:"HtmlSummary;HtmlChart" - name: Upload JUnit Comparison Report continue-on-error: true @@ -115,12 +129,12 @@ jobs: - name: Prepare Allure Results Directory run: | mkdir -p ./allure-results - cp junit.xml ./allure-results/ - if [ -f "previous-junit.xml" ]; then - cp previous-junit.xml ./allure-results/ + cp junit-${TIMESTAMP}.xml ./allure-results/ + if [ -f "./allure-results/previous-junit.xml" ]; then + cp ./allure-results/previous-junit.xml ./allure-results/ fi - - name: Generate Allure Report + - name: Generate Allure Report with Full History run: | allure generate --clean --output ./allure-report ./allure-results @@ -131,6 +145,16 @@ jobs: name: allure-html-report path: ./allure-report + - name: Zip and Update Historical JUnit Reports with Metadata + run: | + zip -r junit-history.zip ./allure-results/*.xml ./allure-results/environment-*.properties + + - name: Upload Updated JUnit History + uses: actions/upload-artifact@v4 + with: + name: junit-history + path: junit-history.zip + - name: Provide Report Links run: | echo "JUnit reports, Allure report, and test comparison reports are available as artifacts." @@ -143,7 +167,7 @@ jobs: - name: Setup Pages uses: actions/configure-pages@v4 - + - name: Upload Allure Report as Pages Artifact uses: actions/upload-pages-artifact@v3 with: @@ -165,4 +189,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v4