Skip to content

Commit 0a2cfb0

Browse files
fix filepaths, readme
1 parent 1c86eae commit 0a2cfb0

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Playwright Python Blueprint
22

3-
[![CI/CD Pull Request](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml/badge.svg)](https://github.com/nhs-england-tools/playwright-python-blueprint/actions/workflows/cicd-1-pull-request.yaml)
3+
[![CI/CD Pull Request](https://github.com/nhs-england-tools/playwright-python-blueprint/actions/workflows/cicd-1-pull-request.yaml/badge.svg)](https://github.com/nhs-england-tools/playwright-python-blueprint/actions/workflows/cicd-1-pull-request.yaml)
44

55
This project is designed to provide a blueprint to allow for development teams to start quickly developing UI tests using [Playwright Python](https://playwright.dev/python/), providing the base framework and utilities to allow for initial focus on writing tests, rather than configuration of the framework itself. Playwright is the current mainstream UI testing tool for NHS England, as outlined on the [NHS England Tech Radar](https://radar.engineering.england.nhs.uk/).
66

@@ -16,6 +16,7 @@ This project is designed to provide a blueprint to allow for development teams t
1616
- [Getting Started](#getting-started)
1717
- [Utilities](#utilities)
1818
- [Using Environment Variables For Secrets](#using-environment-variables-for-secrets)
19+
- [Using the Jira Upload Script](#using-the-jira-upload-script)
1920
- [Contributing](#contributing)
2021
- [Contacts](#contacts)
2122
- [Licence](#licence)
@@ -111,6 +112,56 @@ The local.env file is set in the [.gitignore file](./.gitignore), so by default
111112

112113
> NOTE: You should never commit this file or any secrets in the codebase directly.
113114
115+
## Using the Jira Upload Script
116+
117+
Included with this code is a Jira Upload utility that will allow for the uploading of artifacts from test runs to
118+
a Jira ticket directly. The script itself ([`jira_upload.py`](jira_upload.py)) can be invoked using the following
119+
command:
120+
121+
```shell
122+
python jira_upload.py
123+
```
124+
125+
For this to work, you need to set the follow environment variables (which you can do via local.env):
126+
127+
| Key | Required | Description |
128+
| --------------------- | -------- | ------------------------------------------------------------------------------------------------------ |
129+
| JIRA_URL | Yes | The Jira instance url to connect to |
130+
| JIRA_PROJECT_KEY | Yes | The project key for the Jira project to upload to |
131+
| JIRA_API_KEY | Yes | The Jira API key for your user, which can be generated in Jira via Profile > Personal Access Tokens |
132+
| JIRA_TICKET_REFERENCE | No | The Jira ticket you want to default to, if required. Can be left blank to use branch-based referencing |
133+
134+
This command will do the following actions:
135+
136+
1. Work out the Jira ticket to upload to and confirm it is a valid reference, by using the following logic:
137+
1. If a `--jira-ref` value has been provided, use that value.
138+
2. If a `JIRA_TICKET_REFERENCE` environment variable exists, use that value.
139+
3. If none of the above, check if you are in a feature branch and if so, compiles the Jira ticket reference by combining the project key and the end of the feature branch (when in the format `feature/<shortcode>-<jira_ticket_number>`).
140+
2. Check the `test-results/` directory (or custom directory if specified) for appropriate files under 10MB (Jira's file limit), specifically:
141+
1. HTML files (e.g. `report.html` generated by `pytest`).
142+
2. Trace Files (e.g. `test_name/trace.zip` generated by Playwright).
143+
3. Screenshots (e.g. `test_screenshot.png` generated by Playwright).
144+
4. CSV Files (e.g. `results.csv` generated during test execution from the UI).
145+
3. Prompt the user to confirm that they are updating the correct ticket and the correct files are being uploaded. If files already exist on the ticket with a matching name, a unique name will be provided unless `--overwrite-files` is provided.
146+
4. If `y` is selected, upload the files and add a comment (unless `--no-comment` is provided) to Jira outlining the files uploaded and if possible, the environment information from the test run (unless `--no-env-data` is provided).
147+
148+
You can also pass in the following arguments which will have the noted effects:
149+
150+
| Argument | Description |
151+
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
152+
| `--jira-ref <Jira Reference>` | The Jira ticket to upload to. Will take precedence over auto-deriving from branch name and the set environment variable. |
153+
| `--results-dir <Directory>` | The directory to point to. If not set, points to `test-results/` (the default directory for test results in this repository). |
154+
| `--no-html` | Don't include HTML files in the upload. |
155+
| `--no-trace` | Don't include Trace files (.zip) in the upload. |
156+
| `--no-csv` | Don't include CSV files in the upload. |
157+
| `--no-screenshots` | Don't include screenshots (.png) in the upload. |
158+
| `--no-comment` | Don't add a Jira comment highlighting the results. |
159+
| `--no-env-data` | Don't include environment data in the Jira comment (if getting environment data has been configured). |
160+
| `--overwrite-files` | If a filename exists on the ticket that matches those in the results directory, overwrite them. |
161+
| `--auto-confirm` | Will not ask if you want to proceed if provided, and will assume that yes has been pressed. |
162+
163+
Further information on the available actions for this logic can be found in the [Jira Confluence Utility utility guide](./docs/utility-guides/JiraConfluenceUtil.md).
164+
114165
## Contributing
115166

116167
Further guidance on contributing to this project can be found in our [contribution](./CONTRIBUTING.md) page.

utils/jira_confluence_util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import os
22
import re
33
import shutil
4-
import json
54
from atlassian import Jira, Confluence
65
from pathlib import Path
76
from dotenv import load_dotenv
87
from git import Repo
98
from datetime import datetime
109

1110
# Paths to file locations in this project
12-
ROOT_DIR = Path(__file__).resolve().parent.parent.parent.parent
13-
LOCAL_ENV_PATH = Path(__file__).resolve().parent.parent.joinpath("local.env")
14-
RESULTS_DIR = Path(__file__).resolve().parent.parent.joinpath("test-results")
11+
ROOT_DIR = Path(__file__).resolve().parent.parent
12+
LOCAL_ENV_PATH = ROOT_DIR.joinpath("local.env")
13+
RESULTS_DIR = ROOT_DIR.joinpath("test-results")
1514

1615

1716
class JiraConfluenceUtil:

0 commit comments

Comments
 (0)