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

Production Increment 0.1.16 #293

Merged
merged 10 commits into from
May 20, 2020
Merged
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: node_js
sudo: required
notifications:
email: false
slack:
rooms:
- rooms:
- secure: juuizlfiQolXbqy4L2nfODB1K8xiSGvUrzsT3XeXIsQqX7yCYVvnRUssKLbqgLM9m85kgXJk1ef0qwjJoliNqGcrALTZLHPTkxWwTnV7tPEVS/4uQPSyy+DDHDwrTzCrF3qhCqyKJ6vB18z22qm3qLgStmNj4p1ZLznsdJR/u7U3spJ+WLL70QSNHCQy/5QjRDDiR3oqWdXjhVcUCeV+v/2CtfqK3dqYtzCL/b7z8lm/YbV6w1Rd8mwzTgLstbzjrvR/gq2IPALzzJTq1S8lXtV7ZtbYz4bjB8RNCRZFJrjBUH4CqD1oUskit4RRe+ilVs8qNQh0Tt3whsOdbJoRXJn2B/NVxppp2WGlODdsuMgfNh5iBocHKN3Qo4mONbstnHFG99Hr7L8GbUugJHEQlrZn1xRyO9ulyVp+hFp8/F088NNyhnd3+lERUPA5/4+HPQh6Ea+PyKq2TR41VoDGcRDBS4VY/6PfLEJzxEBjwRAAemfvtOFTUu2EocuAllPX1vMA4b1j7Wm+Bs7wft6nEcVdftVanfAgx4dNksnaS8zN9II8rdtBci2yXYJ6J+e+REDn/2IrHaUwr0N9BojYc0ePUElDcygW4Kk1oGklHp681j2zhi1Gt7rbuae1C9fD4QHnryx59uVH5NXqDsXI5EbwTJE3zvzRz9SzmyDqV5A=
- rooms:
- secure: cB1tOG48V5iia0O2dJ9+1gusBSCaohu5TR8PeWbqug/Yho+ZCQ3rp7Tfd7fRyYsf9ztWdu6G+VrHwOboR08Aef7cttZ743j/aXwo5m50Q9Ne3fkNzEUjL8IGeM4MtlRtwruD54RQmPzjmHjEapfx0dX2AHkB/8Zrnjs36YzPST1kT/YYrub9Kv5wUXB0TlzWmrRGj+pPGqBmJVksxQFxvbvafRcKI3kj91maJQhBHQe+19GboJbFOnwzPTPAL7Lf7j70ZmbPlQVG3G3VjN/QUALqaiwjlgH0owLHjBbDrMt8cpPoTq8Uw6ANBWYzENBMzHeiBwz0jqTY/BBP06WCxJSJCgOgd90L93/LAbJYiTyvpfAt8dOdWk7RhKy0L3kIalj5Mff8/3zDyLDOvd9Xtn7topHJv/5SBV6ZZVUvEJTxgEQq9337YEOka2omPvwt7UfHNcT/PH4flV70cy/OdR6J4x1UIKIUgX0iWYMZUj7QZqUhLybXv5BRS0vQTg4V8C7uvQ4aE8hzkv+pjXZ5aL5POtJhrgNPiO9iIHXtV/EUoGrT9iibijyQbWPusloJBwmPWkZ2j3UbaCY5bPTgnHnaPllnE3WKuTwxQA4bIL1Ma2C3yv2RSgfVvwM+pekeNsaVmpOD5xlcNYPPuW5bLE/jqhLmeKJaKQWujoC0glU=
node_js:
- "10"
- 12
cache: yarn
jobs:
include:
Expand All @@ -16,9 +17,11 @@ jobs:
script: yarn test:ci
after_success: codecov
- stage: Beta Deploy
script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh | bash -s
script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh
| bash -s
- stage: Stable Deploy
script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh | bash -s
script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh
| bash -s
env:
global:
- REPO="git@github.com:RedHatInsights/curiosity-frontend-build"
Expand Down
91 changes: 68 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,93 @@
# Contributing
Contributing encompasses repository specific requirements and the global [Insights guidelines](https://cloud.redhat.com/docs/storybook?path=/story/welcome--getting-started).

## Commits
In an effort to bring in future automation around
## Install
Before developing you'll need to install:
* [NodeJS and NPM](https://nodejs.org/)
* [Docker](https://docs.docker.com/engine/installation/)
* And [Yarn](https://yarnpkg.com)

### Docker & Mac
Setting Docker up on a Mac? Install the appropriate package and you should be good to go. To check if everything installed correctly you can try these steps.
* At a terminal prompt type

```
$ docker run hello-world
```

### Docker & Linux
Setting Docker up on a Linux machine can include an additional convenience step. If you're having to prefix "sudo" in front of your Docker commands you can try these steps.
* [Docker postinstall documentation](https://docs.docker.com/install/linux/linux-postinstall/)

### Yarn
Once you've installed NodeJS you can use NPM to perform the [Yarn](https://yarnpkg.com) install

```
$ npm install yarn -g
```

You can also use [Homebrew](https://brew.sh/)

```
$ brew update
$ brew install yarn
```

## Git process
### Commits
In an effort to continue enhancing future automation around
[CHANGELOG.md](./CHANGELOG.md) and tagging we make use of [Standard Version](https://github.com/conventional-changelog/standard-version#readme) and [Conventional Commits](https://www.conventionalcommits.org).

It's encouraged that commit messaging follow the format
It's required that commit messaging follow the format
```
<type>[optional scope]: <issue number><description>
```

Settings for [Standard Version](https://github.com/conventional-changelog/standard-version#readme) can be found in [package.json](./package.json)

## Branching, Pull Requests, and Releases

### Branches
Curiosity primarily makes use of the branches `master`, `qa`, and `ci`.
### Branching, Pull Requests, and Releases
Curiosity makes use of the branches `master`, `stage`, `qa`, and `ci`.
- `master` branch is a protected representation of production environments
- Adding commits, or a PR, into `master` should generate a `prod-stable` branch within the deploy repository [curiosity-frontend-build](https://github.com/RedHatInsights/curiosity-frontend-build)
- The `prod-stable` branch is manually deployed through coordination with the operations team.
- `stage` branch is a protected representation of production environments
- Adding commits, or a PR, into `stage` should generate a `prod-beta` branch within the deploy repository [curiosity-frontend-build](https://github.com/RedHatInsights/curiosity-frontend-build)
- The `prod-beta` branch is manually deployed through coordination with the operations team.
- `qa` branch is a representation of `qa-stable`, and `ci-stable`.
- Adding commits, or a PR, into `ci-stable` should generate `ci-*` and `qa-*` branches within the deploy repository [curiosity-frontend-build](https://github.com/RedHatInsights/curiosity-frontend-build)
- The `ci-*` and `qa-*` branches are automatically deployed within an averaged time for both `https://ci.*.redhat.com` and `https://qa.*.redhat.com`
- In the future, once the API is fully deployed to QA, this will be a representation of `qa-beta` and `qa-stable`
- `ci` branch is a representation of `ci-beta`, and `qa-beta`.
- Adding commits, or a PR, into `ci-beta` should generate `ci-*` and `qa-*` branches within the deploy repository [curiosity-frontend-build](https://github.com/RedHatInsights/curiosity-frontend-build)
- The `ci-*` and `qa-*` branches are automatically deployed within an averaged time for both `https://ci.*.redhat.com` and `https://qa.*.redhat.com`

#### Additional branches
A staging branch can also be utilized.
- `stage` branch is a protected representation of production environments
- Adding commits, or a PR, into `stage` should generate a `prod-beta` branch within the deploy repository [curiosity-frontend-build](https://github.com/RedHatInsights/curiosity-frontend-build)
- The `prod-beta` branch is manually deployed through coordination with the operations team.
- In the future, once the API is fully deployed to QA, this will be a representation of `ci-beta` and `ci-stable`

#### Branching and Pull Request Workflow
It is preferred that all work is handled through GitHub's fork and pull workflow. Working directly on the master repository is discouraged
since a form of Continuous Integration is implemented and dependent on branch structure.

1. General development PRs should be opened against the `ci` branch.
1. It is preferred that PRs to `qa` originate from `ci`, but development PRs opened against `qa` are allowed.
1. PRs to master branch are considered production ready releases. It is preferred that PRs originate from `qa`, or `stage` if available.
1. Development PRs opened against master, unless a team agreed exception occurs, will be closed.
It is required that all work is handled through GitHub's fork and pull workflow.

**Working directly on the master repository is highly discouraged since a form of Continuous Integration is implemented and dependent on branch structure.**

1. General development PRs should almost always be opened against the `ci` branch.
1. It is preferred that PRs to `qa` originate from `ci`, but testing related fixes and general PRs opened against `qa` are allowed.
1 PRs from `ci` to `qa` are allowed
1. PRs from `qa` to `stage` are preferred.
1. PRs to `stage` require a QE team members approval/sign-off.
1. PRs to `master` are only allowed from `stage`.
1. PRs to `master` branch are considered production ready releases.
1. Development or testing PRs opened against master, unless a team agreed exception occurs, will be closed.
1. All PRs to production, master branch, should have a final review, coordination, from Quality Engineering.

```
PR -> ci <-> qa -> stage -> master
PR fork -> ci <-> qa -> stage -> master
```

### Releases and Tagging
1. Merging a PR into `master` is considered production ready.
1. Merging a PR into `master` doesn't require tagging and [CHANGELOG.md](./CHANGELOG.md) updates.
1. Tagging and `CHANGELOG.md` updates should be coordinated against a consistent release cycle, and can take place at an independent time.
1. Tagging should make use of semver.
1. Manipulating tags against commits directly should be avoided in favor of a semantic version increment.
1. Manipulating tags against commits directly should be avoided in favor of a semantic version increment, iteration.
1. Once a release commit and tag have been implemented `stage`, `qa`, and `ci` will be rebased accordingly.

## Serving content, or getting everything to run in your local environment.
To serve content you'll need to have Docker, Node, and Yarn installed.
Expand All @@ -71,6 +107,15 @@ Serving content comes in 3 variations
Occasionally the proxy setup will attempt to connect, acknowledge that it's connected, but then fail to load the GUI.
Things to try:

#### It's the Port, maybe?
The API requires a secure origin header within its AJAX/XHR calls.
1. Stop the build
1. Confirm within `package.json` that the NPM scripts
- `$ yarn api:proxy` has a port parameter setting of `443`
- `$ yarn api:proxy` has the `domain` or `-d` parameter setup like `...proxy.api.sh -d "https://ci.foo.redhat.com/beta/subscriptions/"...`
1. Run the build again, `$ yarn start:proxy`
1. Confirm you browser is pointed at `https://ci.foo.redhat.com/...`

#### It's Docker?
1. Stop the build
1. Restart Docker
Expand Down Expand Up @@ -205,5 +250,5 @@ After setting up the repository...
```
$ yarn test:dev
```
1. Make sure your browser opened around the domain `https://*.foo.redhat.com:1337`
1. Make sure your browser opened around the domain `https://*.foo.redhat.com/`
1. Start developing...
24 changes: 3 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,9 @@ A web user interface for subscription reporting, based on [Patternfly <img src="
Before developing for Curiosity Frontend, the basic requirements:
* Your system needs to be running [NodeJS version 10+ and NPM](https://nodejs.org/)
* [Docker](https://docs.docker.com/engine/installation/)
* And [Yarn 1.16+](https://yarnpkg.com) for dependency and script management.

### Docker & Mac
Setting Docker up on a Mac? Install the appropriate package and you should be good to go. To check if everything installed correctly you can try these steps.
* At a terminal prompt type

```
$ docker run hello-world
```

### Docker & Linux
Setting Docker up on a Linux machine can include an additional convenience step. If you're having to prefix "sudo" in front of your Docker commands you can try these steps.
* [Docker postinstall documentation](https://docs.docker.com/install/linux/linux-postinstall/)

### Yarn
We recommend using [Homebrew](https://brew.sh/) to do the install.

```
$ brew update
$ brew install yarn
```
* And [Yarn 1.20+](https://yarnpkg.com) for dependency and script management.

For in-depth tooling install guidance see the [contribution guidelines](./CONTRIBUTING.md#Install)

## Development, Quick Start

Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"api:dev": "mock -p 5000 -w ./src/services",
"api:docs": "node ./scripts/openapi.docs.js",
"api:proxy-hosts": "sh ./scripts/proxy.api.sh -s",
"api:proxy": "sh ./scripts/proxy.api.sh -d \"ci.foo.redhat.com\" -p 1337 -c \"$(pwd)/config/spandx.config.js\"",
"api:proxy": "sh ./scripts/proxy.api.sh -d \"https://ci.foo.redhat.com/beta/subscriptions/\" -p 443 -c \"$(pwd)/config/spandx.config.js\"",
"api:proxyClean": "sh ./scripts/proxy.api.sh -u",
"build": "run-s -l build:pre build:js build:post test:integration",
"build:js": "react-scripts build",
Expand All @@ -64,7 +64,7 @@
"release": "standard-version",
"start": "run-s dev:chrome; run-p -l api:dev start:js",
"start:js": "react-scripts start",
"start:proxy": "sh -ac '. ./.env.proxy; open https://ci.foo.redhat.com:1337/beta/subscriptions/; run-s api:proxy-hosts; run-p -l start:js api:proxy'",
"start:proxy": "sh -ac '. ./.env.proxy; run-s api:proxy-hosts; run-p -l start:js api:proxy'",
"start:standalone": "rm ./.env.development.local; run-p -l api:dev start:js",
"test": "run-s test:lint test:ci",
"test:ci": "export CI=true; react-scripts test --env=jsdom --roots=./src --coverage",
Expand All @@ -76,29 +76,29 @@
"test:local": "react-scripts test --env=jsdom --roots=./src"
},
"dependencies": {
"@patternfly/patternfly": "2.71.3",
"@patternfly/react-charts": "5.3.18",
"@patternfly/react-core": "3.153.3",
"@patternfly/react-icons": "3.15.15",
"@patternfly/react-styles": "3.7.12",
"@patternfly/react-tokens": "2.8.12",
"@redhat-cloud-services/frontend-components": "1.0.12",
"@redhat-cloud-services/frontend-components-notifications": "1.0.2",
"@redhat-cloud-services/frontend-components-utilities": "1.0.0",
"@patternfly/patternfly": "2.71.6",
"@patternfly/react-charts": "5.3.19",
"@patternfly/react-core": "3.153.13",
"@patternfly/react-icons": "3.15.16",
"@patternfly/react-styles": "3.7.13",
"@patternfly/react-tokens": "2.8.13",
"@redhat-cloud-services/frontend-components": "1.0.24",
"@redhat-cloud-services/frontend-components-notifications": "1.0.3",
"@redhat-cloud-services/frontend-components-utilities": "1.0.3",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"i18next": "^19.3.4",
"i18next": "^19.4.4",
"i18next-xhr-backend": "^3.2.2",
"js-cookie": "^2.2.1",
"locale-code": "^2.0.2",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"node-sass": "^4.13.1",
"moment": "^2.25.3",
"node-sass": "^4.14.1",
"numbro": "^2.2.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-i18next": "^11.3.4",
"react-i18next": "^11.4.0",
"react-redux": "^7.2.0",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
Expand All @@ -108,32 +108,32 @@
"redux-promise-middleware": "^6.1.2",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"victory": "^34.1.3",
"victory-core": "^34.1.3",
"victory-legend": "^34.1.3"
"victory": "^34.2.0",
"victory-core": "^34.2.0",
"victory-legend": "^34.2.0"
},
"devDependencies": {
"apidoc-mock": "^3.0.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-jsdoc": "^22.1.0",
"eslint-plugin-jest": "^23.9.0",
"eslint-plugin-jsdoc": "^24.0.6",
"eslint-plugin-json": "^2.1.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^3.0.0",
"eslint-plugin-react-hooks": "^4.0.0",
"express": "^4.17.1",
"gettext-extractor": "^3.5.2",
"moxios": "^0.4.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"redux-mock-store": "^1.5.4",
"standard-version": "^7.1.0",
"standard-version": "^8.0.0",
"swagger-ui-express": "^4.1.4",
"yamljs": "^0.3.0"
},
Expand Down
4 changes: 3 additions & 1 deletion public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"dropdownMonthly": "Monthly",
"dropdownQuarterly": "Quarterly",
"dropdownPlaceholder": "Select date range",
"noDataLabel": "No data",
"infiniteThresholdLabel": "unlimited",
"noDataLabel": "no data",
"noDataErrorLabel": "No data",
"dateLabel": "Date",
"coresLabel": "Cores",
"socketsLabel": "Sockets",
Expand Down
15 changes: 12 additions & 3 deletions scripts/proxy.api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ runProxy()
RUN_CONFIG="-e CUSTOM_CONF=true -v ${RUN_CONFIG}:/config/spandx.config.js"
fi

docker run -d --rm -p $RUN_PORT:1337 $RUN_CONFIG -e PLATFORM -e PORT -e LOCAL_API -e SPANDX_HOST -e SPANDX_PORT --name $RUN_NAME $RUN_CONTAINER >/dev/null
docker run -d --rm -p $RUN_PORT:$RUN_PORT $RUN_CONFIG -e PLATFORM -e PORT -e LOCAL_API -e SPANDX_HOST -e SPANDX_PORT=$RUN_PORT --name $RUN_NAME $RUN_CONTAINER >/dev/null
fi

checkContainerRunning $RUN_NAME

if [ ! -z "$(docker ps | grep $RUN_CONTAINER)" ]; then
printf " ${YELLOW}Container: $(docker ps | grep $RUN_CONTAINER | cut -c 1-50)${NOCOLOR}\n"
echo " Development proxy running: http://${RUN_DOMAIN}:${RUN_PORT}/"
echo " Development proxy running on ${RUN_PORT}: ${RUN_DOMAIN}"
printf " To stop: $ ${YELLOW}docker stop ${RUN_NAME}${NOCOLOR}\n"
open "${RUN_DOMAIN}"
fi

exit 0
Expand All @@ -168,8 +169,8 @@ runProxy()
YELLOW="\e[33m"
NOCOLOR="\e[39m"

DOMAIN="localhost"
PORT=1337
DOMAIN=""
CONFIG=""
UPDATE=false
HOST_ONLY=false
Expand All @@ -193,6 +194,14 @@ runProxy()
esac
done

if [ -z "$DOMAIN" ]; then
if (( $PORT % 2 )); then
DOMAIN="https://localhost:$PORT"
else
DOMAIN="http://localhost:$PORT"
fi
fi

if [ "$UPDATE" = true ]; then
printf "${YELLOW}Updating ${CONTAINER_NAME}, Docker and data...${NOCOLOR}\n"
docker stop -t 0 $CONTAINER_NAME
Expand Down
12 changes: 2 additions & 10 deletions src/common/dateHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,8 @@ const getCurrentDate = () =>
* @returns {{endDate: Date, startDate: Date}}
*/
const setRangedDateTime = ({ date, subtract, measurement }) => ({
startDate: moment
.utc(date)
.startOf(measurement)
.subtract(subtract, measurement)
.toDate(),
endDate: moment
.utc(date)
.startOf(measurement)
.endOf('days')
.toDate()
startDate: moment.utc(date).startOf(measurement).subtract(subtract, measurement).toDate(),
endDate: moment.utc(date).startOf(measurement).endOf('days').toDate()
});

const defaultDateTime = setRangedDateTime({ date: getCurrentDate(), subtract: 30, measurement: 'days' });
Expand Down
Loading