mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
# Which Problems Are Solved Replaces Turbo by Nx and lays the foundation for the next CI improvements. It enables using Nx Cloud to speed the up the pipelines that affect any node package. It streamlines the dev experience for frontend and backend developers by providing the following commands: | Task | Command | Notes | |------|---------|--------| | **Production** | `nx run PROJECT:prod` | Production server | | **Develop** | `nx run PROJECT:dev` | Hot reloading development server | | **Test** | `nx run PROJECT:test` | Run all tests | | **Lint** | `nx run PROJECT:lint` | Check code style | | **Lint Fix** | `nx run PROJECT:lint-fix` | Auto-fix style issues | The following values can be used for PROJECT: - @zitadel/zitadel (root commands) - @zitadel/api, - @zitadel/login, - @zitadel/console, - @zitadel/docs, - @zitadel/client - @zitadel/proto The project names and folders are streamlined: | Old Folder | New Folder | | --- | --- | | ./e2e | ./tests/functional-ui | | ./load-test | ./benchmark | | ./build/zitadel | ./apps/api | | ./console | ./apps/console (postponed so the PR is reviewable) | Also, all references to the TypeScript repo are removed so we can archive it. # How the Problems Are Solved - Ran `npx nx@latest init` - Replaced all turbo.json by project.json and fixed the target configs - Removed Turbo dependency - All JavaScript related code affected by a PRs changes is quality-checked using the `nx affected` command - We move PR checks that are runnable using Nx into the `check` workflow. For workflows where we don't use Nx, yet, we restore previously built dependency artifacts from Nx. - We only use a single and easy to understand dev container - The CONTRIBUTING.md is streamlined - The setup with a generated client pat is orchestrated with Nx - Everything related to the TypeScript repo is updated or removed. A **Deploy with Vercel** button is added to the docs and the CONTRIBUTING.md. # Additional Changes - NPM package names have a consistent pattern. - Docker bake is removed. The login container is built and released like the core container. - The integration tests build the login container before running, so they don't rely on the login container action anymore. This fixes consistently failing checks on PRs from forks. - The docs build in GitHub actions is removed, as we already build on Vercel. # Additional Context - Internal discussion: https://zitadel.slack.com/archives/C087ADF8LRX/p1756277884928169 - Workflow dispatch test: https://github.com/zitadel/zitadel/actions/runs/17760122959 --------- Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Tim Möhlmann <[email protected]> Co-authored-by: Copilot <[email protected]>
77 lines
2.9 KiB
TypeScript
77 lines
2.9 KiB
TypeScript
import { loginByUsernamePassword } from '../login_ui';
|
|
import { createOrg } from '../org';
|
|
import { User, createMachine } from '../user';
|
|
import { Config, MaxVUs } from '../config';
|
|
import { createProject, Project } from '../project';
|
|
import { addUserGrant } from '../user_grant';
|
|
|
|
export async function setup() {
|
|
const tokens = loginByUsernamePassword(Config.admin as User);
|
|
console.info('setup: admin signed in');
|
|
|
|
const org = await createOrg(tokens.accessToken!);
|
|
console.info(`setup: org (${org.organizationId}) created`);
|
|
|
|
const projects = await Promise.all(
|
|
Array.from({ length: 50 }, (_, i) => {
|
|
return createProject(`project-${i}`, org, tokens.accessToken!);
|
|
}),
|
|
);
|
|
console.log(`setup: ${projects.length} projects created`);
|
|
|
|
let machines = (
|
|
await Promise.all(
|
|
Array.from({ length: MaxVUs() }, async (_, i) => {
|
|
return await createMachine(`zitachine-${i}`, org, tokens.accessToken!);
|
|
}),
|
|
)
|
|
).map((machine) => {
|
|
return { userId: machine.userId, loginName: machine.loginNames[0] };
|
|
});
|
|
console.log(`setup: ${machines.length} machines created`);
|
|
|
|
return { tokens, org, machines, projects };
|
|
}
|
|
|
|
export default async function (data: any) {
|
|
const machine = await createMachine(`zitachine-${__VU}-${__ITER}`, data.org, data.tokens.accessToken!);
|
|
let userGrants = await Promise.all(
|
|
data.projects.map((project: Project) => {
|
|
return addUserGrant(data.org, machine.userId, project, [], data.tokens.accessToken!);
|
|
}),
|
|
);
|
|
|
|
return { userGrants };
|
|
}
|
|
|
|
export function teardown(data: any) {
|
|
// removeOrg(data.org, data.tokens.accessToken);
|
|
console.info('teardown: org is not removed to verify correctness of projections, do not forget to remove the org afterwards');
|
|
}
|
|
|
|
/**
|
|
* To verify the correctness of the projections you can use the following statements:
|
|
*
|
|
* set the owner of the events:
|
|
*
|
|
* set my.owner = '<org id of the created org>';
|
|
*
|
|
* check if the amount of events is the same as amount of objects
|
|
*
|
|
* select * from (
|
|
select 'projections.user_grants5', count(*) from projections.user_grants5 where resource_owner = (select current_setting('my.owner'))
|
|
union all
|
|
select 'projections.users14', count(*) from projections.users14 where resource_owner = (select current_setting('my.owner'))
|
|
union all
|
|
select 'projections.sessions8', count(*) from projections.sessions8 where user_resource_owner = (select current_setting('my.owner'))
|
|
union all
|
|
select aggregate_type, count(*) from eventstore.events2
|
|
where
|
|
aggregate_type in ('user', 'usergrant', 'session')
|
|
and event_type in ('user.machine.added', 'user.human.added', 'user.grant.added', 'session.user.checked')
|
|
and (owner = (select current_setting('my.owner'))
|
|
OR payload->>'userResourceOwner' = (select current_setting('my.owner'))
|
|
)
|
|
group by aggregate_type
|
|
) order by 2;
|
|
*/ |