Skip to content

Commit

Permalink
Merge pull request #3786 from project-koku/release_prod-stable.9506
Browse files Browse the repository at this point in the history
Deployment commit for prod-stable
  • Loading branch information
dlabrecq authored Apr 10, 2024
2 parents d19b038 + db8db34 commit 88ba24e
Show file tree
Hide file tree
Showing 95 changed files with 251 additions and 225 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Run this workflow for PRs only. Travis is required to push via insights-frontend-builder-common scripts

name: Pull request
on:
pull_request:
branches: [ main, master, prod-beta, prod-stable, stage-beta, stage-stable ]
branches:
- main
- master
- prod-beta
- prod-stable
- stage-beta
- stage-stable
env:
BRANCH: ${{ github.base_ref }}

Expand All @@ -16,14 +20,16 @@ jobs:
node-version: [18]
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -34,13 +40,27 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Lint
if: ${{ success() }}
run: npm run lint

- name: Test
if: ${{ success() }}
run: npm test --coverage --maxWorkers=4
run: npm test -- --collect-coverage --max-workers=4

- name: Upload coverage report
if: ${{ success() }}
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
directory: coverage
plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely.

2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
- uses: actions/stale@v9
with:
days-before-issue-close: 14
days-before-issue-stale: 30
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
tag_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: prod-stable
- run: |
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Koku UI

