Skip to content

test

test #28

name: Integration Test
on: [push]
jobs:
first-test:
name: Test Calculator
uses: swetha1654/allure-simple/.github/workflows/main.yaml@calc
with:
module-name: test_calculator
second-test:
name: Test Utils
needs: [first-test]
uses: swetha1654/allure-simple/.github/workflows/main.yaml@calc
with:
module-name: test_utils
allure-report:
# TODO future improvement: use concurrency group for job
name: (beta) Publish Allure report
if: always()
needs:
- first-test
- second-test
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Download Allure
# Following instructions from https://allurereport.org/docs/gettingstarted-installation/#install-via-the-system-package-manager-for-linux
run: gh release download --repo allure-framework/allure2 --pattern 'allure_*.deb'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Allure
run: |
sudo apt-get update
sudo apt-get install ./allure_*.deb -y
# For first run, manually create branch with no history
# (e.g.
# git checkout --orphan gh-pages-beta
# git rm -rf .
# touch .nojekyll
# git add .nojekyll
# git commit -m "Initial commit"
# git push origin gh-pages-beta
# )
- name: Checkout GitHub pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
path: repo/
- name: Download default test results
uses: actions/download-artifact@v4
with:
path: allure-collection-default-results/
pattern: allure-default-results*
merge-multiple: true
- name: Download actual test results
uses: actions/download-artifact@v4
with:
path: allure-results/
pattern: allure-results*
merge-multiple: true
- name: Install CLI
run: pipx install git+https://github.com/swetha1654/allure-simple@calc#subdirectory=python/cli
- name: Combine Allure default results & actual results
# For every test: if actual result available, use that. Otherwise, use default result
# So that, if actual result not available, Allure report will show "unknown"/"failed" test result
# instead of omitting the test
run: allure-add-default-for-missing-results --allure-results-dir=allure-results --allure-collection-default-results-dir=allure-collection-default-results
- name: Load test report history
run: |
if [[ -d repo/_latest/history/ ]]
then
echo 'Loading history'
cp -r repo/_latest/history/ allure-results/
fi
- name: Create executor.json
shell: python
run: |
# Reverse engineered from https://github.com/simple-elf/allure-report-action/blob/eca283b643d577c69b8e4f048dd6cd8eb8457cfd/entrypoint.sh
import json
DATA = {
"name": "GitHub Actions",
"type": "github",
"buildOrder": ${{ github.run_number }}, # TODO future improvement: use run ID
"buildName": "Run ${{ github.run_id }}",
"buildUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"reportUrl": "../${{ github.run_number }}/",
}
with open("allure-results/executor.json", "w") as file:
json.dump(DATA, file)
- name: Generate Allure report
run: allure generate
- name: Create index.html
shell: python
run: |
DATA = f"""<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="refresh" content="0; url=${{ github.run_number }}">
"""
with open("repo/index.html", "w") as file:
file.write(DATA)
- name: Update GitHub pages branch
working-directory: repo/
# TODO future improvement: commit message
run: |
mkdir '${{ github.run_number }}'
rm -f _latest
ln -s '${{ github.run_number }}' _latest
cp -r ../allure-report/. _latest/
git add .
git config user.name "GitHub Actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Allure report ${{ github.run_number }}"
# Uses token set in checkout step
git push origin gh-pages