Skip to content

Commit 83003e7

Browse files
committed
revised docs and shadow report env names, breaking change
1 parent b1e0f63 commit 83003e7

File tree

4 files changed

+82
-36
lines changed

4 files changed

+82
-36
lines changed

README.md

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ Our package bridges Cypress and Playwright test runs with Google Sheets or CSV,
3232

3333
After installing `qa-shadow-report` using the command:
3434

35-
`npm i qa-shadow-report`
35+
npm i qa-shadow-report
3636

3737
you will then need to run the command:
3838

39-
`npx qasr-setup`
39+
npx qasr-setup
4040

4141
this initiates a series of `Yes` or `No` questions to guide you through setting up the tool for your testing framework and package manager. You may choose to exit the setup at any time by entering `EXIT`, which is not recommended. If you exit setup, you will then need to restart using the command `npx qasr-setup`
4242

@@ -105,15 +105,15 @@ Before you begin, ensure you have the following packages and authentication. You
105105

106106
`npm install --save-dev mochawesome mochawesome-merge`
107107

108-
- **Google Spreadsheet ID:** Place the sheet's URL directly in an environment variable: `https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160`.
108+
- **Google Spreadsheet URL:** Place the sheet's URL directly in an environment variable: `https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160`.
109109
- **Service Account Credentials for Google Sheets:** Follow the detailed guide from `node-google-spreadsheet` they have a great document describing Google Service Accounts [node-google-spreadshee: Google Service Account](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication?id=authentication-methods)
110-
to set up and safely store your credentials, updating `shadowReportConfig.*` (`js`, or `ts`) with the path to these credentials. Use `.gitignore` to secure your credentials within your project.
110+
to set up and safely store your credentials. update `shadowReportConfig.*` (`js`, or `ts`) with the path to these credentials. Use `.gitignore` to secure your credentials within your project. Allow your service account to Edit the Google Sheet by sharing the google sheet with the service account emial address as an Editor.
111111
- **qa-shadow-report configuration file:** Usually installed by the setup wizard in the root of your Cypress project, named: `shadowReportConfig.*` (`js`, or `ts`).
112112

113113
- `teamNames`: An array of identifiers representing different teams within your organization that may use or contribute to the testing process.
114114
- `testTypes`: Specifies the types of tests included in your project, such as API tests or UI tests, to help organize and filter test executions.
115115
- `testCategories`: Defines the categories of tests your project includes, such as smoke tests for quick checks or sanity tests for verifying vital features after builds.
116-
- `googleSpreadsheetId`: The unique identifier for your Google Sheets project, found within the URL of your Google Sheet. This is used to integrate and sync test result data.
116+
- `googleSpreadsheetUrl`: The URL of your Google Sheet. This is used to integrate and sync test result data.
117117
- `googleKeyFilePath`: The file path to your Google service account credentials, which are required to authenticate and interact with Google Sheets API.
118118
- `testData`: The file path to where your test results in JSON format are stored, typically generated by Cypress or another testing framework.
119119
- `csvDownloadsPath`: The directory path where the generated CSV files will be saved. This is useful for users who prefer to download and review test results in a CSV format.
@@ -132,7 +132,7 @@ Before you begin, ensure you have the following packages and authentication. You
132132
'smoke',
133133
'sanity',
134134
],
135-
googleSpreadsheetId: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
135+
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
136136
googleKeyFilePath: 'googleCredentials.json',
137137
testData: 'cypress/results/output.json',
138138
csvDownloadsPath: 'downloads'
@@ -168,9 +168,9 @@ Adjust these scripts as needed for your project's requirements.
168168

169169
Before you begin, ensure you have the following packages and authentication, you can run the command `npx qasr-setup` which initiates a couple of Yes or No questions to guide you through setting up the tool for your testing framework and package manager:
170170

171-
- **Google Spreadsheet ID:** Place the sheet's URL directly in an environment variable: `https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160`.
171+
- **Google Spreadsheet URL:** Place the sheet's URL directly in an environment variable: `https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160`.
172172
- **Service Account Credentials for Google Sheets:** Follow the detailed guide from `node-google-spreadsheet` they have a great document describing Google Service Accounts [node-google-spreadshee: Google Service Account](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication?id=authentication-methods)
173-
to set up and safely store your credentials, updating `shadowReportConfig.*` (`js`, or `ts`) with the path to these credentials. Use `.gitignore` to secure your credentials within your project.
173+
to set up and safely store your credentials. update `shadowReportConfig.*` (`js`, or `ts`) with the path to these credentials. Use `.gitignore` to secure your credentials within your project. Allow your service account to Edit the Google Sheet by sharing the google sheet with the service account emial address as an Editor.
174174
- **Playwright Configuration**: In the `playwright.config.js` file, specify the reporter like this:
175175

