Skip to content

Commit 8377112

Browse files
authored
feat: remove custom script add only comments
2 parents 359be26 + 7ac3b84 commit 8377112

File tree

22 files changed

+504
-244
lines changed

22 files changed

+504
-244
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,22 @@ jobs:
3838
outPath: ./packages/user-flow-gh-action-e2e/measures
3939
format: html,json
4040
rcPath: ./.user-flowrc.json
41+
4142
- name: run:action ( dummy run for to test multiple comments )
4243
uses: ./
4344
with:
4445
commentId: test-e2e-second-run
4546
dryRun: on
4647
ufPath: ./user-flows/flow.uf.ts
47-
rcPath: ./.user-flowrc.json
48+
49+
50+
- name: use user-flow-nx-plugin
51+
run: npm run nx user-flow user-flow-gh-action-e2e
52+
53+
- name: run:action ( test commentsOnly input )
54+
uses: ./
55+
with:
56+
verbose: on
57+
commentId: test-commentsOnly
58+
onlyComments: on
59+
outPath: ./dist/user-flow/user-flow-gh-action-e2e

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ It automatically detects flows, executes them and produces md reports as comment
99
| Name | Type | Default | Description |
1010
|------------------------------| --------- | --------------------------- |----------------------------------------------------------------------------------------------------------- |
1111
| **`--commentId`** | `string` | `user flow summary report` | Id used to identify a comment in the PR (useful if multiple actions run user-flow for the same PR) |
12-
| **`--customScript`** | `string` | `undefined` | Custom way to execute user-flow (helpfule if the default way of execution is not given) |
12+
| **`--commentsOnly`** | `string` | `off` | Only collects results and creates a comment in the PR (helpful if the reports are generated over external logic) |
1313
| **`--rcPath`** | `string` | `./user-flowrc.json` | Path to `.user-flowrc.json`. e.g. `./user-flowrc.server.json` |
1414
| **`--verbose`** | `string` | `off` | Run with verbose logging (only 'on' and 'off' is possible) |
1515
| **`--dryRun`** | `string` | `off` | Run in `dryRun` mode (only 'on' and 'off' is possible) |
16+
| **`...`** | ... | ... | All other actions from the user-flow CLI are available |
1617

1718
# Setup
1819

