Skip to content

Commit 208a1cd

Browse files
authored
Merge pull request #68 from spotify/release-2.0.0
Release 2.0.0
2 parents d726dc4 + 5953410 commit 208a1cd

File tree

17 files changed

+3763
-4632
lines changed

17 files changed

+3763
-4632
lines changed

.github/workflows/publish.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ name: Publish
33
on:
44
push:
55
branches:
6-
- master
6+
- master
77

88
jobs:
99
publish:
1010
name: Publish
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v1
15-
- uses: actions/setup-node@v1
16-
with:
17-
node-version: 12.0
18-
- name: yarn install
19-
run: yarn
20-
- name: lint
21-
run: yarn lint
22-
- name: build
23-
run: yarn build
24-
- name: test
25-
run: yarn test
26-
- name: release
27-
run: yarn release
28-
env:
29-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
31-
GH_USERNAME: ${{ secrets.GH_USERNAME }}
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 16
18+
- name: yarn install
19+
run: yarn install --frozen-lockfile
20+
- name: lint
21+
run: yarn lint
22+
- name: build
23+
run: yarn build
24+
- name: test
25+
run: yarn test
26+
- name: release
27+
run: yarn release
28+
env:
29+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
31+
GH_USERNAME: ${{ secrets.GH_USERNAME }}

.github/workflows/test.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Tests
33
on:
44
push:
55
branches:
6-
- master
6+
- master
77
pull_request:
88
branches:
9-
- master
9+
- master
1010

1111
jobs:
1212
test:
@@ -15,19 +15,19 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [12.x]
18+
node-version: [14, 16]
1919

2020
steps:
21-
- uses: actions/checkout@v1
22-
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v1
24-
with:
25-
node-version: ${{ matrix.node-version }}
26-
- name: yarn install
27-
run: yarn
28-
- name: lint
29-
run: yarn lint
30-
- name: build
31-
run: yarn build
32-
- name: test
33-
run: yarn test
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v2
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: yarn install
27+
run: yarn install --frozen-lockfile
28+
- name: lint
29+
run: yarn lint
30+
- name: build
31+
run: yarn build
32+
- name: test
33+
run: yarn test

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@ typings/
6363
# web-scripts paths
6464
types
6565
esm
66-
cjs
66+
cjs
67+
68+
# typescript incremental compilation cache
69+
tsconfig.tsbuildinfo

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn web-scripts commitmsg --edit="$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn web-scripts precommit --no-tests --no-typecheck

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12
1+
16

Dockerfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
# everything below sets up and runs lighthouse
2-
FROM node:12
3-
4-
WORKDIR /app
2+
FROM node:16-bullseye-slim
53

