Skip to content

Commit

Permalink
feat: remove custom script add only comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton authored Jul 21, 2023
2 parents 359be26 + 7ac3b84 commit 8377112
Show file tree
Hide file tree
Showing 22 changed files with 504 additions and 244 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,22 @@ jobs:
outPath: ./packages/user-flow-gh-action-e2e/measures
format: html,json
rcPath: ./.user-flowrc.json

- name: run:action ( dummy run for to test multiple comments )
uses: ./
with:
commentId: test-e2e-second-run
dryRun: on
ufPath: ./user-flows/flow.uf.ts
rcPath: ./.user-flowrc.json


- name: use user-flow-nx-plugin
run: npm run nx user-flow user-flow-gh-action-e2e

- name: run:action ( test commentsOnly input )
uses: ./
with:
verbose: on
commentId: test-commentsOnly
onlyComments: on
outPath: ./dist/user-flow/user-flow-gh-action-e2e
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ It automatically detects flows, executes them and produces md reports as comment
| Name | Type | Default | Description |
|------------------------------| --------- | --------------------------- |----------------------------------------------------------------------------------------------------------- |
| **`--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) |
| **`--customScript`** | `string` | `undefined` | Custom way to execute user-flow (helpfule if the default way of execution is not given) |
| **`--commentsOnly`** | `string` | `off` | Only collects results and creates a comment in the PR (helpful if the reports are generated over external logic) |
| **`--rcPath`** | `string` | `./user-flowrc.json` | Path to `.user-flowrc.json`. e.g. `./user-flowrc.server.json` |
| **`--verbose`** | `string` | `off` | Run with verbose logging (only 'on' and 'off' is possible) |
| **`--dryRun`** | `string` | `off` | Run in `dryRun` mode (only 'on' and 'off' is possible) |
| **`...`** | ... | ... | All other actions from the user-flow CLI are available |

# Setup

Expand Down Expand Up @@ -40,6 +41,35 @@ jobs:
uses: push-based/[email protected]
```
You can use action inputs over the with property:
```yml
name: user-flow-ci
on:
pull_request:
jobs:
user-flow-integrated-in-ci:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- name: Executing user-flow CLI
# without any parameters the rcPath defaults to `.user-flowrc.json`
uses: push-based/[email protected]
with:
commentId: test-e2e-first-run
dryRun: off
verbose: on
url: https://google.com
ufPath: ./user-flows
outPath: ./packages/user-flow-gh-action-e2e/measures
format: html,json
rcPath: ./.user-flowrc.json
```
# How to test the setup
1. If you open a new PR in your repository you should see the runner execution your user-flow in the CI
Expand All @@ -51,6 +81,34 @@ jobs:
<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">
# How to use it with the nx-plugin and --affected
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).
Here is how you can combine it with the GitHub action:
1. Use the action with commentsOnly. besides the outPath no other params are considered.
```yml
name: user-flow-ci
on:
pull_request:
jobs:
user-flow-integrated-in-ci:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- name: Executing user-flow CLI
uses: push-based/[email protected]
with:
verbose: on
commentId: test-e2e-first-run
commentsOnly: on
```
---
made with ❤ by [push-based.io](https://www.push-based.io)
Expand Down
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ inputs:
description: 'A custom id to identify a comments in a PR'
required: false
default: "user flow summary report"
customScript:
description: 'A custom way to execute userflow. This is helpful if another lib wraps the userflow execution in the CI'
onlyComments:
description: 'No execution of userflow. Just creation of the comments in the PR.'
required: false
default: "off"
rcPath:
description: 'Path to a UFCI user-flowrc.json file'
required: false
Expand Down Expand Up @@ -58,7 +59,7 @@ runs:
shell: bash
run: node ${{ github.action_path }}/dist/packages/user-flow-gh-action/main.js
env:
INPUT_CUSTOMSCRIPT: ${{ inputs.customScript }}
INPUT_ONLYCOMMENTS: ${{ inputs.onlyComments }}
INPUT_RCPATH: ${{ inputs.rcPath }}
INPUT_VERBOSE: ${{ inputs.verbose }}
INPUT_DRYRUN: ${{ inputs.dryRun }}
Expand Down
5 changes: 3 additions & 2 deletions dist/packages/user-flow-gh-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: 'Lighthouse User Flow CI Action'
description: "Audit URL's using Lighthouse user flow and test performance within PR's"
inputs:
# GLOBAL ============================================
customScript:
description: 'A custom way to execute userflow. This is helpful if another lib wraps the userflow execution in the CI'
onlyComments:
description: 'No execution of userflow. Just creation of the comments in the PR.'
required: false
default: "off"
rcPath:
description: 'Path to a UFCI user-flowrc.json file'
required: false
Expand Down
60 changes: 37 additions & 23 deletions dist/packages/user-flow-gh-action/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/packages/user-flow-gh-action/main.js.map

Large diffs are not rendered by default.

33 changes: 12 additions & 21 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,25 @@
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"accessToken": "YTg3NDI1MGEtYzk0Mi00YWM0LTgwYTItMmM2YTliNDM3M2YzfHJlYWQtd3JpdGU="
"accessToken": "YTg3NDI1MGEtYzk0Mi00YWM0LTgwYTItMmM2YTliNDM3M2YzfHJlYWQtd3JpdGU=",
"cacheableOperations": ["lint", "build", "test","user-flow"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
]
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"lint": {
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json"
]
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
},
"test": {
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
}
},
"namedInputs": {
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
Expand All @@ -50,5 +36,10 @@
"workspaceLayout": {
"appsDir": "packages",
"libsDir": "packages"
},
"generators": {
"@push-based/user-flow-nx-plugin:target": {
"targetName": "user-flow"
}
}
}
Loading

0 comments on commit 8377112

Please sign in to comment.