[![AGPLv3][license-badge]][license]
[![Build Status][build-badge]][build]
[![Apache 2.0][license-badge]](https://github.com/project-koku/koku-ui/blob/main/LICENSE)
[![CI Status][build-badge]](https://github.com/project-koku/koku-ui/actions/workflows/tag_release.yml)
[![codecov][codecov-badge]](https://codecov.io/gh/project-koku/koku-ui)

React.js app for Cost Management.

User interface is based on Patternfly [![Patternfly][pf-logo]][patternfly]
User interface is based on [Patternfly].

To submit an issue, please visit https://issues.redhat.com/projects/COST/
Submit issues in [Jira].

## Requirements
* [NodeJS v18.15+][nodejs]
* [npm v9.5+][npm]

## Setup /etc/hosts entries (do this once)
## Setup `hosts` entries (do this once)

Edit the /etc/hosts file and add the following entries
Edit the `/etc/hosts` file and add the following entries
```
127.0.0.1 prod.foo.redhat.com
127.0.0.1 stage.foo.redhat.com
Expand All @@ -28,7 +29,7 @@ sudo bash scripts/patch-etc-hosts.sh

## Getting Started
1. Install requirements listed above.
2. Setup /etc/hosts entries 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.

Expand Down Expand Up @@ -109,7 +110,7 @@ npm start:static
npm start:csb:mfe
```

## Running local instances of Koku UI & Koku API
## Running local instances of Koku UI and Koku API
#### Koku UI

1. Start development server (Answer `yes` to run against local APIs)
Expand Down Expand Up @@ -193,14 +194,14 @@ http://localhost:1337/beta/settings/applications/cost-management

This [RELEASE][release-doc] doc describes how to release Koku UI to each staging environment.

[build]: https://travis-ci.com/project-koku/UI'
[build-badge]: https://img.shields.io/travis/project-koku/koku-ui.svg?style=for-the-badge
[build-badge]: https://github.com/project-koku/koku-ui/actions/workflows/tag_release.yml/badge.svg
[license-badge]: https://img.shields.io/github/license/project-koku/koku-ui.svg?longCache=true
[codecov-badge]: https://codecov.io/gh/project-koku/koku-ui/graph/badge.svg?token=1hjFIy1cRe

[koku-readme]: https://github.com/project-koku/koku#readme
[license-badge]: https://img.shields.io/github/license/project-koku/koku-ui.svg?longCache=true&style=for-the-badge
[license]: https://github.com/project-koku/koku-ui/blob/main/LICENSE
[nodejs]: https://nodejs.org/en/
[patch-etc-hosts]: https://github.com/RedHatInsights/insights-proxy/blob/master/scripts/patch-etc-hosts.sh
[pf-logo]: https://www.patternfly.org/v4/images/logo.4189e7eb1a0741ea2b3b51b80d33c4cb.svg
[patternfly]: https://www.patternfly.org/
[Patternfly]: https://www.patternfly.org/
[release-doc]: https://github.com/project-koku/koku-ui/blob/main/RELEASE.md
[npm]: https://https://www.npmjs.com/
[npm]: https://www.npmjs.com/
[Jira]: https://issues.redhat.com/projects/COST/
1 change: 0 additions & 1 deletion fec.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ module.exports = {
* Package can be re-enabled for sharing once chrome starts providing global routing package to all applications
*/
// exclude: ['react-router-dom'],
exclude: ['axios'], // Setting the base URL affects Cost Management APIs in OCM, when navigating between apps
exposes: {
'./RootApp': path.resolve(__dirname, './src/appEntry.tsx'),
},
Expand Down
6 changes: 3 additions & 3 deletions src/api/accountSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios';
import { axiosInstance } from 'api';

import type { PagedLinks, PagedMetaData } from './api';

Expand Down Expand Up @@ -38,10 +38,10 @@ export const AccountSettingsTypePaths: Partial<Record<AccountSettingsType, strin

export function fetchAccountSettings(settingsType: AccountSettingsType) {
const path = AccountSettingsTypePaths[settingsType];
return axios.get<AccountSettings>(`${path}`);
return axiosInstance.get<AccountSettings>(`${path}`);
}

export function updateAccountSettings(settingsType: AccountSettingsType, payload: AccountSettingsPayload) {
const path = AccountSettingsTypePaths[settingsType];
return axios.put(`${path}`, payload);
return axiosInstance.put(`${path}`, payload);
}
22 changes: 17 additions & 5 deletions src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AxiosRequestConfig } from 'axios';
import type { AxiosInstance, AxiosRequestConfig } from 'axios';
import axios from 'axios';

export interface PagedMetaData {
Expand All @@ -18,10 +18,10 @@ export interface PagedResponse<D = any, M = any> {
data: D[];
}

export function initApi({ version }: { version: string }) {
axios.defaults.baseURL = `/api/cost-management/${version}/`;
axios.interceptors.request.use(authInterceptor);
}
// export function initApi({ version }: { version: string }) {
// axios.defaults.baseURL = `/api/cost-management/${version}/`;
// axios.interceptors.request.use(authInterceptor);
// }

export function authInterceptor(reqConfig: AxiosRequestConfig) {
return {
Expand All @@ -31,3 +31,15 @@ export function authInterceptor(reqConfig: AxiosRequestConfig) {
} as any,
};
}

// Create an Axios instance
//
// Note: Setting global defaults may affect the base URL in Cost Management, HCS, and OCM, when navigating between apps
// See https://issues.redhat.com/browse/RHCLOUD-25573
const axiosInstance: AxiosInstance = axios.create({
baseURL: '/api/cost-management/v1/',
});

axiosInstance.interceptors.request.use(authInterceptor);

export default axiosInstance;
12 changes: 6 additions & 6 deletions src/api/costModels.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import axios from 'axios';
import { axiosInstance } from 'api';

import type { CostModelRequest } from './costModels';
import { addCostModel, deleteCostModel, fetchCostModels, updateCostModel } from './costModels';

test('api get cost models calls axios to costmodels', () => {
fetchCostModels();
expect(axios.get).toBeCalledWith('cost-models/');
expect(axiosInstance.get).toBeCalledWith('cost-models/');
});

test('api get cost models calls axios to costmodels with query', () => {
const query = 'limit=20&offset=10';
fetchCostModels(query);
expect(axios.get).toBeCalledWith(`cost-models/?${query}`);
expect(axiosInstance.get).toBeCalledWith(`cost-models/?${query}`);
});

test('add cost model calls axios post', () => {
Expand All @@ -33,7 +33,7 @@ test('add cost model calls axios post', () => {
],
};
addCostModel(request);
expect(axios.post).toBeCalledWith('cost-models/', request);
expect(axiosInstance.post).toBeCalledWith('cost-models/', request);
});

test('update cost model calls axios put', () => {
Expand All @@ -55,10 +55,10 @@ test('update cost model calls axios put', () => {
],
};
updateCostModel('123abc456def', request);
expect(axios.put).toBeCalledWith('cost-models/123abc456def/', request);
expect(axiosInstance.put).toBeCalledWith('cost-models/123abc456def/', request);
});

test('delete cost model calls axios delete', () => {
deleteCostModel('123abc456def');
expect(axios.delete).toBeCalledWith('cost-models/123abc456def/');
expect(axiosInstance.delete).toBeCalledWith('cost-models/123abc456def/');
});
12 changes: 6 additions & 6 deletions src/api/costModels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios';
import { axiosInstance } from 'api';

import type { PagedResponse } from './api';
import type { Rate, RateRequest } from './rates';
Expand Down Expand Up @@ -45,21 +45,21 @@ export interface CostModelRequest {
export type CostModels = PagedResponse<CostModel>;

export function fetchCostModels(query = '') {
return axios.get<CostModels>(`cost-models/${query && '?'}${query}`);
return axiosInstance.get<CostModels>(`cost-models/${query && '?'}${query}`);
}

export function fetchCostModel(uuid: string) {
return axios.get<CostModels>(`cost-models/${uuid}/`);
return axiosInstance.get<CostModels>(`cost-models/${uuid}/`);
}

export function addCostModel(request: CostModelRequest) {
return axios.post(`cost-models/`, request);
return axiosInstance.post(`cost-models/`, request);
}

export function updateCostModel(uuid: string, request: CostModelRequest) {
return axios.put(`cost-models/${uuid}/`, request);
return axiosInstance.put(`cost-models/${uuid}/`, request);
}

export function deleteCostModel(uuid: string) {
return axios.delete(`cost-models/${uuid}/`);
return axiosInstance.delete(`cost-models/${uuid}/`);
}
4 changes: 2 additions & 2 deletions src/api/export/awsExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/awsReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/awsOcpExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/awsOcpReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/azureExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/azureReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/azureOcpExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/azureOcpReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/gcpExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/gcpReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/gcpOcpExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/gcpOcpReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/ibmExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/ibmReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
4 changes: 2 additions & 2 deletions src/api/export/ociExport.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { axiosInstance } from 'api';
import { ReportTypePaths } from 'api/reports/ociReports';
import type { ReportType } from 'api/reports/report';
import axios from 'axios';

export function runExport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];
return axios.get<string>(`${path}?${query}`, {
return axiosInstance.get<string>(`${path}?${query}`, {
headers: {
Accept: 'text/csv',
},
Expand Down
Loading

0 comments on commit 88ba24e

Please sign in to comment.