diff --git a/README.md b/README.md index d7fd93d9..1358e981 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Hybrid Committed Spend +# Hybrid Committed Spend UI [![AGPLv3][license-badge]][license] [![Build Status][build-badge]][build] @@ -11,45 +11,75 @@ User interface is based on Red Hat cloud service frontend components and Pattern To submit an issue, please visit https://issues.redhat.com/projects/HCS/issues -## Initial etc/hosts setup +## Requirements +* [NodeJS v18.15+][nodejs] +* [npm v9.5+][npm] -In order to access the https://[env].foo.redhat.com in your browser, you have to add entries to your `/etc/hosts` file. This is a **one-time** setup that has to be done only once (unless you modify hosts) on each machine. +## Setup /etc/hosts entries (do this once) -To setup the hosts file run following command: +Edit the /etc/hosts file and add the following entries ``` -npm run patch:hosts +127.0.0.1 prod.foo.redhat.com +127.0.0.1 stage.foo.redhat.com ``` -If this command throws an error run it as a `sudo`: +Alternatively, run the [patch-etc-hosts.sh][patch-etc-hosts] script from the insights-proxy repo ``` -sudo npm run patch:hosts +sudo bash scripts/patch-etc-hosts.sh ``` -## Getting started +## Getting Started +1. Install requirements listed above. +2. Setup /etc/hosts entries listed above. +3. Clone the repository, and open a terminal in the base of this project. +4. Run the command `npm install` to install all the dependencies. -1. ```npm install``` +## Building +``` +npm build +``` -2. ```npm run start``` +## Testing +``` +npm test +``` -3. Open browser in URL listed in the terminal output. For example: +## Running Koku UI against a hosted Koku API, using webpack proxy +Note that this approach currently supports the Insights stage-beta, stage-stable, prod-beta, and prod-stable environments. +1. Start development server ``` -https://stage.foo.redhat.com:1337/beta/business-services/hybrid-committed-spend +npm start ``` -### Testing +Follow the prompts that follow. + +* Do you want to use local api? `no` +* Which platform environment you want to use `stage` +* Which Chrome environment you want to use? `beta` + +2. Open the following URL +``` +https://stage.foo.redhat.com:1337/beta/business-services/hybrid-committed-spend +``` -`npm run verify` will run `npm run lint` (eslint) and `npm test` (Jest) +### Running Koku UI with a local Cloud Services Backend -## Testing UI changes locally with Cloud Services Config +See https://github.com/RedHatInsights/chrome-service-backend/blob/main/docs/cloud-services-config.md#serving-files-locally -See https://github.com/RedHatInsights/cloud-services-config#testing-your-changes-locally +1. Serve files locally from Cloud Services Backend repo +``` +make dev-static-node +``` -```npm run start:csc``` +2. Start development server in Hybrid Committed Spend repo +``` +npm start:csb +``` ## Deploying -This [release][release-doc] doc describes how to release the UI to each staging environment. +This [release][release-doc] doc describes how to release the Hybrid Committed Spend UI to each staging environment. [build]: https://app.travis-ci.com/github/RedHatInsights/hybrid-committed-spend-ui [build-badge]: https://img.shields.io/travis/RedHatInsights/hybrid-committed-spend-ui.svg?style=for-the-badge diff --git a/RELEASE.md b/RELEASE.md index 781876a9..00ef13a6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,10 +1,10 @@ -# Releasing Hybrid Committed Spend +# Releasing Hybrid Committed Spend UI -This doc describes how to release the UI to each staging environment. Note that this should be done in order for testing purposes; stage-stable, prod-beta, and finally prod-stable +This doc describes how to release the Hybrid Committed Spend UI to each staging environment. Note that this should be done in order for testing purposes; stage-stable, prod-beta, and finally prod-stable ## Release script -Using our script ensures that code is always pulled from the correct branches. For example, we always pull from: +The release script creates a PR with a unique SHA, used for a namespace \`ref\` in the app-interface repo. The script also ensures that code is always pulled from the correct branches. For example, we always: 1. Pull from master when pushing to stage-stable 2. Pull from stage-stable when pushing to prod-beta @@ -28,19 +28,31 @@ sh scripts/release-branch.sh -b sh scripts/release-branch.sh -p ``` -## Travis build +## Deployment -Whenever a branch is merged, our Travis script automatically builds and pushes a bundle to our RedHatInsights build repo. +After all PRs have been merged, update the \`hybrid-committed-spend-frontend\` resource in https://gitlab.cee.redhat.com/service/app-interface/-/blob/master/data/services/insights/hybrid-committed-spend/deploy.yml -To view our Travis build, see https://app.travis-ci.com/github/RedHatInsights/hybrid-committed-spend-ui/builds +Use the latest commit of each branch to update namespaces \`ref\` in the app-interface repo. Don't use a merge commit, SHAs must be unique when images are created for each branch. -## RedHatInsights build repo - -After each successfully Travis build, you should see a new commit here https://github.com/RedHatInsights/hybrid-committed-spend-ui-build. - -At this point, the Insights pipeline takes over and the bundle should be available shortly in the expected staging environment. - -Depending on how many builds are queued, this could take a few minutes or hours. Typically, the prod-stable environment is updated within 15-30 min. +``` +- name: hybrid-committed-spend-frontend + ... + # Stage Stable Deployment + - namespace: + $ref: /services/insights/frontend-operator/namespaces/stage-frontends.yml + ref: 4b19fba6c54b6679a7be5010b9d97a5aab1fd48c // Replace with latest SHA for stage-beta branch + ... + # Prod Beta Deployment + - namespace: + $ref: /services/insights/frontend-operator/namespaces/prod-beta-frontends.yml + ref: 13f34a18f2c97faa814228fa38b5f5d32bed2ba3 // Replace with latest SHA for prod-beta branch + ... + # Prod Stable Deployment + - namespace: + $ref: /services/insights/frontend-operator/namespaces/prod-frontends.yml + ref: fbb0a70816dd656dbf6cb06654ed3c5d7e1ab379 // Replace with latest SHA for prod-stable branch + ... +``` ## Testing @@ -54,6 +66,6 @@ Please ensure expected changes have been updated before releasing to the next st ## Troubleshooting -If a staging environment has not updated as expected, it's best to ask questions in the forum-consoledot-ui channel of http://coreos.slack.com. +If a staging environment has not updated as expected, it's best to ask questions in the forum-consoledot-ui or proj-fecontainer-migration channels of http://coreos.slack.com. Alternatively, open a Jira issue under the "ConsoleDot Platform (console.redhat.com) (RHCLOUD)" project category. For an example, see https://issues.redhat.com/browse/RHCLOUD-18259 diff --git a/fec.config.js b/fec.config.js index abc6cd76..d9e4cfa5 100644 --- a/fec.config.js +++ b/fec.config.js @@ -89,8 +89,8 @@ module.exports = { /** * Chrome services backend config routes, typically localhost:8000 */ - ...(process.env.CLOUD_SERVICES_CONFIG_PORT && { - '/api/chrome-service/v1/static': { host: `http://localhost:${process.env.CLOUD_SERVICES_CONFIG_PORT}` }, + ...(process.env.CLOUD_SERVICES_BACKEND_PORT && { + '/api/chrome-service/v1/static': { host: `http://localhost:${process.env.CLOUD_SERVICES_BACKEND_PORT}` }, }), }, }; diff --git a/package.json b/package.json index abd27840..1e0a2da2 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,8 @@ "patch:hosts": "fec patch-etc-hosts", "postinstall": "ts-patch install && rm -rf .cache", "start": "HMR=true fec dev", - "start:csc": "CLOUD_SERVICES_CONFIG_PORT=8000 npm start", + "start:csb": "CLOUD_SERVICES_BACKEND_PORT=8000 npm start", "start:hmr": "HMR=true npm start", - "start:static": "BETA=true fec static", "stats": "npm run build:prod --profile --json > stats.json", "test": "jest --no-cache", "test:clean": "jest --clearCache",