CI Job to Generate JUnit Reports with Diff and Allure Reports #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Job to Generate JUnit Reports with Diff and Allure Reports | |
on: | |
schedule: | |
- cron: 17 0 * * * # nightly run; 17th minute to decrease odds of delayed or dropped job | |
push: | |
branches: | |
- main | |
pull_request_target: | |
branches: | |
- main | |
permissions: | |
contents: write # Grant write permissions for contents | |
checks: write # Grant write permissions for checks, only effective on push | |
pull-requests: write # Explicitly grant write permissions for pull requests | |
jobs: | |
generate-reports: | |
runs-on: ubuntu-latest | |
if: (github.repository == 'trueagi-io/metta-wam') || (github.event_name != 'schedule') | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Make Install Script Executable | |
run: chmod +x INSTALL.sh | |
- name: Run Install Script to install Mettalog | |
run: | | |
. ./INSTALL.sh --easy | |
sudo chmod -R 777 . | |
echo $PATH >> $GITHUB_PATH | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install python packages | |
run: | | |
pip install ansi2html | |
pip install hyperon | |
pip install junit2html | |
- name: Make Scripts Executable | |
run: chmod +x scripts/*.sh | |
- name: Run Test Script to Generate Input File | |
continue-on-error: true | |
run: | | |
TIMESTAMP=$(date +"%Y-%m-%dT%H:%M:%S") | |
BASELINE_COMPAT_PATH=reports/tests_output/now | |
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV | |
echo "BASELINE_COMPAT_PATH=$BASELINE_COMPAT_PATH" >> $GITHUB_ENV | |
mkdir -p $BASELINE_COMPAT_PATH | |
if [ ${{ github.event_name }} == 'schedule' ]; then | |
./scripts/run_nightly_tests.sh -t $TIMESTAMP | |
else | |
./scripts/run_commit_tests.sh -t $TIMESTAMP | |
fi | |
env: | |
TERM: xterm-256color | |
- name: Run JUnit Report Generation Script | |
continue-on-error: true | |
run: | | |
python3 scripts/into_junit.py /tmp/SHARED.UNITS ${{ env.TIMESTAMP }} 1 > junit.xml | |
- name: Convert JUnit XML to Standard HTML Report | |
continue-on-error: true | |
run: | | |
cat junit.xml | |
junit2html junit.xml ${{ env.BASELINE_COMPAT_PATH }}/junit-standard-report.html | |
- name: Convert JUnit XML to Matrix HTML Report | |
continue-on-error: true | |
run: | | |
junit2html --report-matrix ${{ env.BASELINE_COMPAT_PATH }}/junit-matrix-report.html junit.xml | |
- name: Upload JUnit XML Report | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: junit-report | |
path: junit.xml | |
- name: Upload Standard HTML Report | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: junit-standard-html-report | |
path: ${{ env.BASELINE_COMPAT_PATH }}/junit-standard-report.html | |
- name: Upload Matrix HTML Report | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: junit-matrix-html-report | |
path: ${{ env.BASELINE_COMPAT_PATH }}/junit-matrix-report.html | |
- name: Upload Test Output Log Files | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-output-logs | |
path: ${{ env.BASELINE_COMPAT_PATH }} | |
- name: Display JUnit Test Results | |
if: github.event_name == 'push' # Only run this step on pushes to main | |
uses: dorny/test-reporter@v1 | |
with: | |
name: 'JUnit Results' | |
path: 'junit.xml' | |
reporter: 'java-junit' | |
fail-on-error: false | |
- name: Provide Report Links | |
run: | | |
echo "JUnit reports are available as artifacts." | |
- name: Generate environment.properties | |
run: | | |
python scripts/generate_allure_environment.py ${{ github.sha }} ${{ github.ref_name }} > environment.properties | |
- name: Upload environment.properties | |
uses: actions/upload-artifact@v4 | |
with: | |
name: environment | |
path: environment.properties | |
- name: Get Allure history | |
uses: actions/checkout@v4 | |
with: | |
ref: test-results | |
path: test-results | |
- name: Download JUnit XML Results | |
uses: actions/download-artifact@v4 | |
with: | |
name: junit-report | |
path: build/allure-results | |
- name: Include environment properties | |
uses: actions/download-artifact@v4 | |
with: | |
name: environment | |
path: build/allure-results | |
- name: Generate Allure Report | |
uses: simple-elf/allure-report-action@master | |
if: always() | |
id: allure-report | |
with: | |
allure_results: build/allure-results | |
gh_pages: test-results | |
allure_report: allure-report | |
allure_history: allure-history | |
subfolder: ${{ env.SUBFOLDER }} | |
keep_reports: 120 | |
env: | |
SUBFOLDER: ${{ github.event_name == 'schedule' && 'nightly' || 'ci' }} | |
- name: Copy JUnit HTML Reports to GitHub Pages Directory | |
run: | | |
sudo chmod 777 . -R | |
ls -lA allure-history | |
mkdir -p allure-history/${{ env.BASELINE_COMPAT_PATH }} | |
cp -f ${{ env.BASELINE_COMPAT_PATH }}/* reports/tests_output/baseline-compat/ | |
cp -rf reports/* allure-history/reports/ | |
- name: Copy Help Docs to GitHub Pages Directory | |
run: | | |
mkdir -p allure-history/help-docs/ | |
cp -r ./docs/* allure-history/help-docs/ | |
- name: Generate Root Index for GitHub Pages | |
run: | | |
echo "<html>" > allure-history/index.html | |
echo "<head><title>Project Reports and Documentation</title></head>" >> allure-history/index.html | |
echo "<body>" >> allure-history/index.html | |
echo "<h1>Project Reports and Documentation</h1>" >> allure-history/index.html | |
echo "<ul>" >> allure-history/index.html | |
echo "<li><a href='./ci/'>Allure CI Reports</a></li>" >> allure-history/index.html | |
echo "<li><a href='./nightly/'>Allure Nightly Reports</a></li>" >> allure-history/index.html | |
echo "<li><a href='./${{ env.BASELINE_COMPAT_PATH }}/junit-standard-report.html'>JUnit Standard Report</a></li>" >> allure-history/index.html | |
echo "<li><a href='./${{ env.BASELINE_COMPAT_PATH }}/junit-matrix-report.html'>JUnit Matrix Report</a></li>" >> allure-history/index.html | |
#echo "<li><a href='./help-docs/'>Help Documentation</a></li>" >> allure-history/index.html | |
echo "</ul>" >> allure-history/index.html | |
echo "</body>" >> allure-history/index.html | |
echo "</html>" >> allure-history/index.html | |
- name: Deploy Allure reports, JUnit HTML reports, and help docs to GitHub Pages | |
if: always() | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
personal_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: test-results | |
publish_dir: allure-history | |
- name: Auto-Approve the Pull Request | |
if: github.event_name == 'pull_request_target' | |
uses: hmarr/auto-approve-action@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} |