Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure NODE_PATH to load plugin from GitHub workspace #19

Merged
merged 17 commits into from Dec 11, 2019
5 changes: 4 additions & 1 deletion .gitignore
@@ -1,2 +1,5 @@
results/
.lighthouseci/
.lighthouseci/

node_modules/.yarn-integrity
node_modules/**/.DS_Store
58 changes: 58 additions & 0 deletions README.md
Expand Up @@ -386,6 +386,64 @@ against each of them. More details on this process are in the [Lighthouse CI doc

</details>

<details>
<summary>Use a Lighthouse plugin.</summary><br>

#### main.yml

```yml
name: Lighthouse Audit
on: push
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1 # checkout your own repo
- run: npm install # install your own dependencies
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v2
with:
urls: |
https://www.example.com/
configPath: ./lighthouserc.json
- name: Save results
uses: actions/upload-artifact@v1
with:
name: lighthouse-results
path: '.lighthouseci' # This will save the Lighthouse results as .json files
```

#### lighthouserc.json

```json
{
"ci": {
"collect": {
"settings": {
"plugins": [
"lighthouse-plugin-social-sharing"
]
}
}
}
}
```

#### package.json

```json
{
"name": "lighthouse-plugin-sample-project",
"devDependencies": {
"lighthouse-plugin-social-sharing": "0.0.1"
}
}
```

[⚙️ See this example](https://github.com/connorjclark/lighthouse-plugin-sample-project)

</details>

Explore more workflows in [public examples](./.github/workflows).
Submit a pull request with a new one if they don't cover your use case.

Expand Down
435 changes: 0 additions & 435 deletions node_modules/.yarn-integrity

This file was deleted.

27 changes: 27 additions & 0 deletions node_modules/is-windows/index.js

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

71 changes: 71 additions & 0 deletions node_modules/is-windows/package.json

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

Binary file added node_modules/ws/lib/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -12,7 +12,8 @@
},
"dependencies": {
"@actions/core": "^1.2.0",
"@lhci/cli": "0.3.4"
"@lhci/cli": "0.3.4",
"is-windows": "^1.0.2"
},
"devDependencies": {
"@types/node": "10",
Expand Down
12 changes: 12 additions & 0 deletions src/index.js
@@ -1,3 +1,15 @@
// Append the node_modules of the github workspace and the node_modules of this action
// to NODE_PATH. This supports lighthouse plugins - all the workspace needs to do is
// `npm install` the plugin. The copy of lighthouse within this action will be used.

const nodePathDelim = require('is-windows')() ? ';' : ':';
const nodePathParts = [
...(process.env.NODE_PATH || '').split(nodePathDelim),
`${__dirname}/../node_modules`,
`${process.env.GITHUB_WORKSPACE}/node_modules`,
];
process.env.NODE_PATH = nodePathParts.join(nodePathDelim);

const core = require('@actions/core')
const childProcess = require('child_process')
const lhciCliPath = require.resolve('@lhci/cli/src/cli.js')
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -1012,6 +1012,11 @@ is-typedarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"

is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==

is-wsl@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
Expand Down