Skip to content

ci(github): add a new step in the pipeline #17

ci(github): add a new step in the pipeline

ci(github): add a new step in the pipeline #17

Workflow file for this run

name: CI & Test Report
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Best Practice: Prevent race conditions on the gh-pages branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# These permissions are required for the actions to post comments and push to the gh-pages branch
permissions:
contents: write
pull-requests: write
jobs:
build-and-report:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install Poetry
run: pipx install poetry
- name: Install dependencies
run: poetry install --no-interaction --no-ansi
- name: Run CI Pipeline (Lint, Typecheck, Test)
# This runs all checks and generates the raw 'allure-results'
run: poetry run task ci
- name: Check out gh-pages branch
uses: actions/checkout@v4
if: always()
continue-on-error: true # This allows the workflow to continue if the branch doesn't exist yet
with:
ref: gh-pages
path: gh-pages
- name: Generate Allure Report with History
uses: mgrybyk-org/allure-report-branch-js-action@v1
# This is crucial: The report should be generated even if tests fail
if: always()
# Give the step an ID so we can reference its outputs later
id: allure_report
with:
# The folder where raw Allure results are stored
report_dir: 'test/allure/results'
gh_pages: 'gh-pages'
- name: Commit and Push Report
uses: mgrybyk-org/git-commit-pull-push-action@v1
if: always() && github.ref == 'refs/heads/main' # Only push on merge to main
with:
repository: gh-pages # The directory with the checked-out branch
branch: gh-pages # The branch to push to
# This handles potential merge conflicts by favoring the new report
pull_args: --rebase -X ours
- name: Comment on Pull Request with Report Link
# Only run this step for pull request events
if: github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
# Use the outputs from the previous step to build a nice message
message: |
${{ steps.allure_report.outputs.test_result_icon }} **Allure Test Report** is ready!
* **Report Link:** ${{ steps.allure_report.outputs.report_url }}
* **History:** ${{ steps.allure_report.outputs.report_history_url }}
# This tag allows the action to update its own comment instead of creating new ones
comment_tag: allure_report