Skip to content

Commit

Permalink
chore: add identity CI workflows (#19334)
Browse files Browse the repository at this point in the history
## Description
Adds Identity checks to PRs and merge queue

## Related issues

closes camunda-cloud/identity#2960
  • Loading branch information
Ben-Sheppard committed Jun 21, 2024
2 parents 5e372b6 + 8136da7 commit 25ea0d3
Show file tree
Hide file tree
Showing 20 changed files with 534 additions and 725 deletions.
19 changes: 18 additions & 1 deletion .github/actions/paths-filter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ outputs:
steps.filter-common.outputs.java-code-change ||
steps.filter-common.outputs.maven-change
}}
identity-frontend-tests:
description: Output whether Identity frontend tests should be run based on GitHub event and files changed
value: >-
${{
github.event_name == 'push' ||
steps.filter-common.outputs.github-actions-change ||
steps.filter-identity.outputs.identity-frontend-change
}}
runs:
using: composite
Expand All @@ -43,10 +51,19 @@ runs:
java-code-change:
- '**/src/main/**'
- '**/src/test/**'
maven-change:
- 'bom/*'
- 'build-tools/**'
- 'dist/**'
- 'parent/*'
- 'pom.xml'
- uses: dorny/paths-filter@v3
id: filter-identity
with:
base: ${{ github.event.merge_group.base_ref || '' }}
ref: ${{ github.event.merge_group.head_ref || github.ref }}
filters: |
identity-frontend-change:
- 'identity/client/**'
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
outputs:
actionlint: ${{ steps.filter.outputs.actionlint }}
java-unit-tests: ${{ steps.filter.outputs.java-unit-tests }}
identity-frontend-tests: ${{ steps.filter.outputs.identity-frontend-tests }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -116,6 +117,45 @@ jobs:
secret_vault_address: ${{ secrets.VAULT_ADDR }}
secret_vault_roleId: ${{ secrets.VAULT_ROLE_ID }}

identity-frontend-tests:
if: needs.detect-changes.outputs.identity-frontend-tests == 'true'
needs: [detect-changes]
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
working-directory: identity/client
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
cache-dependency-path: identity/client/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Check formatting
run: yarn test:format
- name: Lint code
run: yarn test:lint
- name: Unit & Integration tests
run: yarn test:unit
- name: Check licenses
run: yarn test:licenses
- name: Build frontend
run: yarn build

- name: Observe build status
if: always()
continue-on-error: true
uses: ./.github/actions/observe-build-status
with:
build_status: ${{ job.status }}
secret_vault_address: ${{ secrets.VAULT_ADDR }}
secret_vault_roleId: ${{ secrets.VAULT_ROLE_ID }}
secret_vault_secretId: ${{ secrets.VAULT_SECRET_ID }}

check-results:
# Used by the merge queue to check all tests, including the unit test matrix.
# New test jobs must be added to the `needs` lists!
Expand All @@ -127,6 +167,7 @@ jobs:
needs:
- actionlint
- java-unit-tests
- identity-frontend-tests
steps:
- run: exit ${{ ((contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure')) && 1) || 0 }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
String[] properties() default "";

@AliasFor(annotation = ActiveProfiles.class, attribute = "profiles")
String[] profiles() default {"test", "auth-basic", "h2"};
String[] profiles() default {"test", "auth-basic"};
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"camunda.identity.init.users[0].password=" + DefaultUserInitializerTest.PASSWORD,
"camunda.identity.init.users[1].username=test1",
"camunda.identity.init.users[1].password=password1",
},
profiles = {"test", "auth-basic"})
})
public class DefaultUserInitializerTest {

static final String USERNAME = "test";
Expand Down
4 changes: 0 additions & 4 deletions identity/client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@ module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
10 changes: 8 additions & 2 deletions identity/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write ./src",
"test:format": "prettier --check ./src",
"test:lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"test:licenses": "license-checker --excludePrivatePackages --excludePackages 'wicg-inert@3.1.2' --onlyAllow 'Apache-2.0;MIT;0BSD;BSD-2-Clause;BSD-3-Clause;ISC;CC0-1.0;WTFPL;OFL-1.1;CC-BY-4.0;' --production",
"test:unit": "",
"test": "yarn test:unit & yarn test:format && yarn test:licenses && yarn test:lint",
"preview": "vite preview"
},
"dependencies": {
"@camunda/camunda-composite-components": "0.8.0",
"@carbon/react": "1.60.1",
"@carbon/react": "1.59.0",
"i18next": "23.11.5",
"react": "18.3.1",
"react-debounced": "1.1.2",
Expand All @@ -35,6 +40,7 @@
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.7",
"event-source-polyfill": "1.0.31",
"license-checker": "25.0.1",
"prettier": "3.3.2",
"sass": "1.77.6",
"typescript": "5.5.2",
Expand Down
74 changes: 39 additions & 35 deletions identity/client/src/components/entityList/EntityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,41 +155,45 @@ const EntityList = <D extends EntityData>({
DataTableFilter<D>["options"]
>([]);

const [index, tableData] = useMemo(() => {
const entityIndex: { [id: string]: D } = {};
const entityTableData: (D & { id: string })[] = [];

data?.forEach((dataset) => {
const id = dataset.id || (Date.now() + Math.random()).toString();
entityIndex[id] = dataset;
entityTableData.push({ ...dataset, id });
});

const filteredData =
filter && selectedFilterItems.length > 0
? entityTableData.filter((entry) =>
filter.callback(entry, selectedFilterItems),
)
: entityTableData;

const sortedEntityTableData =
filteredData.length > 0
? filteredData.sort((a, b) => {
const propertyName =
sortProperty || Object.keys(entityTableData[0])[0];

if (a[propertyName] < b[propertyName]) {
return -1;
}
if (a[propertyName] > b[propertyName]) {
return 1;
}
return 0;
})
: filteredData;

return [entityIndex, sortedEntityTableData];
}, [data, selectedFilterItems]);
const [index, tableData] = useMemo(
() => {
const entityIndex: { [id: string]: D } = {};
const entityTableData: (D & { id: string })[] = [];

data?.forEach((dataset) => {
const id = dataset.id || (Date.now() + Math.random()).toString();
entityIndex[id] = dataset;
entityTableData.push({ ...dataset, id });
});

const filteredData =
filter && selectedFilterItems.length > 0
? entityTableData.filter((entry) =>
filter.callback(entry, selectedFilterItems),
)
: entityTableData;

const sortedEntityTableData =
filteredData.length > 0
? filteredData.sort((a, b) => {
const propertyName =
sortProperty || Object.keys(entityTableData[0])[0];

if (a[propertyName] < b[propertyName]) {
return -1;
}
if (a[propertyName] > b[propertyName]) {
return 1;
}
return 0;
})
: filteredData;

return [entityIndex, sortedEntityTableData];
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[sortProperty, data, selectedFilterItems],
);

const areRowsEmpty = !tableData || tableData.length === 0;

Expand Down
6 changes: 3 additions & 3 deletions identity/client/src/components/entityList/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* file except in compliance with the proprietary license.
*/

import styled from 'styled-components';
import { TableContainer } from '@carbon/react';
import { layer01, productiveHeading01, spacing04 } from '@carbon/themes';
import styled from "styled-components";
import { TableContainer } from "@carbon/react";
import { layer01, productiveHeading01, spacing04 } from "@carbon/themes";

export const NoDataContainer = styled.div`
padding: ${spacing04};
Expand Down
2 changes: 1 addition & 1 deletion identity/client/src/components/form/DropdownSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const DropdownSearch = <Item,>({

useEffect(() => {
if (items.length > 0) setSelectedResult(0);
}, [JSON.stringify(items)]);
}, [items.length]);

return (
<ListBox disabled={false} type="inline" isOpen>
Expand Down
2 changes: 1 addition & 1 deletion identity/client/src/components/global/GlobalRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import { FC } from "react";
import { Route, Routes as RouterRoutes } from "react-router-dom";
import Redirect from "src/components/global/Redirect";
import { useGlobalRoutes } from "src/components/global/useGlobalRoutes";
import Redirect from "src/components/router/Redirect";

const GlobalRoutes: FC = () => {
const routes = useGlobalRoutes();
Expand Down
25 changes: 0 additions & 25 deletions identity/client/src/components/global/Redirect.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion identity/client/src/components/layout/LateLoading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const LateLoading: FC<LateLoadingProps> = ({ timeout = 300 }) => {

useEffect(() => {
debounce(() => setVisible(true));
}, []);
}, [debounce]);

if (visible) {
return <Loading />;
Expand Down
2 changes: 1 addition & 1 deletion identity/client/src/components/router/Redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Redirect: FC<RedirectProps> = ({ to }) => {

useEffect(() => {
navigate(to, { replace: true });
}, [to]);
}, [navigate, to]);

return null;
};
Expand Down
14 changes: 9 additions & 5 deletions identity/client/src/components/tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ const Tabs = <T extends { key: string; label: string; content: ReactNode }>({

const selectedTabIndex = tabs.findIndex(({ key }) => key === selectedTabKey);

useEffect(() => {
if (selectedTabIndex === -1) {
navigate(`${path}/${tabs[0].key}`, { replace: true });
}
}, [selectedTabKey]);
useEffect(
() => {
if (selectedTabIndex === -1) {
navigate(`${path}/${tabs[0].key}`, { replace: true });
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[navigate, path, selectedTabIndex],
);

return (
<CarbonTabs
Expand Down
18 changes: 9 additions & 9 deletions identity/client/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
@use '@carbon/react' as *;
@import '@carbon/themes/scss/themes';
@use "@carbon/react" as *;
@import "@carbon/themes/scss/themes";

html {
@include theme($g10);
}

h1 {
@include type-style('heading-04');
@include type-style("heading-04");
}

h2 {
@include type-style('heading-03');
@include type-style("heading-03");
}

h3 {
@include type-style('heading-02');
@include type-style("heading-02");
}

h4 {
@include type-style('heading-01');
@include type-style("heading-01");
}

p {
@include type-style('body-01');
@include type-style("body-01");
}

.cds--list-box input[role='combobox'],
.cds--list-box input[type='text'] {
.cds--list-box input[role="combobox"],
.cds--list-box input[type="text"] {
background-color: var(--cds-field-02, #ffffff);
}
8 changes: 5 additions & 3 deletions identity/client/src/utility/api/hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ const useApi: UseApi = <R, P>(

const paramsDependency = JSON.stringify(params);
// params are passed to dependencies as json string which is not recognised by eslint
// eslint-disable-next-line
// @ts-ignore
const reload = useCallback(() => call(params as P), [call, paramsDependency]);
const reload = useCallback(
() => call(params as P),
// eslint-disable-next-line react-hooks/exhaustive-deps
[call, paramsDependency],
);

useEffect(() => {
if (paramsValid) {
Expand Down
Loading

0 comments on commit 25ea0d3

Please sign in to comment.