Skip to content

Commit

Permalink
Merge pull request #2575 from andrewballantyne/merge-main
Browse files Browse the repository at this point in the history
Merge main into `f/pipelines-v2`
  • Loading branch information
openshift-merge-bot[bot] authored Mar 8, 2024
2 parents 2859b99 + ff14753 commit eb9a60a
Show file tree
Hide file tree
Showing 362 changed files with 17,188 additions and 29,055 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ node_modules/
tests/
**/__mocks__/
**/__tests__/
**/.storybook/
scripts/
manifests/

Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Self checklist (all need to be checked):
- [ ] The developer has manually tested the changes and verified that the changes work
- [ ] Commits have been squashed into descriptive, self-contained units of work (e.g. 'WIP' and 'Implements feedback' style messages have been removed)
- [ ] Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
- [ ] The developer has added tests or explained why testing cannot be added (unit tests & storybook for related changes)
- [ ] The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

If you have UI changes:
<!--- You can ignore these if you are doing manifest, backend, internal logic, etc changes; aka non-UI / visual changes -->
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ jobs:
- name: Install Node.js packages
if: ${{ steps.repo-cache.outputs.cache-hit != 'true' || steps.backend-cache.outputs.cache-hit != 'true' || steps.frontend-cache.outputs.cache-hit != 'true' }}
run: npm install
- name: Install Playwright Browsers
working-directory: ./frontend
run: npx playwright install --with-deps
- name: Check for uncomitted changes
run: |
git diff --exit-code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vuln_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
sarif_file: 'scan_result.sarif'

- name: Archive scan results to GitHub
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: trivyResult
path: 'scan_result.sarif'
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ or
npm run make:login
```

> Note: You'll need to reauthenticate using one of the above steps and restart `backend` each day.
## Debugging and Testing

See [frontend testing guidelines](docs/testing.md) for more information.
Expand Down
10 changes: 8 additions & 2 deletions backend/src/routes/api/namespaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ import { logRequestDetails } from '../../../utils/fileUtils';
export default async (fastify: KubeFastifyInstance): Promise<void> => {
fastify.get(
'/:name/:context',
async (request: OauthFastifyRequest<{ Params: { name: string; context: string } }>) => {
async (
request: OauthFastifyRequest<{
Params: { name: string; context: string };
Querystring: { dryRun?: string };
}>,
) => {
logRequestDetails(fastify, request);

const { name, context: contextAsString } = request.params;
const { dryRun } = request.query;

const context = parseInt(contextAsString) as NamespaceApplicationCase;

return applyNamespaceChange(fastify, request, name, context);
return applyNamespaceChange(fastify, request, name, context, dryRun);
},
);
};
3 changes: 2 additions & 1 deletion backend/src/routes/api/namespaces/namespaceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const applyNamespaceChange = async (
request: OauthFastifyRequest,
name: string,
context: NamespaceApplicationCase,
dryRun?: string,
): Promise<{ applied: boolean }> => {
if (name.startsWith('openshift') || name.startsWith('kube')) {
// Kubernetes and OpenShift namespaces are off limits to this flow
Expand Down Expand Up @@ -120,7 +121,7 @@ export const applyNamespaceChange = async (
}

return fastify.kube.coreV1Api
.patchNamespace(name, { metadata: { labels } }, undefined, undefined, undefined, undefined, {
.patchNamespace(name, { metadata: { labels } }, undefined, dryRun, undefined, undefined, {
headers: { 'Content-type': PatchUtils.PATCH_FORMAT_JSON_MERGE_PATCH },
})
.then(() => ({ applied: true }))
Expand Down
35 changes: 35 additions & 0 deletions backend/src/routes/api/prometheus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@ const handleError = (e: createError.HttpError) => {
*/

module.exports = async (fastify: KubeFastifyInstance) => {
fastify.post(
'/query',
async (
request: OauthFastifyRequest<{
Body: { query: string };
}>,
): Promise<{ code: number; response: PrometheusQueryResponse }> => {
logRequestDetails(fastify, request);
const { query } = request.body;
return callPrometheusThanos<PrometheusQueryResponse>(fastify, request, query).catch(
handleError,
);
},
);

fastify.post(
'/queryRange',
async (
request: OauthFastifyRequest<{
Body: { query: string };
}>,
): Promise<{ code: number; response: PrometheusQueryRangeResponse }> => {
logRequestDetails(fastify, request);
const { query } = request.body;
return callPrometheusThanos<PrometheusQueryRangeResponse>(
fastify,
request,
query,
QueryType.QUERY_RANGE,
).catch(handleError);
},
);

// TODO the /pvc, /bias and /serving routes here should be removed in favor of the generic /query and /queryRange above

fastify.post(
'/pvc',
async (
Expand Down
1 change: 1 addition & 0 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export type OdhApplication = {
description: string;
displayName: string;
docsLink: string;
hidden?: boolean | null;
enable?: {
actionLabel: string;
description?: string;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/componentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const getCSVForApp = (
}

const subsStatus = getSubscriptions();
const subStatus = subsStatus.find((st) => st.installedCSV.startsWith(app.spec.csvName));
const subStatus = subsStatus.find((st) => st.installedCSV?.startsWith(app.spec.csvName));

if (!subStatus) {
return Promise.resolve(undefined);
Expand Down
8 changes: 5 additions & 3 deletions docs/dev-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ODH requires the following to run:
- Node recommended version -> `18.16.0`
- NPM recommended version -> `9.6.7`
- [OpenShift CLI](https://docs.openshift.com/container-platform/4.12/cli_reference/openshift_cli/getting-started-cli.html)
- [kustomize](https://github.com/kubernetes-sigs/kustomize)
- [kustomize](https://github.com/kubernetes-sigs/kustomize) (if you need to do deployment)

### Additional tooling

Expand Down Expand Up @@ -36,15 +36,17 @@ npm run build

This is the default context for running a local UI. Make sure you build the project using the instructions above prior to running the command below.

> Note: You must be logged-in with `oc` before you can start the backend.
> Note: You must be logged-in with `oc` before you can start the backend. Details for that are in the the [contribution guidelines](../CONTRIBUTING.md#give-your-dev-env-access).

> Note: The CLI logged-in user will need to be a `cluster-admin` level user on the cluster to mimic the Dashboard Service Account level of permissions. You could also bind the [cluster role](../manifests/base/cluster-role.yaml) to your user as we do with the service account [binding](../manifests/base/cluster-role-binding.yaml).

```bash
npm run start
```

For in-depth local run guidance review the [contribution guidelines](./CONTRIBUTING.md#Serving%20Content).
> If you'd like to run "backend" and "frontend" separately for development, cd into each directory in two different terminals and run `npm run start:dev` from each.
For in-depth local run guidance review the [contribution guidelines](../CONTRIBUTING.md#Serving%20Content).
### Testing
Expand Down
10 changes: 7 additions & 3 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ Hook specific assertions:

Cypress is used to run tests against the frontend while mocking all network requests.

Single command to run Cypress tests:
Single command to run all Cypress tests or a specific test (build frontend, start HTTP server, run Cypress):
```bash
npm run test:cypress-ci

