Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 45 additions & 27 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ env:

permissions:
contents: read
pull-requests: write
checks: write
pages: write
id-token: write

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
Expand All @@ -41,13 +42,8 @@ jobs:
run: uv run ruff format --check .
- name: Test with pytest
env:
EMAIL: ${{ secrets.EMAIL }}
PASSWORD: ${{ secrets.PASSWORD }}
BASE_URL: ${{ vars.BASE_URL }}
run: xvfb-run uv run pytest -m devRun --base-url "$BASE_URL"
- name: Auto-assign reviewers
uses: kentaro-m/auto-assign-action@v2.0.2
if: success()
- name: Link Git Information And Browser Version To Allure Results
if: always()
working-directory: allure-results
Expand All @@ -68,28 +64,50 @@ jobs:
- name: Generate Allure HTML report (Allure 3 CLI via npx)
if: always()
run: npx -y allure generate allure-results --output allure-report
- name: Allure PR summary
if: always()
uses: allure-framework/allure-action@v0.12.0
with:
report-directory: "./allure-report"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Pages artifact
- name: Upload report artifact
if: always()
uses: actions/upload-pages-artifact@v5
id: allure_artifact
uses: actions/upload-artifact@v7
with:
name: allure-report
path: allure-report
deploy_pages:
- 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: always()
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
contents: read
pull-requests: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- 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
110 changes: 55 additions & 55 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-xml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: no-commit-to-branch
args: ['--branch', 'main']
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.39.0
hooks:
- id: check-github-workflows
args: ["--verbose"]
- id: check-renovate
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.5.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.3
hooks:
- id: ruff
args: [ --fix ]
continue_on_error: true
- id: ruff-format
continue_on_error: true
- repo: https://github.com/codespell-project/codespell
rev: v2.4.3
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.27
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.16.0
hooks:
- id: pretty-format-toml
exclude: poetry.lock
args: [--autofix]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-xml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: no-commit-to-branch
args: ['--branch', 'main']
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.39.0
hooks:
- id: check-github-workflows
args: ["--verbose"]
- id: check-renovate
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.5.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.4
hooks:
- id: ruff
args: [ --fix ]
continue_on_error: true
- id: ruff-format
continue_on_error: true
- repo: https://github.com/codespell-project/codespell
rev: v2.4.3
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.27
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.16.0
hooks:
- id: pretty-format-toml
exclude: poetry.lock
args: [--autofix]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ We use Allure for reporting. To generate and open the report locally:
npx -y allure generate allure-results --output allure-report --open
```

For a pull request, download and extract the `allure-report` artifact from the
workflow run. Serve the extracted directory over HTTP rather than opening its
`index.html` directly:

```bash
npx -y allure open <extracted-report-directory>
```

👉 [See a Live Example of the Report Here](https://nirtal85.github.io/Selenium-Python-Example/)

---
Expand Down
166 changes: 83 additions & 83 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
[dependency-groups]
dev = [
"ruff==0.17.3",
"pre-commit==4.7.0",
"pytest-flakiness==1.2.0",
]

[project]
name = "selenium-python-example"
description = "Selenium Python example project with pytest and Allure report"
version = "0.1.0"
readme = "README.md"
license = "MIT"
authors = [{ name = "Nir Tal" }]
dependencies = [
"allure-pytest==2.16.2",
"assertpy==2.35.0",
"dataclasses-json==0.6.7",
# Deprecated 3 requires Python 3.12; retain support for Python 3.11.
"deprecated==1.3.1; python_version < '3.12'",
"deprecated==3.0.1; python_version >= '3.12'",
"mailinator-python-client-2==1.0.9",
"mysql-connector-python==26.10.0",
"pytest==9.2.0",
"pytest-base-url==2.1.0",
"pytest-check==3.0.3",
"pytest-dependency==0.6.1",
"pytest-ordering==0.6",
"pytest-rerunfailures==16.7",
"pytest-split==0.11.0",
"python-dotenv==1.2.4",
"requests==2.34.2",
"requests-toolbelt==1.0.0",
"selenium==4.52.0",
"tenacity==9.2.1",
"visual-regression-tracker==5.1.0",
"xlrd==2.0.2"
]
requires-python = "~=3.11"

[tool.pytest.ini_options]
pythonpath = ["src"]
addopts = [
"--clean-alluredir",
"--alluredir=allure-results",
"--allure-link-pattern",
"issue:https://{}",
"--allure-link-pattern",
"link:https://{}",
"--allure-link-pattern",
"tms:https://{}",
"--color=yes",
"-s",
"-p no:logging"
]
base_url = 'https://www.involve.me/'
markers = [
"security: marks security tests",
"devRun: marks tests that run before merge to the main branch",
"flaky: marks tests that may be rerun",
"run: marks ordered test execution",
"sanity: marks sanity tests"
]
testpaths = [
"tests"
]

[tool.ruff]
exclude = [".venv", "env"]
line-length = 100
target-version = "py311"

[tool.ruff.lint]
ignore = [
"D203", # One blank line required before class docstring (conflicts with D211)
"D213", # Multi-line docstring summary should start at the second line
"COM812"
]
select = ["E", "F", "B", "I", "UP", "SIM", "PT"]

[tool.ruff.format]
docstring-code-format = true
quote-style = "double"
[dependency-groups]
dev = [
"ruff==0.17.4",
"pre-commit==4.7.0",
"pytest-flakiness==1.2.0",
]
[project]
name = "selenium-python-example"
description = "Selenium Python example project with pytest and Allure report"
version = "0.1.0"
readme = "README.md"
license = "MIT"
authors = [{ name = "Nir Tal" }]
dependencies = [
"allure-pytest==2.16.2",
"assertpy==2.36.0",
"dataclasses-json==0.6.7",
# Deprecated 3 requires Python 3.12; retain support for Python 3.11.
"deprecated==1.3.1; python_version < '3.12'",
"deprecated==3.0.1; python_version >= '3.12'",
"mailinator-python-client-2==1.0.9",
"mysql-connector-python==26.10.0",
"pytest==9.2.0",
"pytest-base-url==2.1.0",
"pytest-check==3.0.3",
"pytest-dependency==0.6.1",
"pytest-ordering==0.6",
"pytest-rerunfailures==16.7",
"pytest-split==0.11.0",
"python-dotenv==1.2.4",
"requests==2.34.2",
"requests-toolbelt==1.0.0",
"selenium==4.52.0",
"tenacity==9.2.1",
"visual-regression-tracker==5.1.0",
"xlrd==2.0.2"
]
requires-python = ">=3.11,<4"
[tool.pytest.ini_options]
pythonpath = ["src"]
addopts = [
"--clean-alluredir",
"--alluredir=allure-results",
"--allure-link-pattern",
"issue:https://{}",
"--allure-link-pattern",
"link:https://{}",
"--allure-link-pattern",
"tms:https://{}",
"--color=yes",
"-s",
"-p no:logging"
]
base_url = 'https://www.involve.me/'
markers = [
"security: marks security tests",
"devRun: marks tests that run before merge to the main branch",
"flaky: marks tests that may be rerun",
"run: marks ordered test execution",
"sanity: marks sanity tests"
]
testpaths = [
"tests"
]
[tool.ruff]
exclude = [".venv", "env"]
line-length = 100
target-version = "py311"
[tool.ruff.lint]
ignore = [
"D203", # One blank line required before class docstring (conflicts with D211)
"D213", # Multi-line docstring summary should start at the second line
"COM812"
]
select = ["E", "F", "B", "I", "UP", "SIM", "PT"]
[tool.ruff.format]
docstring-code-format = true
quote-style = "double"
Loading
Loading