Skip to content

Commit

Permalink
Configure NODE_PATH to load plugin from GitHub workspace (#19)
Browse files Browse the repository at this point in the history
* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* ignore ds store

* add dock

* del
  • Loading branch information
connorjclark authored and alekseykulikov committed Dec 11, 2019
1 parent 7f0d318 commit 3da4a41
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 437 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
node_modules/**/*.ts
results/
.lighthouseci/
.lighthouseci/

node_modules/.yarn-integrity
node_modules/**/.DS_Store
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 3da4a41

Please sign in to comment.