apache / incubator-devlake

Apache DevLake is an open-source dev data platform to ingest, analyze, and visualize the fragmented data from DevOps tools, extracting insights for engineering excellence, developer experience, and community growth.
https://devlake.apache.org/
Apache License 2.0
2.5k stars 493 forks source link

[Question][GitHub] GitOps-like repos belonging to multiple projects. #7684

Open jluque0101 opened 3 days ago

jluque0101 commented 3 days ago

Question

I have a question regarding projects and shared repositories.

Use Case: I have two teams, Team A and Team B. Each team has its own repository, and they share a GitOps-like repository where they publish new releases for deployment. The shared repository uses GitHub Actions (with different names depending on which files were updated) to track deployments. However, the regex used in scope-config should be different for each project because the action name to be tracked as a deployment is different for each team.

Question: Is there a way to associate multiple scope-configs for a repository depending on which project it is associated with? Alternatively, what is the best approach to handle this use case ?

dosubot[bot] commented 3 days ago

Hello, @jluque0101! I'm here to assist you with any questions, bugs, or issues you may have. I can help you solve problems, answer questions, and even guide you on how to become a contributor. Let me know how I can assist you today!

Yes, there is a way to associate multiple scope-configs for a repository depending on which project it is associated with. The application supports associating and updating scope configurations for different projects. The handleAssociateScopeConfig and handleUpdate functions demonstrate how scope configurations can be managed and applied to different projects.

Here is a relevant code snippet that handles the association and updating of scope configurations:

const handleAssociateScopeConfig = async (trId: ID) => {
    const [success] = await operator(
      () =>
        Promise.all(
          scopeIds.map(async (scopeId) => {
            const scope = await API.scope.get(plugin, connectionId, scopeId);
            return API.scope.update(plugin, connectionId, scopeId, {
              ...scope,
              scopeConfigId: trId !== 'None' ? +trId : null,
            });
          }),
        ),
      {
        setOperating,
        formatMessage: () =>
          trId !== 'None' ? 'Associate scope config successful.' : 'Dis-associate scope config successful.',
      },
    );

    if (success) {
      handleHideDialog();
      setVersion(version + 1);
      message.success(
        'Scope Config(s) have been updated. If you would like to re-transform or re-collect the data in the related project(s), please go to the Project page and do so.',
      );
    }
  };

const handleUpdate = async (trId: ID) => {
    handleHideDialog();

    const [success, res] = await operator(() => API.scopeConfig.check(plugin, trId), { hideToast: true });

    if (success) {
      handleShowProjectsModal(res.projects ?? []);
    }
  };

Additionally, the ScopeConfigForm component provides a user interface for creating and updating scope configurations. This form allows users to specify the name, data entities, and transformations for a scope configuration, which can then be associated with different projects.

For more detailed information, you can refer to the relevant files in the repository:

This approach ensures that the correct scope configurations are applied based on the project context, allowing you to handle different regex patterns for tracking deployments in GitHub Actions workflows for each team.

To continue talking to Dosu, mention @dosu.

d4x1 commented 18 hours ago

@jluque0101 You can set up two connections with different scope-configs to circumvent this issues.