forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate PR stats action into Next.js repo (vercel#13177)
* Migrate PR stats into Next.js repo * Update running prettier in local mode
- Loading branch information
Showing
26 changed files
with
1,380 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/node_modules | ||
out.md | ||
.work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:10-buster | ||
|
||
LABEL com.github.actions.name="Next.js PR Stats" | ||
LABEL com.github.actions.description="Compares stats of a PR with the main branch" | ||
LABEL repository="https://github.com/zeit/next-stats-action" | ||
|
||
COPY . /next-stats | ||
|
||
# Install node_modules | ||
RUN cd /next-stats && yarn install --production | ||
|
||
RUN git config --global user.email 'stats@localhost' | ||
RUN git config --global user.name 'next stats' | ||
|
||
RUN apt update | ||
RUN apt install apache2-utils -y | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Next.js Stats GitHub Action | ||
|
||
> Downloads and runs project with provided configs gathering stats to compare branches | ||
See it in action at Next.js https://github.com/zeit/next.js | ||
|
||
## Getting Started | ||
|
||
1. Add a `.stats-app` folder to your project with a [`stats-config.js`](#stats-config) and any files to run against for example a test app that is to be built | ||
2. Add the action to your [workflow](https://help.github.com/en/articles/configuring-a-workflow) | ||
3. Enjoy the stats | ||
|
||
## Stats Config | ||
|
||
```TypeScript | ||
const StatsConfig = { | ||
// the Heading to show at the top of stats comments | ||
commentHeading: 'Stats from current PR' | undefined, | ||
commentReleaseHeading: 'Stats from current release' | undefined, | ||
// the command to build your project if not done on post install | ||
initialBuildCommand: undefined | string, | ||
skipInitialInstall: undefined | boolean, | ||
// the command to build the app (app source should be in `.stats-app`) | ||
appBuildCommand: string, | ||
appStartCommand: string | undefined, | ||
// the main branch to compare against (what PRs will be merging into) | ||
mainBranch: 'canary', | ||
// the main repository path (relative to https://github.com/) | ||
mainRepo: 'zeit/next.js', | ||
// whether to attempt auto merging the main branch into PR before running stats | ||
autoMergeMain: boolean | undefined, | ||
// an array of configs for each run | ||
configs: [ | ||
{ // first run's config | ||
// title of the run | ||
title: 'fastMode stats', | ||
// whether to diff the outputted files (default: onOutputChange) | ||
diff: 'onOutputChange' | false | undefined, | ||
// config files to add before running diff (if `undefined` uses `configFiles`) | ||
diffConfigFiles: [] | undefined, | ||
// renames to apply to make file names deterministic | ||
renames: [ | ||
{ | ||
srcGlob: 'main-*.js', | ||
dest: 'main.js' | ||
} | ||
], | ||
// config files to add before running (removed before successive runs) | ||
configFiles: [ | ||
{ | ||
path: './next.config.js', | ||
content: 'module.exports = { fastMode: true }' | ||
} | ||
], | ||
// an array of file groups to diff/track | ||
filesToTrack: [ | ||
{ | ||
name: 'Pages', | ||
globs: [ | ||
'build/pages/**/*.js' | ||
] | ||
} | ||
], | ||
// an array of URLs to fetch while `appStartCommand` is running | ||
// will be output to fetched-pages/${pathname}.html | ||
pagesToFetch: [ | ||
'https://localhost:$PORT/page-1' | ||
] | ||
}, | ||
{ // second run's config | ||
title: 'slowMode stats', | ||
diff: false, | ||
configFiles: [ | ||
{ | ||
path: './next.config.js', | ||
content: 'module.exports = { slowMode: true }' | ||
} | ||
], | ||
filesToTrack: [ | ||
{ | ||
name: 'Main Bundles', | ||
globs: [ | ||
'build/runtime/webpack-*.js', | ||
'build/runtime/main-*.js', | ||
] | ||
} | ||
] | ||
}, | ||
] | ||
} | ||
|
||
module.exports = StatsConfig | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
set -eu # stop on error | ||
|
||
export HOME=/root | ||
|
||
node /next-stats/src/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "get-stats", | ||
"version": "1.0.0", | ||
"main": "src/index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"async-sema": "^3.1.0", | ||
"fs-extra": "^8.1.0", | ||
"get-port": "^5.0.0", | ||
"glob": "^7.1.4", | ||
"gzip-size": "^5.1.1", | ||
"minimatch": "^3.0.4", | ||
"node-fetch": "^2.6.0", | ||
"prettier": "^1.18.2", | ||
"pretty-bytes": "^5.3.0", | ||
"pretty-ms": "^5.0.0" | ||
} | ||
} |
Oops, something went wrong.