Skip to content

Commit

Permalink
Merge pull request #377 from dhis2/update-commit-checking-workflows
Browse files Browse the repository at this point in the history
ci: replace semantic commit checks with new workflow
  • Loading branch information
HendrikThePendric authored May 24, 2022
2 parents 8272196 + 92a6a21 commit 8cda173
Show file tree
Hide file tree
Showing 38 changed files with 651 additions and 244 deletions.
4 changes: 0 additions & 4 deletions .github/semantic.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/dhis2-verify-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'dhis2: verify (commits)'

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']

jobs:
lint-pr-title:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile
- id: commitlint
run: echo ::set-output name=config_path::$(node -e "process.stdout.write(require('@dhis2/cli-style').config.commitlint)")
- uses: JulienKode/[email protected]
with:
configuration-path: ${{ steps.commitlint.outputs.config_path }}

lint-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: c-hive/gha-yarn-cache@v1
- run: yarn install --frozen-lockfile
- id: commitlint
run: echo ::set-output name=config_path::$(node -e "process.stdout.write(require('@dhis2/cli-style').config.commitlint)")
- uses: wagoid/commitlint-github-action@v4
with:
configFile: ${{ steps.commitlint.outputs.config_path }}
6 changes: 3 additions & 3 deletions cypress/integration/add-route/create-parameter-jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Given, Then } from 'cypress-cucumber-preprocessor/steps'
* Local helpers
*/