176176
```js
@@ -183,7 +183,7 @@ Before you begin, ensure you have the following packages and authentication, you
183183
- `teamNames`: An array of identifiers representing different teams within your organization that may use or contribute to the testing process.
184184
- `testTypes`: Specifies the types of tests included in your project, such as API tests or UI tests, to help organize and filter test executions.
185185
- `testCategories`: Defines the categories of tests your project includes, such as smoke tests for quick checks or sanity tests for verifying vital features after builds.
186-
- `googleSpreadsheetId`: The URL of your Google Sheet. This is used to integrate and sync test result data.
186+
- `googleSpreadsheetUrl`: The URL of your Google Sheet. This is used to integrate and sync test result data.
187187
- `googleKeyFilePath`: The file path to your Google service account credentials, which are required to authenticate and interact with Google Sheets API.
188188
- `testData`: The file path to where your test results in JSON format are stored, typically generated by Cypress or another testing framework.
189189
- `scvDownloadsPath`: The directory path where the generated CSV files will be saved. This is useful for users who prefer to download and review test results in a CSV format.
@@ -202,7 +202,7 @@ Before you begin, ensure you have the following packages and authentication, you
202202
'smoke',
203203
'sanity',
204204
],
205-
googleSpreadsheetId: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
205+
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
206206
googleKeyFilePath: 'googleCredentials.json',
207207
testData: 'cypress/results/output.json',
208208
csvDownloadsPath: 'downloads'
@@ -232,7 +232,7 @@ In this example, running npm run playwright-test will:
232232

233233
### To Generate Reports In Sheets
234234

235-
All commands require that test report data is present, in this example, the report data is generated by the testing framework.
235+
All commands require that test suite result data is present, in this example, the test suite data is generated by the testing framework, either Cypress or Playwright.
236236

237237
- **To run the root `qa-shadow-report` functionality**
238238

@@ -261,7 +261,7 @@ In this example, running npm run playwright-test will:
261261
- This command processes the data from the test results and create a detailed report.
262262
- A new Sheet Tab will be created with the current day's title (e.g., `Mar 24, 2024`), to which this detailed report will be written.
263263
- If the Sheet has Tabs for the previous month (e.g., current month is April and sheet tabs exist for `Mar 24, 2024`, `Mar 25, 2024`), then a monthly summary will be generated with that previous month's data (`Summary Mar 2024`).
264-
- The report will fail if JSON test result data is not present.
264+
- The report will fail if test result data is not present in JSON format.
265265
- Duplicate Sheet Tabs are not created by defualt, to create a duplicate Tab, use the flag `--duplicate`.
266266
267267
- **To run the daily report only**
@@ -311,7 +311,7 @@ module.exports = {
311311
'wilkins',
312312
'canonicus',
313313
],
314-
googleSpreadsheetId: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
314+
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
315315
googleKeyFilePath: 'googleCredentials.json',
316316
testData: '[framework]/results/output.json',
317317
csvDownloadsPath: 'downloads'
@@ -364,7 +364,7 @@ module.exports = {
364364
'accessibility',
365365
'mobile',
366366
],
367-
googleSpreadsheetId: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
367+
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
368368
googleKeyFilePath: 'googleCredentials.json',
369369
testData: '[framework]/results/output.json',
370370
csvDownloadsPath: 'downloads'
@@ -404,7 +404,7 @@ module.exports = {
404404
'alpha',
405405
'beta',
406406
],
407-
googleSpreadsheetId: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
407+
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
408408
googleKeyFilePath: 'googleCredentials.json',
409409
testData: '[framework]/results/output.json',
410410
csvDownloadsPath: 'downloads'
@@ -488,7 +488,7 @@ module.exports = {
488488
'alpha',
489489
'beta',
490490
],
491-
googleSpreadsheetId: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
491+
googleSpreadsheetUrl: 'https://docs.google.com/spreadsheets/d/1Y8tQWmo3oSB3zIlr1mySs/edit?gid=160#gid=19160',
492492
googleKeyFilePath: 'googleCredentials.json',
493493
testData: '[framework]/results/output.json',
494494
csvDownloadsPath: 'downloads'
@@ -527,13 +527,13 @@ The `cypress/grep` package has a Tags feature, which allows you to add an Object
527527
528528
By integrating `cypress/grep`, you can run subsets of tests based on your annotations, which aligns perfectly with your team's naming conventions and test categorization.
529529
530-
### GitHub CI/CD
530+
### CI/CD
531531
532532
This package is best suited for automated nightly runs, enabling teams to efficiently monitor project status and collaborate on test results every morning.
533533
534-
**Integrating Google Sheets Credentials with GitHub Actions:**
534+
**Integrating Google Sheets Credentials with CI/CD:**
535535
536-
For seamless integration in GitHub Actions, as required for manual package operation, the Google Sheets credentials need to be appropriately configured. Given the length constraints of GitHub secrets, it may be necessary to compact the Google Sheets key using GPG encryption.
536+
For seamless integration into CI/CD pipelines, the Google Sheets credentials need to be appropriately configured. Given the length constraints of most CI/CD environment variables, it may be necessary to compact the Google Sheets key using GPG encryption.
537537
538538
**Steps for Secure Key Management**
539539
@@ -542,22 +542,22 @@ For seamless integration in GitHub Actions, as required for manual package opera
542542
- **Generate a GPG Key Pair:** If not already available, generate a new GPG key pair using the command `gpg --gen-key`.
543543
- **Encrypt the Secret File:** For a secret file named `google-key.json`, encrypt it by executing `gpg --output google-key.json.gpg --symmetric --cipher-algo AES256 google-key.json`.
544544
545-
2. **Storing Encrypted Secrets in GitHub**
545+
2. **Storing Encrypted Secrets in Repository/CI Environmen**
546546
547547
- **Repository Storage:** Include the encrypted file (`google-key.json.gpg`) in the repository.
548-
- **Creating a GitHub Secret:** Generate a GitHub secret named `GPG_PASSPHRASE` containing the passphrase used for file encryption.
548+
- **Creating a CI/CD Environment Variable:** Generate a secret named `GPG_PASSPHRASE` containing the passphrase used for file encryption.
549549
550-
3. **Decrypting the Secret in GitHub Actions**
551-
- **Workflow Modification:** Incorporate steps in your GitHub Actions workflow to decrypt the secret file using the stored passphrase. The modifications should align with your project's encryption setup.
550+
3. **Decrypting the Secret in CI/CD**
551+
- **Workflow Modification:** Incorporate steps in your CI/CD workflow to decrypt the secret file using the stored passphrase. The modifications should align with your project's encryption setup.
552552
553-
**Note:** A suitable GitHub Action configuration is required for this process to function correctly:
553+
**GitHub Actions Example:**
554554
555-
```
555+
```yaml
556556
name: Nightly regression and report
557557
558558
on:
559559
schedule:
560-
- cron: "0 1 * * *" # Runs daily at 1 AM UTC
560+
- cron: '0 1 * * *' # Runs daily at 1 AM UTC
561561
push:
562562
branches:
563563
- main
@@ -573,7 +573,7 @@ jobs:
573573
- name: Set up Node.js
574574
uses: actions/setup-node@v4
575575
with:
576-
node-version: "21"
576+
node-version: '21'
577577
578578
- name: Install GPG
579579
run: sudo apt-get install -y gpg
@@ -588,16 +588,62 @@ jobs:
588588
run: echo "GOOGLE_KEY_FILE_PATH=$(pwd)/googleCredentials.json" >> $GITHUB_ENV
589589
590590
- name: Install dependencies
591-
run: npm install --legacy-peer-deps
591+
run: npm install
592592
593593
- name: Run QA regression tests
594594
run: npm run cypress:nightly
595595
```
596596