npm run test:cypress-ci -- --spec "**/testfile.cy.ts"
```

Cypress tests require a frontend server to be running.
Expand All @@ -144,13 +146,15 @@ npm run cypress:server
```

There are two commands to run Cypress mock tests (always use the `:mock` variants).
- `open`: Opens the Cypress GUI
- `open`: Open the Cypress GUI
```bash
npm run cypress:open:mock
```
- `run`: Runs Cypress tests headless
- `run`: Run all Cypress tests or a specific test headless
```bash
npm run cypress:run:mock
npm run cypress:run:mock -- --spec "**/testfile.cy.ts"
```

Running out of memory using the GUI? Cypress keeps track of a lot of data while testing. If you experience memory issues or crashes, use the following command to adjust the number of tests kept in memory:
Expand Down
25 changes: 23 additions & 2 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
],
"extends": [
"eslint:recommended",
"plugin:jsx-a11y/recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
Expand Down Expand Up @@ -52,6 +53,19 @@
}
},
"rules": {
"jsx-a11y/no-autofocus": ["error", { "ignoreNonDOM": true }],
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["to"],
"aspects": ["noHref", "invalidHref", "preferButton"]
}
],
"react/jsx-boolean-value": "error",
"react/jsx-fragments": "error",
"react/jsx-no-constructed-context-values": "error",
"react/no-unused-prop-types": "error",
"arrow-body-style": "error",
"curly": "error",
"@typescript-eslint/default-param-last": "error",
Expand Down Expand Up @@ -133,8 +147,7 @@
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"react/self-closing-comp": "error",
// temporarily turn off @typescript-eslint/no-unnecessary-condition to merge pipeline versions and logs feature into main branch
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unnecessary-condition": "error",
"react-hooks/exhaustive-deps": "error",
"prefer-destructuring": [
"error",
Expand Down Expand Up @@ -178,6 +191,14 @@
]
}
],
"no-restricted-properties": [
"error",
{
"object": "Promise",
"property": "allSettled",
"message": "Avoid using Promise.allSettled, use allSettledPromises utility function instead."
}
],
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"import/no-named-as-default": "error",
Expand Down
3 changes: 0 additions & 3 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# testing
/coverage
/test-results/
/playwright-report/
/playwright/.cache/
/storybook-static/
/public-cypress

# production
Expand Down
38 changes: 0 additions & 38 deletions frontend/.storybook/main.js

This file was deleted.

66 changes: 0 additions & 66 deletions frontend/.storybook/preview.js

This file was deleted.

Loading

0 comments on commit eb9a60a

Please sign in to comment.