Browse Source

SONAR-21822 Fix GitHub scan onboarding tutorial for monorepo

tags/10.5.0.89998
Ambroise C 4 weeks ago
parent
commit
df4b2cacab

+ 3
- 1
server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx View File

@@ -70,7 +70,9 @@ beforeEach(() => {
const ui = {
loading: byText('loading'),
noScanRights: byText('onboarding.tutorial.no_scan_rights'),
monoRepoSecretInfo: byText('onboarding.tutorial.with.github_action.create_secret.monorepo_info'),
monoRepoSecretInfo: byText(
'onboarding.tutorial.with.github_action.create_secret.monorepo_project_level_token_info.link',
),
monoRepoYamlDocLink: byRole('link', {
name: 'onboarding.tutorial.with.github_action.monorepo.see_yaml_instructions',
}),

+ 8
- 2
server/sonar-web/src/main/js/components/tutorials/components/DefaultProjectKey.tsx View File

@@ -17,8 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { CodeSnippet, NumberedListItem } from 'design-system';
import { CodeSnippet, FlagMessage, NumberedListItem } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { Component } from '../../../types/types';
import SentenceWithFilename from './SentenceWithFilename';

@@ -33,12 +34,17 @@ export default function DefaultProjectKey(props: DefaultProjectKeyProps) {
const { component, monorepo } = props;

return (
<NumberedListItem>
<NumberedListItem className="sw-mb-6">
<SentenceWithFilename
filename="sonar-project.properties"
translationKey={`onboarding.tutorial.other.project_key${monorepo ? '.monorepo' : ''}`}
/>
<CodeSnippet snippet={sonarProjectSnippet(component.key)} isOneLine className="sw-p-6" />
<div>
<FlagMessage variant="info">
<FormattedMessage id="onboarding.tutorial.other.project_key.monorepo.info" />
</FlagMessage>
</div>
</NumberedListItem>
);
}

+ 21
- 39
server/sonar-web/src/main/js/components/tutorials/github-action/SecretStep.tsx View File

@@ -28,10 +28,8 @@ import {
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { translate } from '../../../helpers/l10n';
import { hasGlobalPermission } from '../../../helpers/users';
import { useProjectBindingQuery } from '../../../queries/devops-integration';
import { AlmSettingsInstance } from '../../../types/alm-settings';
import { Permissions } from '../../../types/permissions';
import { Component } from '../../../types/types';
import { LoggedInUser } from '../../../types/users';
import { InlineSnippet } from '../components/InlineSnippet';
@@ -86,38 +84,6 @@ export default function SecretStep(props: SecretStepProps) {
/>
<InlineSnippet snippet="SONAR_TOKEN" className="sw-ml-1" />
<ClipboardIconButton copyValue="SONAR_TOKEN" className="sw-ml-2 sw-align-sub" />
{monorepo && (
<FlagMessage variant="info" className="sw-block sw-w-fit sw-mt-4">
<FormattedMessage
defaultMessage={translate(
'onboarding.tutorial.with.github_action.create_secret.monorepo_sonar_token',
)}
id="onboarding.tutorial.with.github_action.create_secret.monorepo_sonar_token"
values={{
token_name: <InlineSnippet snippet="SONAR_TOKEN_1" className="sw-ml-1" />,
global_secret: hasGlobalPermission(currentUser, Permissions.Scan) ? (
<FormattedMessage
defaultMessage={translate(
'onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token',
)}
id="onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token"
values={{
link: (
<Link to="/account/security" target="_blank" className="sw-mx-1">
{translate(
'onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token.link',
)}
</Link>
),
}}
/>
) : (
''
),
}}
/>
</FlagMessage>
)}
</NumberedListItem>
<NumberedListItem>
<TokenStepGenerator component={component} currentUser={currentUser} />
@@ -127,6 +93,27 @@ export default function SecretStep(props: SecretStepProps) {
translationKey="onboarding.tutorial.with.github_action.secret.add"
highlightKeys={['add_secret']}
/>
{monorepo && (
<FlagMessage variant="info" className="sw-block sw-w-fit sw-mt-4">
<div>
<div>
<FormattedMessage
id="onboarding.tutorial.with.github_action.create_secret.monorepo_project_level_token_info"
values={{
link: (
<Link to="/account/security">
<FormattedMessage id="onboarding.tutorial.with.github_action.create_secret.monorepo_project_level_token_info.link" />
</Link>
),
}}
/>
</div>
<div className="sw-mt-2">
<FormattedMessage id="onboarding.tutorial.with.github_action.create_secret.monorepo_global_token_info" />
</div>
</div>
</FlagMessage>
)}
</NumberedListItem>
</NumberedList>
<BasicSeparator className="sw-my-6" />
@@ -167,11 +154,6 @@ export default function SecretStep(props: SecretStepProps) {
/>
</NumberedListItem>
</NumberedList>
{monorepo && (
<FlagMessage variant="info" className="sw-block sw-w-fit sw-mt-4">
{translate('onboarding.tutorial.with.github_action.create_secret.monorepo_info')}
</FlagMessage>
)}
</>
);
}

+ 1
- 2
server/sonar-web/src/main/js/components/tutorials/github-action/commands/MonorepoDocLinkFallback.tsx View File

@@ -30,8 +30,7 @@ export default function MonorepoDocLinkFallback() {
<NumberedListItem>
<DocumentationLink className="sw-mt-4" to={MONOREPO_DOC}>
{translate('onboarding.tutorial.with.github_action.monorepo.see_yaml_instructions')}
</DocumentationLink>{' '}
{translate('onboarding.tutorial.with.github_action.monorepo.pre_see_yaml_instructions')}
</DocumentationLink>
</NumberedListItem>
);
}

+ 6
- 7
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -4573,6 +4573,7 @@ onboarding.tutorial.ci_outro.refresh=This page will then refresh with your analy
onboarding.tutorial.ci_outro.refresh.why=If the page doesn't refresh after a while, please double-check the analysis configuration, and check your logs.
onboarding.tutorial.other.project_key.sentence=Create a {file} file in your repository and paste the following code:
onboarding.tutorial.other.project_key.monorepo.sentence=Create a {file} file at the root of your project and paste the following code:
onboarding.tutorial.other.project_key.monorepo.info=Repeat this step for all the projects in your monorepo
onboarding.tutorial.cfamilly.compilation_database_info=If you have trouble using the build wrapper, you can try using a {link}.
onboarding.tutorial.cfamilly.compilation_database_info.link=compilation database
onboarding.tutorial.cfamilly.speed_caching=You can also speed up your analysis by enabling {link}.
@@ -4621,13 +4622,11 @@ onboarding.tutorial.with.bitbucket_pipelines.variables.secured.sentence.secured=

onboarding.tutorial.with.github_ci.title=Analyze your project with GitHub CI
onboarding.tutorial.with.github_action.create_secret.title=Create GitHub Secrets
onboarding.tutorial.with.github_action.create_secret.monorepo_info=If the secrets were created already for one of the projects in the mono repository, please skip this step
onboarding.tutorial.with.github_action.create_secret.monorepo_sonar_token=Monorepository token names will need to be unique per project (e.g. {token_name}) {global_secret}
onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token=or create a {link} for the monorepository
onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token.link=global token
onboarding.tutorial.with.github_action.monorepo.pre_see_yaml_instructions=(once per monorepository)
onboarding.tutorial.with.github_action.monorepo.see_yaml_instructions=See the documentation to create the Workflow YAML file at the root of your repository
onboarding.tutorial.with.github_action.secret.intro=In your GitHub repository, go to {settings_secret} and create two new secrets:
onboarding.tutorial.with.github_action.create_secret.monorepo_project_level_token_info=If you use project-level tokens, {link} for each project in your monorepo and create the associated secrets as per previous steps (secrets names need to be unique per project e.g. SONAR_TOKEN_1, SONAR_TOKEN2...)
onboarding.tutorial.with.github_action.create_secret.monorepo_project_level_token_info.link=generate a token
onboarding.tutorial.with.github_action.create_secret.monorepo_global_token_info=If you use global tokens, request a global token from your admin and follow previous steps.
onboarding.tutorial.with.github_action.monorepo.see_yaml_instructions=Create or update your .github/workflows/build.yml YAML file at the root of your monorepository with this content
onboarding.tutorial.with.github_action.secret.intro=In your GitHub repository, go to {settings_secret} and create below new secrets:
onboarding.tutorial.with.github_action.secret.intro.link=Settings > Secrets
onboarding.tutorial.with.github_action.secret.name.sentence=In the {name} field, enter
onboarding.tutorial.with.github_action.secret.name.sentence.name=Name

Loading…
Cancel
Save