Skip to content

Commit ea816f6

Browse files
Revert "ci(github): edit multiple executions on the allure report"
This reverts commit a5e15cd.
1 parent a5e15cd commit ea816f6

2 files changed

Lines changed: 54 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
# Best Practice: Prevent race conditions on the gh-pages branch
910
concurrency:
10-
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
11+
group: "pages"
1112
cancel-in-progress: true
1213

14+
# These permissions are required for the actions to post comments and push to the gh-pages branch
1315
permissions:
14-
contents: write
15-
pull-requests: write
16+
contents: read
17+
pages: write
18+
id-token: write
1619

1720
jobs:
18-
build-and-report:
21+
build:
1922
runs-on: ubuntu-latest
2023
steps:
2124
- name: Checkout code
@@ -32,52 +35,61 @@ jobs:
3235
- name: Install dependencies
3336
run: poetry install --no-interaction --no-ansi
3437

38+
- name: Install Allure Commandline
39+
run: |
40+
wget https://github.com/allure-framework/allure2/releases/download/2.29.0/allure-2.29.0.tgz
41+
sudo tar -zxvf allure-2.29.0.tgz -C /opt/
42+
sudo ln -s /opt/allure-2.29.0/bin/allure /usr/bin/allure
43+
allure --version
44+
3545
- name: Run CI Pipeline (Lint, Typecheck, Test)
46+
# This runs all checks and generates the raw 'allure-results'
3647
run: poetry run task ci
3748

38-
# FIX: Add this step to check out the existing gh-pages branch for history
39-
- name: Check out gh-pages branch
49+
- name: Check out gh-pages branch for history
4050
uses: actions/checkout@v4
4151
if: always()
42-
continue-on-error: true # This allows the workflow to continue if the branch doesn't exist yet
52+
continue-on-error: true
4353
with:
4454
ref: gh-pages
55+
# Checkout to a specific path
4556
path: gh-pages
4657

47-
- name: Generate Allure Report with History
48-
uses: mgrybyk-org/allure-report-branch-js-action@v1
49-
if: always()
50-
id: allure_report
51-
with:
52-
report_dir: 'test/allure-results'
53-
gh_pages: 'gh-pages' # This MUST match the 'path' in the step above
54-
max_reports: 50
58+
- name: Copy history from previous report
59+
run: |
60+
# This command enables the history trend graph in the new report
61+
cp -r gh-pages/history test/allure-results/ || echo "No history found on first run."
5562
56-
- name: Move report to root of gh-pages
57-
if: always()
63+
- name: Create CI report metadata
5864
run: |
59-
# The report is in a nested folder; find it (its name is dynamic)
60-
LATEST_REPORT_DIR=$(find gh-pages/allure-action -type d -name "*_*" | head -n 1)
61-
# Move all of its contents to the root of the gh-pages checkout
62-
mv $LATEST_REPORT_DIR/* gh-pages/
63-
64-
- name: Deploy Report to GH Pages
65-
# This step only runs on pushes to the 'main' branch
66-
if: always() && github.ref == 'refs/heads/main'
67-
uses: mgrybyk-org/git-commit-pull-push-action@v1
68-
with:
69-
repository: gh-pages # The directory with the checked-out branch
70-
branch: gh-pages # The branch to push to
71-
# This handles potential merge conflicts by favoring the new report
72-
pull_args: --rebase -X ours
73-
74-
- name: Comment on Pull Request with Report Link
75-
if: github.event_name == 'pull_request'
76-
uses: thollander/actions-comment-pull-request@v2
65+
# This creates the executor.json for clickable history links
66+
echo '{"name": "GitHub Actions", "type": "github", "buildName": "Run #${{ github.run_number }}", "buildUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", "reportUrl": "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"}' > ./test/allure-results/executor.json
67+
68+
- name: Build Allure Report
69+
# This calls your new 'report_ci' task
70+
run: poetry run task report_ci
71+
72+
- name: Set up Pages
73+
# This action prepares the artifact for deployment
74+
uses: actions/configure-pages@v5
75+
76+
- name: Upload artifact
77+
# This action uploads the report as a Pages artifact
78+
uses: actions/upload-pages-artifact@v3
7779
with:
78-
message: |
79-
${{ steps.allure_report.outputs.test_result_icon }} **Allure Test Report** is ready!
80+
path: './test/allure-report'
8081

81-
* **Report Link:** ${{ steps.allure_report.outputs.report_url }}
82-
* **History:** ${{ steps.allure_report.outputs.report_history_url }}
83-
comment_tag: allure_report
82+
# This job deploys the report
83+
deploy:
84+
# It requires the 'build' job to finish successfully
85+
needs: build
86+
# Only run this job on pushes to the main branch
87+
if: github.ref == 'refs/heads/main'
88+
runs-on: ubuntu-latest
89+
environment:
90+
name: github-pages
91+
url: ${{ steps.deployment.outputs.page_url }}
92+
steps:
93+
- name: Deploy to GitHub Pages
94+
id: deployment
95+
uses: actions/deploy-pages@v4

pyproject.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,8 @@ pre_test = "task lint && task typecheck"
134134
test = "rm -rf test/allure-results && pytest -s -x --cov=scriptize -vv --alluredir=test/allure-results"
135135
test_ci = "rm -rf test/allure-results && pytest -s --cov=scriptize -vv --alluredir=test/allure-results"
136136
# REPORTS
137-
post_test = """
138-
coverage html && \
139-
cp -r test/allure-report/history test/allure-results/ 2>/dev/null || true && \
140-
python test/generate_executor.py && \
141-
allure -q generate test/allure-results --clean -o test/allure-report && \
142-
echo 'Wrote Allure report to test/allure-report/index.html'
143-
"""
144-
report_ci = "allure -q generate test/allure-results --clean -o test/allure-report"
137+
post_test = "coverage html && cp -r test/allure-report/history test/allure-results/ 2>/dev/null || true && python -c \"import json, time; data={'name': 'Local Build', 'buildName': f'Run @ {time.strftime(\\\"%Y-%m-%d %H:%M:%S\\\")}'}; f=open('test/allure-results/executor.json', 'w'); json.dump(data, f);\" && allure -q generate test/allure-results --clean -o test/allure-report && echo 'Wrote Allure report to test/allure-reports/index.html'"
138+
report_ci = "allure generate test/allure-results --clean -o test/allure-report"
145139
cov_missing = "coverage report -m"
146140
docs = "mkdocs serve"
147141
# CI PIPELINE

0 commit comments

Comments
 (0)