597+
**GitLab CI Example:**
598+
(Note: To schedule nightly runs, set up a pipeline schedule in your GitLab project settings.)
599+
600+
```yaml
601+
stages:
602+
- test
603+
604+
nightly_regression:
605+
stage: test
606+
image: cypress/browsers:22.12.0
607+
allow_failure: true
608+
before_script:
609+
- apt-get update && apt-get install -y gnupg
610+
- git checkout $CI_COMMIT_REF_NAME
611+
script:
612+
- echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --output googleCredentials.json --decrypt googleCredentials.json.gpg
613+
- export GOOGLE_KEY_FILE_PATH=$(pwd)/googleCredentials.json
614+
- npm install
615+
- npm run cypress:nightly
616+
only:
617+
- main
618+
```
619+
620+
**AWS CodeBuild Example:**
621+
For AWS CodeBuild, you can set up a comparable configuration using a `buildspec.yml` file:
622+
623+
```yaml
624+
version: 0.2
625+
626+
phases:
627+
install:
628+
runtime-versions:
629+
nodejs: 21
630+
commands:
631+
- apt-get update && apt-get install -y gnupg
632+
pre_build:
633+
commands:
634+
- echo "Decrypting Google Sheets Key..."
635+
- echo $GPG_PASSPHRASE | gpg --batch --yes --passphrase-fd 0 --output googleCredentials.json --decrypt googleCredentials.json.gpg
636+
- export GOOGLE_KEY_FILE_PATH=$(pwd)/googleCredentials.json
637+
build:
638+
commands:
639+
- npm install
640+
- npm run cypress:nightly
641+
```
642+
597643
Additional Notes:
598644