const selectJob = jobName => {
const selectJob = (jobName) => {
cy.get('[data-test="dhis2-uicore-singleselect"]').click()
cy.findByText(jobName).click()
}

const saveAndExpect = expected => {
cy.intercept({ pathname: /jobConfigurations$/, method: 'POST' }, req => {
const saveAndExpect = (expected) => {
cy.intercept({ pathname: /jobConfigurations$/, method: 'POST' }, (req) => {
expect(req.body).to.deep.equal(expected)
req.reply({ statusCode: 201 })
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Given, Then } from 'cypress-cucumber-preprocessor/steps'
* Local helpers
*/

const selectJob = jobName => {
const selectJob = (jobName) => {
cy.get('[data-test="dhis2-uicore-singleselect"]').click()
cy.findByText(jobName).click()
}

const saveAndExpect = expected => {
cy.intercept({ pathname: /jobConfigurations$/, method: 'POST' }, req => {
const saveAndExpect = (expected) => {
cy.intercept({ pathname: /jobConfigurations$/, method: 'POST' }, (req) => {
expect(req.body).to.deep.equal(expected)
req.reply({ statusCode: 201 })
})
Expand Down
11 changes: 7 additions & 4 deletions cypress/integration/edit-route/delete-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ When('the user clicks the delete job button', () => {
})

Then('the job will be deleted upon confirmation', () => {
cy.intercept({ pathname: /jobConfigurations$/, method: 'DELETE' }, req => {
expect(req.url.endsWith('jobConfigurations/lnWRZN67iDU')).to.be.true
req.reply({ statusCode: 200 })
})
cy.intercept(
{ pathname: /jobConfigurations$/, method: 'DELETE' },
(req) => {
expect(req.url.endsWith('jobConfigurations/lnWRZN67iDU')).to.be.true
req.reply({ statusCode: 200 })
}
)

cy.findByText('Are you sure you want to delete this job?').should('exist')
cy.findByRole('button', { name: 'Delete' }).click()
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/edit-route/edit-parameter-jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Given, Then } from 'cypress-cucumber-preprocessor/steps'
* Local helpers
*/

const selectJob = jobName => {
const selectJob = (jobName) => {
cy.get('[data-test="dhis2-uicore-singleselect"]').click()
cy.findByText(jobName).click()
}

const saveAndExpect = expected => {
const saveAndExpect = (expected) => {
cy.intercept(
{ pathname: /jobConfigurations\/lnWRZN67iDU$/, method: 'PUT' },
req => {
(req) => {
expect(req.body).to.deep.equal(expected)
req.reply({ statusCode: 201 })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Given, Then } from 'cypress-cucumber-preprocessor/steps'
* Local helpers
*/

const selectJob = jobName => {
const selectJob = (jobName) => {
cy.get('[data-test="dhis2-uicore-singleselect"]').click()
cy.findByText(jobName).click()
}

const saveAndExpect = expected => {
const saveAndExpect = (expected) => {
cy.intercept(
{ pathname: /jobConfigurations\/lnWRZN67iDU$/, method: 'PUT' },
req => {
(req) => {
expect(req.body).to.deep.equal(expected)
req.reply({ statusCode: 201 })
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/list-route/filter-jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Given('the user enables the include-system-jobs-in-list toggle', () => {
]

cy.findByRole('checkbox', { name: 'Include system jobs in list' }).click()
expected.forEach(name => {
expected.forEach((name) => {
cy.findByRole('rowheader', { name }).should('exist')
})
})
Expand All @@ -46,7 +46,7 @@ Then('only user jobs that match the filter will be shown', () => {
Then('only jobs that match the filter will be shown', () => {
const expected = ['Job 1', 'System Job 1']

expected.forEach(name => {
expected.forEach((name) => {
cy.findByRole('rowheader', { name }).should('exist')
})
})
6 changes: 3 additions & 3 deletions cypress/integration/list-route/include-system-jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ When('the user checks the include-system-jobs-in-list checkbox', () => {
Then('system jobs are not shown', () => {
const systemJobs = ['System Job 1', 'System Job 2', 'System Job 3']

systemJobs.forEach(name => {
systemJobs.forEach((name) => {
cy.findByRole('rowheader', { name }).should('not.exist')
})
})

Then('system jobs are shown', () => {
const systemJobs = ['System Job 1', 'System Job 2', 'System Job 3']

systemJobs.forEach(name => {
systemJobs.forEach((name) => {
cy.findByRole('rowheader', { name }).should('be.visible')
})
})

Then('user jobs are shown', () => {
const userJobs = ['Job 1', 'Job 2', 'Job 3']

userJobs.forEach(name => {
userJobs.forEach((name) => {
cy.findByRole('rowheader', { name }).should('be.visible')
})
})
12 changes: 6 additions & 6 deletions cypress/integration/list-route/job-toggle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
Given('a disabled user job exists', () => {
const responses = []

cy.fixture('list-route/disabled-user-job').then(fixture => {
cy.fixture('list-route/disabled-user-job').then((fixture) => {
responses.push(fixture)
})

cy.fixture('list-route/enabled-user-job').then(fixture => {
cy.fixture('list-route/enabled-user-job').then((fixture) => {
responses.push(fixture)
})

cy.intercept({ pathname: /jobConfigurations$/ }, req => {
cy.intercept({ pathname: /jobConfigurations$/ }, (req) => {
const fixture = responses.shift()
req.reply(200, fixture)
})
Expand All @@ -28,15 +28,15 @@ Given('a disabled user job exists', () => {
Given('an enabled user job exists', () => {
const responses = []

cy.fixture('list-route/enabled-user-job').then(fixture => {
cy.fixture('list-route/enabled-user-job').then((fixture) => {
responses.push(fixture)
})

cy.fixture('list-route/disabled-user-job').then(fixture => {
cy.fixture('list-route/disabled-user-job').then((fixture) => {
responses.push(fixture)
})

cy.intercept({ pathname: /jobConfigurations$/ }, req => {
cy.intercept({ pathname: /jobConfigurations$/ }, (req) => {
const fixture = responses.shift()
req.reply(200, fixture)
})
Expand Down
13 changes: 8 additions & 5 deletions cypress/integration/list-route/user-job-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ When('the user clicks the run manually button', () => {
})

Then('the job will be executed upon confirmation', () => {
cy.intercept({ pathname: /execute$/, method: 'GET' }, req => {
cy.intercept({ pathname: /execute$/, method: 'GET' }, (req) => {
expect(req.url.endsWith('jobConfigurations/lnWRZN67iDU/execute')).to.be
.true
req.reply({ statusCode: 200 })
Expand All @@ -54,10 +54,13 @@ When('the user clicks the delete button', () => {
})

Then('the job will be deleted upon confirmation', () => {
cy.intercept({ pathname: /jobConfigurations$/, method: 'DELETE' }, req => {
expect(req.url.endsWith('jobConfigurations/lnWRZN67iDU')).to.be.true
req.reply({ statusCode: 200 })
})
cy.intercept(
{ pathname: /jobConfigurations$/, method: 'DELETE' },
(req) => {
expect(req.url.endsWith('jobConfigurations/lnWRZN67iDU')).to.be.true
req.reply({ statusCode: 200 })
}
)

cy.findByText('Are you sure you want to delete this job?').should('exist')
cy.findByRole('button', { name: 'Delete' }).click()
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/view-route/back-to-all-jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Given('the user navigated to the view job page', () => {
Then('there are two links to the job list page', () => {
cy.findAllByRole('link', { name: 'Back to all jobs' })
.should('have.length', 2)
.each(link => {
.each((link) => {
expect(link).to.have.attr('href', '#/')
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^8.0.1",
"@dhis2/cli-style": "^9.0.1",
"@dhis2/cli-style": "^10.4.1",
"@dhis2/cli-utils-cypress": "^9.0.2",
"@dhis2/cypress-commands": "^9.0.2",
"@dhis2/cypress-plugins": "^9.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AuthWall/selectors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const getAuthorized = me => {
export const getAuthorized = (me) => {
const { authorities } = me

if (!authorities) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormErrorBox/FormErrorBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const FormErrorBox = ({ submitError }) => {
title={i18n.t('Something went wrong whilst creating your job')}
>
<ul className={styles.list}>
{submitError.map(error => (
{submitError.map((error) => (
<li key={error}>{error}</li>
))}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/CronField.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const CronField = () => {
<CronPresetButton
setCron={
/* istanbul ignore next */
cron => form.change(FIELD_NAME, cron)
(cron) => form.change(FIELD_NAME, cron)
}
small
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/FormFields/DataIntegrityChecksField.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import styles from './DataIntegrityChecksField.module.css'

const { Field, useField } = ReactFinalForm

const VALIDATOR = value => {
const VALIDATOR = (value) => {
// should not validate when null or undefined
// means "Run all" is selected
if (!value == null) {
Expand All @@ -42,7 +42,7 @@ const DataIntegrityChecksField = ({ label, name }) => {
const [runSelected, setRunSelected] = useState(hasValue)

const translatedOptions = options
.map(option => ({
.map((option) => ({
...option,
value: option.name,
label: getCheckName(option.name),
Expand Down Expand Up @@ -114,7 +114,7 @@ const LabelComponent = ({ label, severity, highlighted, disabled }) => (

LabelComponent.propTypes = TransferOption.propTypes

const renderOption = option => (
const renderOption = (option) => (
<TransferOption {...option} label={<LabelComponent {...option} />} />
)

Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/DataIntegrityReportTypeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DataIntegrityReportTypeField = ({ name, constants }) => {
return null
}

const labeledOptions = constants.map(type => ({
const labeledOptions = constants.map((type) => ({
value: type,
label: getReportTypeLabel(type),
}))
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/JobTypeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const JobTypeField = () => {
value: jobType,
label: jobTypesMap[jobType],
}))
.filter(job => !!job.label)
.filter((job) => !!job.label)
.sort((job1, job2) => job1.label.localeCompare(job2.label))

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/SkipTableTypesField.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SkipTableTypesField = ({ label, name, parameterName }) => {
)
}

const translatedOptions = options.map(option => ({
const translatedOptions = options.map((option) => ({
value: option,
label: analyticsTableTypes[option] || option,
}))
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormFields/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* inputs expect and return a string, so we're formatting them to strings
*/

export const formatToString = value => {
export const formatToString = (value) => {
if (typeof value === 'number') {
return value.toString()
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/JobTable/JobTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const JobTable = ({ jobs }) => (
<TableCell>{i18n.t('No jobs to display')}</TableCell>
</TableRow>
) : (
jobs.map(job => <JobTableRow key={job.id} job={job} />)
jobs.map((job) => <JobTableRow key={job.id} job={job} />)
)}
</TableBody>
</Table>
Expand Down
2 changes: 1 addition & 1 deletion src/components/JobTable/Status.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const statuses = [
]

describe('<Status>', () => {
it.each(statuses)('renders without errors for %s status', status => {
it.each(statuses)('renders without errors for %s status', (status) => {
shallow(<Status status={status} />)
})

Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/CronPresetModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CronPresetModal = ({ setCron, hideModal }) => {
<Modal open small onClose={hideModal}>
<ModalTitle>{i18n.t('Choose a preset time/interval')}</ModalTitle>
<ModalContent>
{cronPresets.map(preset => (
{cronPresets.map((preset) => (
<Radio
{...preset}
checked={currentPreset === preset.value}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Store/StoreContext.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('StoreContext.Consumer', () => {

expectRenderError(
<StoreContext.Consumer>
{store => store.refetchJobs()}
{(store) => store.refetchJobs()}
</StoreContext.Consumer>,
message
)
Expand Down
Loading

0 comments on commit 8cda173

Please sign in to comment.