@@ -40,6 +41,35 @@ jobs:
4041
uses: push-based/[email protected]
4142
```
4243
44+
You can use action inputs over the with property:
45+
46+
```yml
47+
name: user-flow-ci
48+
on:
49+
pull_request:
50+
jobs:
51+
user-flow-integrated-in-ci:
52+
runs-on: ubuntu-latest
53+
strategy:
54+
matrix:
55+
node-version: [18.x]
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Executing user-flow CLI
59+
# without any parameters the rcPath defaults to `.user-flowrc.json`
60+
uses: push-based/[email protected]
61+
with:
62+
commentId: test-e2e-first-run
63+
dryRun: off
64+
verbose: on
65+
url: https://google.com
66+
ufPath: ./user-flows
67+
outPath: ./packages/user-flow-gh-action-e2e/measures
68+
format: html,json
69+
rcPath: ./.user-flowrc.json
70+
```
71+
72+
4373
# How to test the setup
4474
4575
1. If you open a new PR in your repository you should see the runner execution your user-flow in the CI
@@ -51,6 +81,34 @@ jobs:
5181
5282
<img width="676" alt="gh-ci-comment" title="Action created comment in PR" src="https://user-images.githubusercontent.com/10064416/216596391-35a041e2-9839-4cf5-b8c5-b55e93cb622e.PNG">
5383
84+
85+
# How to use it with the nx-plugin and --affected
86+
87+
If you use Nx as you tooling choice you should consider our [Nx plugin](https://github.com/push-based/user-flow/tree/main/packages/nx-plugin) for [user-flow](https://github.com/push-based/user-flow).
88+
89+
Here is how you can combine it with the GitHub action:
90+
91+
1. Use the action with commentsOnly. besides the outPath no other params are considered.
92+
```yml
93+
name: user-flow-ci
94+
on:
95+
pull_request:
96+
jobs:
97+
user-flow-integrated-in-ci:
98+
runs-on: ubuntu-latest
99+
strategy:
100+
matrix:
101+
node-version: [18.x]
102+
steps:
103+
- uses: actions/checkout@v2
104+
- name: Executing user-flow CLI
105+
uses: push-based/[email protected]
106+
with:
107+
verbose: on
108+
commentId: test-e2e-first-run
109+
commentsOnly: on
110+
```
111+
54112
---
55113
56114
made with ❤ by [push-based.io](https://www.push-based.io)

action.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ inputs:
66
description: 'A custom id to identify a comments in a PR'
77
required: false
88
default: "user flow summary report"
9-
customScript:
10-
description: 'A custom way to execute userflow. This is helpful if another lib wraps the userflow execution in the CI'
9+
onlyComments:
10+
description: 'No execution of userflow. Just creation of the comments in the PR.'
1111
required: false
12+
default: "off"
1213
rcPath:
1314
description: 'Path to a UFCI user-flowrc.json file'
1415
required: false
@@ -58,7 +59,7 @@ runs:
5859
shell: bash
5960
run: node ${{ github.action_path }}/dist/packages/user-flow-gh-action/main.js
6061
env:
61-
INPUT_CUSTOMSCRIPT: ${{ inputs.customScript }}
62+
INPUT_ONLYCOMMENTS: ${{ inputs.onlyComments }}
6263
INPUT_RCPATH: ${{ inputs.rcPath }}
6364
INPUT_VERBOSE: ${{ inputs.verbose }}
6465
INPUT_DRYRUN: ${{ inputs.dryRun }}

dist/packages/user-flow-gh-action/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: 'Lighthouse User Flow CI Action'
22
description: "Audit URL's using Lighthouse user flow and test performance within PR's"
33
inputs:
44
# GLOBAL ============================================
5-
customScript:
6-
description: 'A custom way to execute userflow. This is helpful if another lib wraps the userflow execution in the CI'
5+
onlyComments:
6+
description: 'No execution of userflow. Just creation of the comments in the PR.'
77
required: false
8+
default: "off"
89
rcPath:
910
description: 'Path to a UFCI user-flowrc.json file'
1011
required: false

dist/packages/user-flow-gh-action/main.js

Lines changed: 37 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/packages/user-flow-gh-action/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nx.json

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,25 @@
55
"default": {
66
"runner": "@nrwl/nx-cloud",
77
"options": {
8-
"accessToken": "YTg3NDI1MGEtYzk0Mi00YWM0LTgwYTItMmM2YTliNDM3M2YzfHJlYWQtd3JpdGU="
8+
"accessToken": "YTg3NDI1MGEtYzk0Mi00YWM0LTgwYTItMmM2YTliNDM3M2YzfHJlYWQtd3JpdGU=",
9+
"cacheableOperations": ["lint", "build", "test","user-flow"]
910
}
1011
}
1112
},
1213
"targetDefaults": {
1314
"build": {
14-
"dependsOn": [
15-
"^build"
16-
],
17-
"inputs": [
18-
"production",
19-
"^production"
20-
]
15+
"dependsOn": ["^build"],
16+
"inputs": ["production", "^production"]
2117
},
2218
"lint": {
23-
"inputs": [
24-
"default",
25-
"{workspaceRoot}/.eslintrc.json"
26-
]
19+
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
2720
},
2821
"test": {
29-
"inputs": [
30-
"default",
31-
"^production",
32-
"{workspaceRoot}/jest.preset.js"
33-
]
22+
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
3423
}
3524
},
3625
"namedInputs": {
37-
"default": [
38-
"{projectRoot}/**/*",
39-
"sharedGlobals"
40-
],
26+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
4127
"production": [
4228
"default",
4329
"!{projectRoot}/.eslintrc.json",
@@ -50,5 +36,10 @@
5036
"workspaceLayout": {
5137
"appsDir": "packages",
5238
"libsDir": "packages"
39+
},
40+
"generators": {
41+
"@push-based/user-flow-nx-plugin:target": {
42+
"targetName": "user-flow"
43+
}
5344
}
5445
}

0 commit comments

Comments
 (0)