599645
- **Security:** Be cautious with the passphrase and the encrypted file. If someone gains access to both, they can decrypt your secret.
600-
- **GPG Version:** Ensure that the GPG version you use locally for encryption is compatible with the version installed in the GitHub Actions runner.
646+
- **GPG Version:** Ensure that the GPG version you use locally for encryption is compatible with the version installed in the CI/CD environment.
601647
- **File Paths:** Adjust file paths in the script according to where you store the encrypted file and where the decrypted file is needed.
602648

603649
### Demo Branch
@@ -607,7 +653,7 @@ For those who want to see `qa-shadow-report` in action before integrating it int
607653
#### How to Use the Demo
608654

609655
1. **Switch to the Demo Branch:** Navigate to our repository and switch to the branch named `demo`.
610-
2. **Follow the Setup Instructions:** Ensure you meet the prerequisites and follow the setup steps outlined in the [Setup Guide](#setup-guide).
656+
2. **Follow the Setup Instructions:** Ensure you meet the prerequisites and follow the setup steps outlined in [Installation](#installation).
611657
3. **Install Dependencies:**
612658

613659
- **For General Use:**

constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ export const GOOGLE_SHEET_ID = () => {
9898

9999
if (
100100
shadowConfigDetails &&
101-
typeof shadowConfigDetails.googleSpreadsheetId === 'string'
101+
typeof shadowConfigDetails.googleSpreadsheetUrl === 'string'
102102
) {
103-
const envVarMatch = shadowConfigDetails.googleSpreadsheetId.match(
103+
const envVarMatch = shadowConfigDetails.googleSpreadsheetUrl.match(
104104
/^process\.env\.(\w+)$/
105105
);
106106

@@ -112,7 +112,7 @@ export const GOOGLE_SHEET_ID = () => {
112112
sheetId = process.env[envVarName].split('/d/')[1].split('/')[0] || ''; // Set the value from process.env
113113
}
114114
} else {
115-
sheetId = shadowConfigDetails.googleSpreadsheetId
115+
sheetId = shadowConfigDetails.googleSpreadsheetUrl
116116
.split('/d/')[1]
117117
.split('/')[0]; // Use the raw config value if it's not an environment variable
118118
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qa-shadow-report",
3-
"version": "1.1.34",
3+
"version": "2.0.0",
44
"bin": {
55
"qa-shadow-report": "./cli.js",
66
"qasr": "./cli.js",

scripts/postInstall.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ const createConfigFile = () => {
142142
// 'alpha',
143143
// 'beta',
144144
],
145-
// Google Spreadsheet URL: Replace with either the actual spreadsheet ID or an environment variable.
146-
// googleSpreadsheetId: 'your-google-spreadsheet-id' OR googleSpreadsheetId: process.env.GOOGLE_SHEET_URL,
145+
// Google Spreadsheet URL: Replace with either the spreadsheet URL or an environment variable.
146+
// googleSpreadsheetUrl: 'your-google-spreadsheet-url' OR googleSpreadsheetUrl: process.env.GOOGLE_SHEET_URL,
147147
148148
// Path to Google credentials file (service account JSON file): Replace with the file path or use an environment variable.
149149
// googleKeyFilePath: 'googleCredentials.json' OR googleKeyFilePath: process.env.GOOGLE_KEY_FILE_PATH,

0 commit comments

Comments
 (0)