64
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
75
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
86
# installs, work.
97
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
108
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
119
&& apt-get update \
12-
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
10+
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf dumb-init \
1311
--no-install-recommends \
1412
&& rm -rf /var/lib/apt/lists/*
1513

1614
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
1715
ENV CHROME_PATH "google-chrome-unstable"
1816

19-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
17+
USER node
18+
19+
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
20+
ENV PATH=$PATH:/home/node/.npm-global/bin
21+
22+
WORKDIR /home/node/app
2023

2124
# install all dev and production dependencies
22-
COPY package.json /app
23-
COPY yarn.lock app/
25+
COPY --chown=node:node package.json .
26+
COPY --chown=node:node yarn.lock .
2427
RUN yarn install
2528

2629
# build and copy the app over
27-
COPY src/ /app/src
28-
COPY tsconfig.json /app
30+
COPY --chown=node:node src ./src
31+
COPY --chown=node:node tsconfig.json .
2932
RUN yarn build
3033

34+
ENV NODE_ENV production
35+
3136
# prune out dev dependencies now that build has completed
3237
RUN yarn install --production
3338

34-
ENTRYPOINT [ "yarn" ]
35-
CMD [ "start" ]
39+
CMD ["dumb-init", "node", "cjs/run.js"]

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,35 @@ Be sure to see "Configuring Postgres" - you will likely need to configure the Po
2121
- `LAS_CORS`: if true, enables the [cors express middleware](https://expressjs.com/en/resources/middleware/cors.html).
2222
- all [environment variables from pg](https://node-postgres.com/features/connecting#Environment%20variables), which should be used to set credentials for accessing the db.
2323

24+
#### With Docker Compose
25+
26+
A simple way to trial this tool is with the following docker compose file which spins up a postgres container and connects it with the lighthouse image. This would not be a great way to run this in a production environment, but a fast way to test out this tool and see if it meets your needs.
27+
28+
```yaml
29+
# docker-compose.yml
30+
version: '3.1'
31+
32+
services:
33+
34+
db:
35+
image: postgres:latest
36+
restart: always
37+
environment:
38+
POSTGRES_USER: dbuser
39+
POSTGRES_PASSWORD: example
40+
41+
lighthouse:
42+
image: spotify/lighthouse-audit-service:latest
43+
environment:
44+
PGHOST: db
45+
PGUSER: dbuser
46+
PGPASSWORD: example
47+
LAS_PORT: 4008
48+
ports:
49+
- "4008:4008"
50+
```
51+
52+
2453
### As an npm package
2554
2655
Install the project:
@@ -52,7 +81,7 @@ You may nest the [express app](https://expressjs.com/) that the lighthouse-audit
5281

5382
```js
5483
import express from 'express';
55-
import { getApp as getLighthouseAuditServerApp } from '@spotify/lighthouse-audit-server';
84+
import { getApp as getLighthouseAuditServerApp } from '@spotify/lighthouse-audit-service';
5685

5786
async function startup() {
5887
const app = express();

package.json

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,52 @@
2525
"format": "web-scripts format",
2626
"commit": "web-scripts commit",
2727
"release": "web-scripts release",
28-
"prepare": "web-scripts audit"
29-
},
30-
"husky": {
31-
"hooks": {
32-
"commit-msg": "web-scripts commitmsg",
33-
"pre-commit": "web-scripts precommit"
34-
}
28+
"prepare": "husky install"
3529
},
3630
"devDependencies": {
3731
"@spotify/eslint-config-oss": "^1.0.2",
38-
"@spotify/web-scripts": "^10.0.1",
39-
"@types/async-retry": "^1.4.1",
40-
"@types/compression": "^1.7.0",
41-
"@types/cors": "^2.8.6",
42-
"@types/express": "^4.17.3",
43-
"@types/morgan": "^1.9.0",
44-
"@types/node": "^13.9.3",
45-
"@types/pg": "^7.14.11",
46-
"@types/supertest": "^2.0.11",
47-
"@types/uuid": "^8.3.0",
48-
"@types/wait-on": "^5.2.0",
32+
"@spotify/web-scripts": "^13.0.0",
33+
"@types/async-retry": "^1.4.3",
34+
"@types/compression": "^1.7.2",
35+
"@types/cors": "^2.8.12",
36+
"@types/express": "^4.17.13",
37+
"@types/morgan": "^1.9.3",
38+
"@types/node": "^16.9.6",
39+
"@types/pg": "^8.6.5",
40+
"@types/supertest": "^2.0.12",
41+
"@types/uuid": "^8.3.4",
42+
"@types/wait-on": "^5.3.1",
4943
"copyfiles": "^2.4.1",
50-
"dotenv": "^8.2.0",
44+
"dotenv": "^16.0.0",
5145
"get-port": "^5.1.1",
52-
"husky": "^4.0.0",
46+
"husky": "^7.0.4",
5347
"node-duration": "^2.0.0",
54-
"nodemon": "^2.0.7",
55-
"supertest": "^6.1.3",
56-
"testcontainers": "^7.8.0",
57-
"ts-node": "^9.1.1"
48+
"nodemon": "^2.0.15",
49+
"supertest": "^6.2.2",
50+
"testcontainers": "^8.6.1",
51+
"ts-node": "^10.7.0"
5852
},
5953
"dependencies": {
60-
"async-retry": "^1.3.1",
61-
"body-parser": "^1.19.0",
54+
"async-retry": "^1.3.3",
55+
"body-parser": "^1.20.0",
6256
"compression": "^1.7.4",
6357
"cors": "^2.8.5",
64-
"express": "^4.17.1",
65-
"express-promise-router": "^4.1.0",
66-
"lighthouse": "^7.4.0",
58+
"express": "^4.17.3",
59+
"express-promise-router": "^4.1.1",
60+
"lighthouse": "^9.5.0",
6761
"morgan": "^1.10.0",
6862
"node-fetch": "^2.6.1",
69-
"pg": "^8.6.0",
70-
"puppeteer": "^9.0.0",
63+
"pg": "^8.7.3",
64+
"puppeteer": "^13.5.2",
7165
"sql-template-strings": "^2.2.2",
7266
"uuid": "^8.3.2",
73-
"wait-on": "^5.3.0",
74-
"winston": "^3.3.3"
67+
"wait-on": "^6.0.1",
68+
"winston": "^3.7.2"
7569
},
7670
"publishConfig": {
7771
"access": "public"
7872
},
7973
"engines": {
80-
"node": ">=12"
74+
"node": ">=14.17"
8175
}
8276
}

src/api/audits/models.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import path from 'path';
1818

1919
import { Audit, AuditStatus } from './models';
2020

21-
const UUID_RE = /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
21+
const UUID_RE =
22+
/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
2223

2324
const LIGHTHOUSE_REPORT_FIXTURE = fs
2425
.readFileSync(path.join(__dirname, '__fixtures__', 'lighthouse-report.json'))

0 commit comments

Comments
 (0)