-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(codecov): Add output coverage file step 1 #92044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
95c1196
b8806a9
5a66f83
6b6f2e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import {space} from 'sentry/styles/space'; | ||
|
||
const Container = styled('div')` | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${space(1)}; | ||
border: 1px solid ${p => p.theme.border}; | ||
border-radius: ${p => p.theme.borderRadius}; | ||
padding: ${space(2)} ${space(3)}; | ||
`; | ||
|
||
const Header = styled('h3')` | ||
font-size: ${p => p.theme.fontSizeExtraLarge}; | ||
color: ${p => p.theme.gray300}; | ||
margin-bottom: 0; | ||
`; | ||
|
||
const Content = styled('div')` | ||
/* flex-grow: 1; */ | ||
`; | ||
|
||
export const OnboardingStep = { | ||
Container, | ||
Header, | ||
Content, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import {Fragment, useState} from 'react'; | ||
import {Link} from 'react-router-dom'; | ||
import styled from '@emotion/styled'; | ||
|
||
import {CodeSnippet} from 'sentry/components/codeSnippet'; | ||
import {Select} from 'sentry/components/core/select'; | ||
import {t, tct} from 'sentry/locale'; | ||
import {space} from 'sentry/styles/space'; | ||
import {OnboardingStep} from 'sentry/views/codecov/tests/onboardingSteps/onboardingStep'; | ||
|
||
interface OutputCoverageFileProps { | ||
stepString: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: adding the type of variable to the name itself is kind of redundant when you have it typed by a type. I'd call this step or something and cast the number to str if you're expecting that to be a number There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The steps could include a sub-step letter like "2a" so it will need to stay a string. |
||
} | ||
|
||
type Frameworks = 'jest' | 'vitest' | 'pytest' | 'phpunit'; | ||
|
||
const INSTALL_REQUIREMENTS_SNIPPETS: Record<Frameworks, string> = { | ||
jest: `pytest --cov --junitxml=junit.xml -o junit_family=legacy`, | ||
vitest: `vitest --reporter=junit --outputFile=test-report.junit.xml`, | ||
pytest: `npm i --save-dev jest-junit`, | ||
phpunit: `./vendor/bin/phpunit --log-junit junit.xml`, | ||
}; | ||
|
||
const GENERATE_FILE_SNIPPETS: Record<Frameworks, string> = { | ||
jest: '', | ||
vitest: '', | ||
pytest: `JEST_JUNIT_CLASSNAME="{filepath}" jest --reporters=jest-junit`, | ||
phpunit: '', | ||
}; | ||
|
||
export function OutputCoverageFile({stepString}: OutputCoverageFileProps) { | ||
const headerText = tct('Step [stepString]: Output a JUnit XML file in your CI', { | ||
stepString, | ||
}); | ||
const [selectedFramework, setSelectedFramework] = useState<Frameworks>('jest'); | ||
|
||
return ( | ||
<OnboardingStep.Container> | ||
<OnboardingStep.Header>{headerText}</OnboardingStep.Header> | ||
<OnboardingStep.Content> | ||
<p> | ||
{tct( | ||
"Select your language below to generate your testing reports. If your language isn't listed, visit [supported] for your testing framework. Currently, Sentry supports JUnit XML format only.", | ||
{ | ||
supported: ( | ||
// TODO: the new version of this link is still TBD | ||
<Link to="https://docs.codecov.com/docs/test-analytics#:~:text=Only%20JUnit%20XML%20test%20result%20files%20are%20supported%20at%20the%20moment"> | ||
{t('supported languages')} | ||
</Link> | ||
), | ||
} | ||
)} | ||
</p> | ||
<StyledSelectControl | ||
size="md" | ||
options={[ | ||
{label: 'Jest', value: 'jest'}, | ||
{label: 'Vitest', value: 'vitest'}, | ||
{label: 'Pytest', value: 'pytest'}, | ||
{label: 'PHPunit', value: 'phpunit'}, | ||
]} | ||
value={selectedFramework} | ||
onChange={(option: {value: Frameworks}) => setSelectedFramework(option.value)} | ||
/> | ||
<StyledInstruction> | ||
{t('Install requirements in your terminal:')} | ||
</StyledInstruction> | ||
<CodeSnippet dark language="bash"> | ||
{INSTALL_REQUIREMENTS_SNIPPETS[selectedFramework]} | ||
</CodeSnippet> | ||
{selectedFramework === 'pytest' ? ( | ||
<Fragment> | ||
<StyledInstruction> | ||
{t('Generate a JUnit XML file that contains the results of your test run.')} | ||
</StyledInstruction> | ||
<CodeSnippet dark language="bash"> | ||
{GENERATE_FILE_SNIPPETS.pytest} | ||
</CodeSnippet> | ||
</Fragment> | ||
) : null} | ||
</OnboardingStep.Content> | ||
</OnboardingStep.Container> | ||
); | ||
} | ||
|
||
const StyledSelectControl = styled(Select)` | ||
width: 110px; | ||
margin-bottom: ${space(1.5)}; | ||
`; | ||
|
||
const StyledInstruction = styled('p')` | ||
margin: ${space(1.5)} 0; | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why you decided to lump these 3 styled components into this file. It feels like we're trying to think this as a component rather than at markup so trying to get a feel of why it's on it's own file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to reuse this composition components for all of the steps so they wouldn't be associated with one specific file/component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh fair fair I see. Do you ever foresee these steps having different styling bw their headers, contents or containers? I'd normally say this is preemptive abstraction but I think there's a valid case to say you want all of them to be the same, so this comes as a handy way for that if that's how we foresee this behaving in the future. I trust your judgement here 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I will leave it for now then. I do think there's a possibility for steps to have different styling but looking at our current designs, they are all relatively identical. If we run into an outlier, we can explicitly define new styles to be used instead of the styled composition components for that/those instance(s).