Repository navigation
113 lines (107 loc) · 4.11 KB
/
Copy pathpr.yml
File metadata and controls
113 lines (107 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Pull Request Tests
on:
pull_request:
branches: [ main ]
paths:
- "**/*.py"
- "**/*.toml"
- "**/*.lock"
- ".github/workflows/pr.yml"
env:
FLAKINESS_PROJECT: nirtal85/Selenium-Python-Example
permissions:
contents: read
jobs:
merge_test:
timeout-minutes: 15
runs-on: ubuntu-latest
outputs:
artifact_url: ${{ steps.allure_artifact.outputs.artifact-url }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.15"
- name: Set up uv
uses: astral-sh/setup-uv@v10.3.3
with:
enable-cache: true
- name: Install dependencies
run: uv sync --locked --all-extras --dev
- name: Ruff check
run: uv run ruff check .
- name: Ruff format check
run: uv run ruff format --check .
- name: Test with pytest
env:
BASE_URL: ${{ vars.BASE_URL }}
run: xvfb-run uv run pytest -m devRun --base-url "$BASE_URL"
- name: Link Git Information And Browser Version To Allure Results
if: always()
working-directory: allure-results
env:
BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
GIT_COMMIT_ID: ${{ github.sha }}
run: |
{
printf 'BUILD_URL=%s\n' "$BUILD_URL"
printf 'GIT_BRANCH=%s\n' "$GIT_BRANCH"
printf 'GIT_COMMIT_ID=%s\n' "$GIT_COMMIT_ID"
printf 'GIT_COMMIT_MESSAGE=%s\n' "$(git show -s --format=%s HEAD)"
printf 'GIT_COMMIT_AUTHOR_NAME=%s\n' "$(git show -s --format='%ae' HEAD)"
printf 'GIT_COMMIT_TIME=%s\n' "$(git show -s --format=%ci HEAD)"
printf 'CHROME_VERSION=%s\n' "$(google-chrome --product-version 2>/dev/null || true)"
} >> environment.properties
- name: Generate Allure HTML report (Allure 3 CLI via npx)
if: always()
run: npx -y allure generate allure-results --output allure-report
- name: Upload report artifact
if: always()
id: allure_artifact
uses: actions/upload-artifact@v7
with:
name: allure-report
path: allure-report
- name: Link report in job summary
if: always() && steps.allure_artifact.outputs.artifact-url != ''
env:
ARTIFACT_URL: ${{ steps.allure_artifact.outputs.artifact-url }}
run: printf '[Download Allure report](%s)\n' "$ARTIFACT_URL" >> "$GITHUB_STEP_SUMMARY"
assign_reviewers:
needs: merge_test
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v7
- name: Auto-assign reviewers
uses: kentaro-m/auto-assign-action@v2.0.2
report_link:
needs: merge_test
if: always() && needs.merge_test.outputs.artifact_url != '' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Publish report link on pull request
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
ARTIFACT_URL: ${{ needs.merge_test.outputs.artifact_url }}
run: |
marker='<!-- allure-report-artifact -->'
body=$(printf '%s\n[Download Allure report](%s)' "$marker" "$ARTIFACT_URL")
comments_url="repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments"
comment_id=$(gh api --paginate "$comments_url" --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("<!-- allure-report-artifact -->"))) | .id' | head -n 1)
if [ -n "$comment_id" ]; then
gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" -f "body=$body" > /dev/null
else
gh api --method POST "$comments_url" -f "body=$body" > /dev/null
fi