Skip to content

Commit

Permalink
Add service and website to repo & new BundleMon version (#32)
Browse files Browse the repository at this point in the history
## BREAKING CHANGES
- GitHub integration:
  - `github-pr` output name to changed to `github`
  - `statusCheck` option in `github` output options changed to `commitStatus` 
  - [Install BundleMon GitHub App](https://github.com/apps/bundlemon), `BUNDLEMON_GITHUB_TOKEN` env var is not needed anymore and it wont work.
- remove `--local` / `onlyLocalAnalyze` option, will run in local mode if `CI` environment variable doesn't exists

## Features
- Add `checkRun` option to `github` output, will create a GitHub check run. default `false`
  • Loading branch information
LironEr authored Jun 2, 2021
1 parent 544c57f commit 11e2ff8
Show file tree
Hide file tree
Showing 128 changed files with 9,929 additions and 738 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
*Dockerfile*
*docker-compose*
node_modules
*.log
build
*.tsbuildinfo
*.md
.next
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

25 changes: 14 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"env": { "node": true },
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"ignorePatterns": ["**/node_modules", "**/build", "**/dist", "pacakges/*/lib/", "coverage", "*.svg"],
"overrides": [
{
"files": ["**/*.ts"],
"parser": "@typescript-eslint/parser",
"extends": ["plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true, "argsIgnorePattern": "^_" }]
}
},
{
"files": ["**/__tests__/**/*.spec.ts"],
"extends": ["plugin:jest/recommended"],
Expand All @@ -24,5 +21,11 @@
"@typescript-eslint/no-var-requires": "off"
}
}
]
],
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true, "argsIgnorePattern": "^_" }],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
27 changes: 8 additions & 19 deletions .github/workflows/build.yml → .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build web

on:
push:
Expand All @@ -19,31 +19,20 @@ jobs:
- name: Install dependencies
run: yarn

- name: Build packages
run: yarn build-packages

- name: Build
working-directory: ./website
run: yarn build

- name: Test
run: yarn test

- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/coverage-final.json

- name: Lint
run: yarn lint

- name: Type check
run: yarn type-check

- name: override CI_COMMIT_SHA
if: github.event_name == 'pull_request'
run: echo "CI_COMMIT_SHA=${{ github.event.pull_request.head.sha}}" >> $GITHUB_ENV

- name: Run bundlemon
working-directory: ./packages/bundlemon
working-directory: ./website
run: yarn bundlemon
env:
BUNDLEMON_PROJECT_ID: ${{ secrets.BUNDLEMON_PROJECT_ID }}
BUNDLEMON_PROJECT_APIKEY: ${{ secrets.BUNDLEMON_PROJECT_APIKEY }}
BUNDLEMON_GITHUB_TOKEN: ${{ secrets.BUNDLEMON_GITHUB_TOKEN }}
BUNDLEMON_PROJECT_ID: ${{ secrets.WEBSITE_BUNDLEMON_PROJECT_ID }}
BUNDLEMON_PROJECT_APIKEY: ${{ secrets.WEBSITE_BUNDLEMON_PROJECT_APIKEY }}
29 changes: 0 additions & 29 deletions .github/workflows/pr-build-test.yml

This file was deleted.

98 changes: 98 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: PR checks

on:
pull_request:
types: [synchronize, opened, reopened]

jobs:
packages:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: yarn

- name: Build
run: yarn build-packages

- name: Test
run: yarn test

- uses: codecov/codecov-action@v1
if: ${{ matrix.node-version == '12.x' }} # run this step only one time
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/coverage-final.json

- name: Lint
if: ${{ matrix.node-version == '12.x' }} # run this step only one time
run: yarn lint-packages

- name: Type check
if: ${{ matrix.node-version == '12.x' }} # run this step only one time
run: yarn type-check-packages

website:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js 12
uses: actions/setup-node@v2-beta
with:
node-version: '12'

- name: Install dependencies
run: yarn

- name: Build packages
run: yarn build-packages

- name: type check
working-directory: ./website
run: yarn type-check

- name: Lint
working-directory: ./website
run: yarn lint

service:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js 12
uses: actions/setup-node@v2-beta
with:
node-version: '12'

- name: Install dependencies
run: yarn

- name: Build packages
run: yarn build-packages

- name: type check
working-directory: ./service
run: yarn type-check

- name: Lint
working-directory: ./service
run: yarn lint

