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

frontend: apply prettier to cypress/webapp #417

Merged
merged 8 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"build": { "dockerfile": "Dockerfile" },
"extensions": [
"golang.go"
],
"forwardPorts": [4040]
"extensions": ["golang.go"],
"forwardPorts": [4040]
}
14 changes: 8 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"parser": "babel-eslint",
"plugins": ["prettier"],
"extends": ["airbnb", "prettier"],
"extends": ["airbnb", "prettier", "plugin:cypress/recommended"],
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"no-unused-vars": ["warn"],
"prettier/prettier": ["error"],
"no-param-reassign": ["warn"],
"no-shadow": ["warn"],
"no-case-declarations": ["warn"],
Expand All @@ -20,11 +19,14 @@
"jsx-a11y/mouse-events-have-key-events": ["warn"],
"jsx-a11y/click-events-have-key-events": ["warn"],
"jsx-a11y/no-static-element-interactions": ["warn"],
"jsx-a11y/label-has-associated-control": [ "error", {
"required": {
"some": [ "nesting", "id" ]
"jsx-a11y/label-has-associated-control": [
"error",
{
"required": {
"some": ["nesting", "id"]
}
}
}]
]
},
"env": {
"browser": true,
Expand Down
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fca0fcf152cb304c10b94bd3b78d56a319485170
2 changes: 1 addition & 1 deletion .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
uses: petethepig/revive-action@v5
with:
config: revive.toml
exclude: "vendor/..."
exclude: 'vendor/...'
11 changes: 5 additions & 6 deletions .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: Markdown Linting
# runs every monday at 9 am
on:
schedule:
- cron: "0 9 * * 1"
- cron: '0 9 * * 1'

jobs:
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: .github/workflows/markdown-links-config.json

- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: .github/workflows/markdown-links-config.json
22 changes: 11 additions & 11 deletions .github/workflows/update-contributos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Install dependencies
run: make install-web-dependencies
- name: Install dependencies
run: make install-web-dependencies

- name: Update contributors
run: make update-contributors
- name: Update contributors
run: make update-contributors

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Updates the list of contributors in README
file_pattern: README.md
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Updates the list of contributors in README
file_pattern: README.md
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
npx lint-staged
npx lint-staged
1 change: 0 additions & 1 deletion .linelint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ignore:
- examples/dotnet
- .github/markdown-images


rules:
# checks if file ends in a newline character
end-of-file:
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
webapp/public
third_party
*.md
*.json
monitoring/gen/*
.prettierignore
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "single-quote": true }
{ "singleQuote": true }
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ WORKDIR /opt/pyroscope

COPY scripts ./scripts
COPY webapp ./webapp
COPY package.json yarn.lock babel.config.js .eslintrc .eslintignore Makefile ./
COPY package.json yarn.lock babel.config.js .eslintrc .eslintignore .prettierrc Makefile ./

ARG EXTRA_METADATA=""
RUN EXTRA_METADATA=$EXTRA_METADATA make assets-release
Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: ["transform-class-properties"],
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['transform-class-properties'],
};
10 changes: 4 additions & 6 deletions benchmark/ci/pr/dangerfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {markdown } from "danger"
import { markdown } from 'danger';
const fs = require('fs');
const path = require('path');


const metaReport = fs.readFileSync(path.join(__dirname,"./meta-report"));
const tableReport = fs.readFileSync(path.join(__dirname,"./table-report"));
const imgReport = fs.readFileSync(path.join(__dirname,"./image-report"));
const metaReport = fs.readFileSync(path.join(__dirname, './meta-report'));
const tableReport = fs.readFileSync(path.join(__dirname, './table-report'));
const imgReport = fs.readFileSync(path.join(__dirname, './image-report'));

// the markdown calls seem to be LIFO
// so it's easier to just use a single call
markdown(`${metaReport} \n${tableReport} \n${imgReport}`);

12 changes: 6 additions & 6 deletions benchmark/ci/pr/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
x-PYROSCOPE_CPUS: &PYROSCOPE_CPUS 1
x-PYROSCOPE_MEMORY: &PYROSCOPE_MEMORY 4096MB

version: "3.9"
version: '3.9'
services:
client:
build:
context: ../../../
dockerfile: benchmark/Dockerfile
# we will be running docker exec against it
command:
- sh
- -c
- sleep Infinity
- sh
- -c
- sleep Infinity
volumes:
- ./dashboard-screenshots:/screenshots
- ./report.yaml:/report.yaml
- ./dashboard-screenshots:/screenshots
- ./report.yaml:/report.yaml
pyroscope:
environment:
- PYROSCOPE_LOG_LEVEL=info
Expand Down
4 changes: 2 additions & 2 deletions benchmark/ci/pr/report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ baseName: main
targetName: pr

queries:
- name: "throughput"
- name: 'throughput'
base: 'rate(pyroscope_http_request_duration_seconds_count{handler="/ingest", instance="pyroscope:4040"}[5m])'
target: 'rate(pyroscope_http_request_duration_seconds_count{handler="/ingest", instance="pyroscope_main:4040"}[5m])'
diffThresholdPercent: 5
biggerIsBetter: true

- base: 'pyroscope_http_request_duration_seconds_count{handler="/ingest", instance="pyroscope:4040"}'
target: 'pyroscope_http_request_duration_seconds_count{handler="/ingest", instance="pyroscope_main:4040"}'
name: "total items processed"
name: 'total items processed'
diffThresholdPercent: 5
biggerIsBetter: true
17 changes: 8 additions & 9 deletions benchmark/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: "3.9"
version: '3.9'
services:
pyrobench:
env_file:
- run-parameters.env
- run-parameters.env
build:
context: ../
dockerfile: benchmark/Dockerfile
# we will be running docker exec against it
command:
- sh
- -c
- sleep Infinity
- sh
- -c
- sleep Infinity
volumes:
- ./dashboard-screenshots:/screenshots
- ./dashboard-screenshots:/screenshots

pyroscope:
environment:
Expand All @@ -28,8 +28,8 @@ services:
deploy:
resources:
limits:
cpus: "${PYROSCOPE_CPUS}"
memory: "${PYROSCOPE_MEMORY}"
cpus: '${PYROSCOPE_CPUS}'
memory: '${PYROSCOPE_MEMORY}'

prometheus:
image: prom/prometheus:v2.27.1
Expand All @@ -53,4 +53,3 @@ services:
volumes:
data-prometheus:
driver: local

20 changes: 3 additions & 17 deletions benchmark/grafana-provisioning/dashboards/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,7 @@
"links": [],
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
Expand Down Expand Up @@ -1639,9 +1637,7 @@
"displayMode": "gradient",
"orientation": "vertical",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
Expand Down Expand Up @@ -1816,17 +1812,7 @@
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
},
"timezone": "browser",
"title": "main",
Expand Down
10 changes: 5 additions & 5 deletions benchmark/grafana-provisioning/dashboards/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: 1

providers:
- name: dashboards
type: file
updateIntervalSeconds: 5
options:
path: /etc/grafana/provisioning/dashboards
- name: dashboards
type: file
updateIntervalSeconds: 5
options:
path: /etc/grafana/provisioning/dashboards
18 changes: 9 additions & 9 deletions benchmark/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# my global config
global:
scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
- static_configs:
- targets:
# - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
Expand All @@ -26,8 +26,8 @@ scrape_configs:
# scheme defaults to 'http'.

static_configs:
- targets:
- 'localhost:9090'
- 'pyroscope:4040'
- 'pyroscope_main:4040'
- 'pushgateway:9091'
- targets:
- 'localhost:9090'
- 'pyroscope:4040'
- 'pyroscope_main:4040'
- 'pushgateway:9091'
15 changes: 8 additions & 7 deletions benchmark/take-screenshot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
console.log("puppeteer start");
console.log('puppeteer start');

const puppeteer = require("puppeteer");
const puppeteer = require('puppeteer');

function timeout(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
Expand All @@ -9,15 +9,16 @@ function timeout(ms) {
const args = process.argv.slice(2);

const from = args[1];
console.log('from', from)

(async () => {
console.log(
'from',
from
)(async () => {
const browser = await puppeteer.launch({});
const page = await browser.newPage();
await page.setViewport({ width: 1600, height: 1280 });
await page.goto(
`http://localhost:8080/d/65gjqY3Mk/main?orgId=1&from=${from}`,
{ waitUntil: "networkidle2" }
{ waitUntil: 'networkidle2' }
);
await timeout(2000);
await page.screenshot({
Expand All @@ -27,4 +28,4 @@ console.log('from', from)
browser.close();
})();

console.log("puppeteer stop");
console.log('puppeteer stop');
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ignore:
- "**/*.pb.go" # auto-generated code
- '**/*.pb.go' # auto-generated code
10 changes: 5 additions & 5 deletions cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

[Cypress](https://www.cypress.io/) is a end-to-end testing library, used mainly to simulate real user scenario (ie. clicking around and interacting with).


# Running locally

While running the dev server, run `yarn cy:open`
Which will spawn a browser, click on the file that you want to work on. It will be refreshed automatically whenever you update that file.

Or run `yarn cy:ci` to run all tests.

# Writing tests
* Try to use [testids](https://kentcdodds.com/blog/making-your-ui-tests-resilient-to-change/) to select DOM elements
* Since our application is relatively simple, there's no need for Page Objects yet
* [Don't write small tests with single assertions](https://docs.cypress.io/guides/references/best-practices#Creating-tiny-tests-with-a-single-assertion)
* [Mock HTTP requests](https://docs.cypress.io/guides/guides/network-requests#Stub-Responses) when appropriate

- Try to use [testids](https://kentcdodds.com/blog/making-your-ui-tests-resilient-to-change/) to select DOM elements
- Since our application is relatively simple, there's no need for Page Objects yet
- [Don't write small tests with single assertions](https://docs.cypress.io/guides/references/best-practices#Creating-tiny-tests-with-a-single-assertion)
- [Mock HTTP requests](https://docs.cypress.io/guides/guides/network-requests#Stub-Responses) when appropriate
Loading