Skip to content

Commit

Permalink
ci: replace semantic commit checks with new workflow (#791)
Browse files Browse the repository at this point in the history
* ci: replace semantic commit checks with new workflow

* style: fix prettier errors

* ci: fix lint script

* ci: fix d2-style script

* style: fix eslint errors
  • Loading branch information
ismay authored Jun 13, 2022
1 parent 5c9bbbf commit bc2e593
Show file tree
Hide file tree
Showing 59 changed files with 865 additions and 476 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 }}
2 changes: 1 addition & 1 deletion .huskyrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { config } = require('@dhis2/cli-style')
const husky = require(config.husky)

const tasks = arr => arr.join(' && ')
const tasks = (arr) => arr.join(' && ')

module.exports = {
hooks: {
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/analytics-tables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Before(() => {

cy.intercept(
{ pathname: /resourceTables\/analytics$/, method: 'POST' },
req => {
(req) => {
req.reply(200, {
response: {
id: JOB_ID,
Expand All @@ -18,7 +18,7 @@ Before(() => {

cy.intercept(
{ pathname: /system\/tasks\/ANALYTICS_TABLE/, method: 'GET' },
req => {
(req) => {
// Handle request for in-progress tasks
if (req.url.endsWith('ANALYTICS_TABLE')) {
req.reply(200, null)
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/data-integrity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const JOB_ID = 'JOB_ID'
Before(() => {
cy.clock()

cy.intercept({ pathname: /dataIntegrity$/, method: 'POST' }, req => {
cy.intercept({ pathname: /dataIntegrity$/, method: 'POST' }, (req) => {
req.reply(200, {
response: {
id: JOB_ID,
Expand All @@ -15,7 +15,7 @@ Before(() => {

cy.intercept(
{ pathname: /system\/taskSummaries\/DATA_INTEGRITY/, method: 'GET' },
req => {
(req) => {
expect(req.url.endsWith(JOB_ID)).to.be.true
req.reply(200, {
dataElementsWithoutDataSet: [
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/data-statistics/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Before, Given, Then } from 'cypress-cucumber-preprocessor/steps'

Before(() => {
cy.intercept({ pathname: /dataSummary$/, method: 'GET' }, req => {
cy.intercept({ pathname: /dataSummary$/, method: 'GET' }, (req) => {
req.reply(200, {
objectCounts: {},
activeUsers: {},
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/lock-exceptions/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given } from 'cypress-cucumber-preprocessor/steps'
import './user-views-lock-exceptions'
import './user-adds-lock-exception'
import './user-views-lock-exceptions.js'
import './user-adds-lock-exception.js'

Given('the user navigated to the lock exceptions page', () => {
cy.visit('/#/lock-exceptions')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Before(() => {
pathname: /lockExceptions$/,
method: 'POST',
},
req => {
(req) => {
req.reply({
statusCode: 200,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before(() => {
pathname: /lockExceptions$/,
method: 'DELETE',
},
req => {
(req) => {
req.reply({
statusCode: 200,
})
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/maintenance/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Before, Given, When, Then } from 'cypress-cucumber-preprocessor/steps'

Before(() => {
cy.intercept({ pathname: /maintenance$/, method: 'POST' }, req => {
cy.intercept({ pathname: /maintenance$/, method: 'POST' }, (req) => {
const url = new URL(req.url)
const expectFieldValue = (field, value) => {
expect(url.searchParams.has(field))
Expand All @@ -26,8 +26,8 @@ Before(() => {
'cacheClear',
'appReload',
]
checkedFields.forEach(field => expectFieldValue(field, 'true'))
uncheckedFields.forEach(field => expectFieldValue(field, null))
checkedFields.forEach((field) => expectFieldValue(field, 'true'))
uncheckedFields.forEach((field) => expectFieldValue(field, null))

req.reply({
statusCode: 200,
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/min-max-value-generation/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given, When } from 'cypress-cucumber-preprocessor/steps'
import './user-generates-min-max-values'
import './user-deletes-min-max-values'
import './user-generates-min-max-values.js'
import './user-deletes-min-max-values.js'

Given('the user navigated to the min-max values page', () => {
cy.visit('/#/min-max-value-generation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before(() => {
pathname: /minMaxValues/,
method: 'DELETE',
},
req => {
(req) => {
req.reply({
statusCode: 200,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before(() => {
pathname: /minMaxValues$/,
method: 'POST',
},
req => {
(req) => {
req.reply({
statusCode: 200,
})
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/resource-tables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const JOB_ID = 'JOB_ID'
Before(() => {
cy.clock()

cy.intercept({ pathname: /resourceTables$/, method: 'POST' }, req => {
cy.intercept({ pathname: /resourceTables$/, method: 'POST' }, (req) => {
req.reply(200, {
response: {
id: JOB_ID,
Expand All @@ -15,7 +15,7 @@ Before(() => {

cy.intercept(
{ pathname: /system\/tasks\/RESOURCE_TABLE/, method: 'GET' },
req => {
(req) => {
// Handle request for in-progress tasks
if (req.url.endsWith('RESOURCE_TABLE')) {
req.reply(200, null)
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@testing-library/cypress/add-commands'
import '@testing-library/cypress/add-commands.js'
import { enableAutoLogin, enableNetworkShim } from '@dhis2/cypress-commands'

enableAutoLogin()
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"cy:start": "BROWSER=none yarn start",
"cy:open": "d2-utils-cypress open --appStart 'yarn cy:start'",
"cy:run": "d2-utils-cypress run --appStart 'yarn cy:start'",
"lint:js": "d2-style js check",
"lint:text": "d2-style text check",
"lint:js": "d2-style check js",
"lint:text": "d2-style check text",
"lint:staged": "yarn lint:js --staged && yarn lint:text --staged",
"lint": "yarn lint:js && yarn lint:text",
"format:js": "d2-style js apply",
"format:text": "d2-style text apply",
"format:js": "d2-style apply js",
"format:text": "d2-style apply text",
"format:staged": "yarn format:js --staged && yarn format:text --staged",
"format": "yarn format:js && yarn format:text"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^8.3.3",
"@dhis2/cli-style": "^7.3.0",
"@dhis2/cli-style": "^10.4.1",
"@dhis2/cli-utils-cypress": "^7.0.1",
"@dhis2/cypress-commands": "^7.0.1",
"@dhis2/cypress-plugins": "^7.0.1",
Expand Down
7 changes: 3 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import './locales'

import './locales/index.js'
import { CssVariables } from '@dhis2/ui'
import React from 'react'
import { HashRouter } from 'react-router-dom'
import styles from './App.module.css'
import Routes from './components/Routes/Routes'
import Sidebar from './components/Sidebar/Sidebar'
import Routes from './components/Routes/Routes.js'
import Sidebar from './components/Sidebar/Sidebar.js'

const App = () => (
<HashRouter>
Expand Down
4 changes: 2 additions & 2 deletions src/components/DocsLink/DocsLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useConfig } from '@dhis2/app-runtime'
import { colors, Tooltip, IconQuestion24 } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../../locales'
import { getDocsKeyForSection } from '../../pages/sections.conf'
import i18n from '../../locales/index.js'
import { getDocsKeyForSection } from '../../pages/sections.conf.js'
import styles from './DocsLink.module.css'

const getDocsVersion = ({ major, minor, tag }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormattedNumber/FormattedNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'
import React from 'react'

const FormattedNumber = props => (
const FormattedNumber = (props) => (
<span>{new Intl.NumberFormat(i18n.language).format(props.value)}</span>
)

Expand Down
4 changes: 2 additions & 2 deletions src/components/LockExceptionsTable/LockExceptionsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const LockExceptionsTable = ({
<Table>
<TableHead>
<TableRowHead>
{columns.map(column => (
{columns.map((column) => (
<TableCellHead key={column}>
{columnLabels[column]}
</TableCellHead>
Expand All @@ -41,7 +41,7 @@ const LockExceptionsTable = ({
<TableBody>
{rows.map((row, index) => (
<TableRow key={index}>
{columns.map(column => (
{columns.map((column) => (
<TableCell key={column}>{row[column]}</TableCell>
))}
<TableCell>
Expand Down
4 changes: 2 additions & 2 deletions src/components/NotificationsTable/NotificationsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import React from 'react'
import styles from './NotificationsTable.module.css'

/* FIXME think of using an third party library for that, converting for a standard time format defined by design team */
const formatDateFromServer = dateFromServer => {
const formatDateFromServer = (dateFromServer) => {
if (dateFromServer) {
return `${dateFromServer.slice(0, 10)} ${dateFromServer.slice(11, 19)}`
}

return ''
}

const renderNotificationIcon = notification => {
const renderNotificationIcon = (notification) => {
if (notification.completed) {
if (notification.level === 'ERROR') {
return <IconError16 color={colors.red500} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageHeader/PageHeader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types'
import React from 'react'
import DocsLink from '../DocsLink/DocsLink'
import DocsLink from '../DocsLink/DocsLink.js'
import styles from './PageHeader.module.css'

const PageHeader = ({ title, sectionKey }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import React from 'react'
const mutation = {
resource: 'lockExceptions',
type: 'delete',
params: params => params,
params: (params) => params,
}

const RemoveLockExceptionModal = ({ lockException, onRemove, onClose }) => {
Expand All @@ -36,7 +36,7 @@ const RemoveLockExceptionModal = ({ lockException, onRemove, onClose }) => {
onRemove()
onClose()
},
onError: error => errorAlert.show({ error }),
onError: (error) => errorAlert.show({ error }),
})

const handleRemoveLockException = () => {
Expand Down
10 changes: 5 additions & 5 deletions src/components/Routes/Routes.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from 'react'
import { Switch, Route, Redirect } from 'react-router-dom'
import AddLockException from '../../pages/add-lock-exception/AddLockException.js'
import BatchDeleteLockExceptions from '../../pages/batch-delete-lock-exceptions/BatchDeleteLockExceptions'
import Home from '../../pages/home/Home'
import { sections } from '../../pages/sections.conf'
import BatchDeleteLockExceptions from '../../pages/batch-delete-lock-exceptions/BatchDeleteLockExceptions.js'
import Home from '../../pages/home/Home.js'
import { sections } from '../../pages/sections.conf.js'

const Routes = () => (
<Switch>
<Route exact path="/" component={Home} />
{sections.map(section => (
{sections.map((section) => (
<Route
key={section.key}
exact
path={section.path}
component={props => (
component={(props) => (
<section.component sectionKey={section.key} {...props} />
)}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Menu } from '@dhis2/ui'
import React from 'react'
import { sections } from '../../pages/sections.conf'
import SidebarItem from './SidebarItem'
import { sections } from '../../pages/sections.conf.js'
import SidebarItem from './SidebarItem.js'

const Sidebar = () => (
<Menu>
{sections.map(section => (
{sections.map((section) => (
<SidebarItem
key={section.key}
label={section.info.label}
Expand Down
2 changes: 1 addition & 1 deletion src/get-active-task-id-from-summary.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const getActiveTaskIdFromSummary = taskSummaryResponse => {
export const getActiveTaskIdFromSummary = (taskSummaryResponse) => {
const { taskId } = Object.entries(taskSummaryResponse).reduce(
(currLatestTask, [taskId, taskNotifications]) => {
// First notification is last array item, so its timestamp represents the task start
Expand Down
2 changes: 1 addition & 1 deletion src/get-updated-notifications.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const getUpdatedNotifications = taskNotifications => {
export const getUpdatedNotifications = (taskNotifications) => {
const lastIndex = taskNotifications.length - 1

// Reverse to sort oldest-newest
Expand Down
13 changes: 7 additions & 6 deletions src/hooks/use-poll.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useDataQuery } from '@dhis2/app-runtime'
import { useState, useRef, useEffect } from 'react'

const useConst = factory => {
const useConst = (factory) => {
const ref = useRef(null)
if (ref.current === null) {
ref.current = factory()
Expand Down Expand Up @@ -39,17 +39,18 @@ export const usePoll = ({ query, interval, checkDone }) => {
}))
const { refetch, error } = useDataQuery(wrappedQuery, {
lazy: true,
onComplete: data => {
onComplete: (data) => {
setData(data)
if (checkDone(data.poll)) {
cancel()
}
},
})
const { start, cancel, started: polling } = useLazyInterval(
refetch,
interval
)
const {
start,
cancel,
started: polling,
} = useLazyInterval(refetch, interval)

useEffect(() => {
return cancel
Expand Down
Loading

0 comments on commit bc2e593

Please sign in to comment.