- name: Build
working-directory: ./service
run: yarn build
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ dist
.vscode
packages/*/lib
examples
.DS_STORE
.DS_STORE
build
.vercel
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:14-alpine

WORKDIR /app

EXPOSE 3333

COPY package.json yarn.lock ./
COPY service/package.json ./service/
COPY packages/bundlemon-utils/package.json ./packages/bundlemon-utils/

RUN yarn

COPY tsconfig.json ./

WORKDIR /app/packages/bundlemon-utils

COPY packages/bundlemon-utils/ .

RUN yarn build

WORKDIR /app/service

COPY service/ .

CMD ["yarn", "start:watch"]

31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BundleMon helps you achieve that by constantly monitoring your bundle size on ev
- Set max increase allowed in percentage from base branch, will fail build if exceeded
- Supports multiple CI
- Integrates with Github, can post build status & comment with detailed information
- History report (Still work in progress) [example](https://bundlemon.now.sh/projects/5f0628553998ea0008c3f6ee/reports?branch=master&resolution=days)
- History report - temporarily not available

## Guides

Expand Down Expand Up @@ -67,15 +67,13 @@ BundleMon config can be placed in other places like: `.bundlemonrc`, `.bundlemon
| groups | Sum all file sizes matching the pattern, rules applies to the sum of the files [Groups config](./docs/types.md#File) | `FileConfig[]` | - |
| defaultCompression | Use compression before calculating file size | `"none"` \| `"gzip"` | `"gzip"` |
| reportOutput | [Output options](./docs/output.md) | `(string \| [string, object])[]` | [] |
| onlyLocalAnalyze | Don't communicate with the service, just validate `maxSize` | `boolean` | `false` |
| verbose | Print more details | `boolean` | `false` |

## CLI usage

You can also set some of the variables using CLI flags

```
bundlemon --local
bundlemon --config my-custom-config-path.json
```

Expand All @@ -85,7 +83,7 @@ bundlemon --config my-custom-config-path.json

In order to save history and get differences from your main branches you will need to create a new project and setup environment variables.

- [Create new project](https://bundlemon.now.sh/create-project) and copy the project ID and API key
- [Create new project](https://app.bundlemon.dev/create-project) and copy the project ID and API key
- Add the ID to `BUNDLEMON_PROJECT_ID` and the API key to `BUNDLEMON_PROJECT_APIKEY` environment variables in your CI

## Set additional environment variables
Expand All @@ -94,6 +92,7 @@ In order to get BundleMon to work you'll need to set these environment variables

> If you are using one of the supported CIs (GitHub Actions, Travis, CircleCI and Codefresh) you dont need to set anything.
- `CI=true`
- `CI_REPO_OWNER` - github.com/LironEr/bundlemon `LironEr`
- `CI_REPO_NAME` - github.com/LironEr/bundlemon `bundlemon`
- `CI_BRANCH` - source branch name
Expand All @@ -103,28 +102,36 @@ In order to get BundleMon to work you'll need to set these environment variables

## GitHub integration

BundleMon can post build status and a detailed comment on your PR.
BundleMon can create GitHub check run, post commit status and a detailed comment on your PR.

<img src="./assets/check-run.png" alt="GitHub check run" height="300px" />
<br />
<img src="./assets/build-status-pass.png" alt="GitHub build status" height="50px" />
<br />
<img src="./assets/pr-comment.png" alt="GitHub detailed comment" height="300px" />

```
Just [Install BundleMon GitHub App](https://github.com/apps/bundlemon)

Then add `github` to `reportOutput`

```json
"reportOutput": ["github"]

// override default options

"reportOutput": [
[
"github-pr",
"github",
{
"statusCheck": true, // Default true
"prComment": true // Default false
"checkRun": false,
"commitStatus": true,
"prComment": true
}
]
]
```

- [Authorize `BundleMon`](https://bundlemon.now.sh/setup-github) and copy the token
- Add the token to `BUNDLEMON_GITHUB_TOKEN` environment variable in your CI

> The token is not saved in BundleMon service, ONLY used to communicate with GitHub

## Using hash in file names?

Expand Down
Binary file added assets/check-run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3.3'

services:
mongo:
image: mongo:4
ports:
- '51651:27017'
volumes:
- /data/db
logging:
driver: "none"
command: --quiet

bundlemon:
build: .
environment:
- NODE_ENV=development
- MONGO_URL=mongodb://mongo:27017
- MONGO_DB_NAME=dev
- MONGO_DB_USER=user
- MONGO_DB_PASSWORD=password
env_file:
- ./service/.env
depends_on:
- mongo
ports:
- '3333:3333'
volumes:
- $PWD:/app
- /usr/local/share/.cache/yarn/v6
1 change: 0 additions & 1 deletion docs/cli-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
| Flag | Description | Type |
| ------------ | ------------------------------------------------------------------------------------------- | ------------------ |
| -c, --config | Config file path | `string` optional |
| -l, --local | set `onlyLocalAnalyze` to true, Don't communicate with the service, just validate `maxSize` | `boolean` optional |
Loading

0 comments on commit 11e2ff8

Please sign in to comment.