Skip to content

Commit

Permalink
[UXE-5924] chore: implements lint workflow (#2113)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmendes21 authored Jan 31, 2025
1 parent eddf985 commit 998fa40
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
- [ ] Tags are added to the PR

#### These changes were tested on the following browsers:

- [ ] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari
- [ ] Brave
6 changes: 4 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
### What is the new behavior introduced by this PR?

### Does this PR introduce breaking changes?
- [ ] No
- [ ] Yes

- [ ] No
- [ ] Yes

### Does this PR introduce UI changes? Add a video or screenshots here.

Expand All @@ -24,7 +24,9 @@
- [ ] Tags are added to the PR

#### These changes were tested on the following browsers:

- [ ] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari
- [ ] Brave
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### CHANGELOG

### Does this deploy introduce breaking changes?

- [ ] No
- [ ] Yes

Expand All @@ -14,7 +15,7 @@

#### Make sure your pull request fits the checklist below (when applicable):

- [ ] The issue title follows the format: DEPLOY YYYY.MM.DD
- [ ] The issue title follows the format: DEPLOY YYYY-MM-DD
- [ ] The team was notified of the deploy
- [ ] Every change is validated in stage environment
- [ ] Every change is validated in stage environment
- [ ] Project version is incremented
44 changes: 44 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run Linters And Checking Build Integrity

on:
pull_request:
types: [opened, synchronize]
push:
branches:
- dev
env:
HUSKY: 0

jobs:
eslint:
runs-on: ubuntu-latest
container:
image: node:18-alpine3.18

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install SO Dependencies
run: apk add --no-cache curl bash git

- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install Dependencies
run: yarn ci

- name: Checking Build Integrity
run: |
echo "checking build integrity"
yarn build
rm -rf dist
rm -rf coverage
- name: Run ESLint
run: yarn lint

- name: Run Prettier Formatting
run: yarn prettier --check src/
5 changes: 0 additions & 5 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "checking build integrity"
yarn build
rm -rf dist
rm -rf coverage
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const parseStatusData = (status) => {
const isActive = status.toUpperCase() === 'ACTIVE'
const parsedStatus = isActive
? {
content: capitalizeFirstLetter(status),
severity: 'success'
}
content: capitalizeFirstLetter(status),
severity: 'success'
}
: {
content: capitalizeFirstLetter(status),
severity: 'danger'
}
content: capitalizeFirstLetter(status),
severity: 'danger'
}

return parsedStatus
}
Expand All @@ -59,23 +59,27 @@ const checkIfFieldExist = (field, defaultValue = '-') => field ?? defaultValue
const adapt = (httpResponse) => {
const isArray = Array.isArray(httpResponse.body?.results)

const parsedDigitalCertificates = isArray ? httpResponse.body.results?.map((item) => {
const subjectNames = checkIfFieldExist(item?.subject_name?.map((subject) => subject)?.join(','))
const typeMap = {
edge_certificate: EDGE_CERTIFICATE,
trusted_ca_certificate: TRUSTED_CA_CERTIFICATE
}
const parsedDigitalCertificates = isArray
? httpResponse.body.results?.map((item) => {
const subjectNames = checkIfFieldExist(
item?.subject_name?.map((subject) => subject)?.join(',')
)
const typeMap = {
edge_certificate: EDGE_CERTIFICATE,
trusted_ca_certificate: TRUSTED_CA_CERTIFICATE
}

return {
id: checkIfFieldExist(item?.id, null),
name: checkIfFieldExist(item?.name),
issuer: checkIfFieldExist(item?.issuer),
subjectName: subjectNames,
type: checkIfFieldExist(typeMap[item?.type]),
validity: item?.validity ? parseValidityDate(item.validity) : '-',
status: item?.status ? parseStatusData(item.status) : '-'
}
}) : []
return {
id: checkIfFieldExist(item?.id, null),
name: checkIfFieldExist(item?.name),
issuer: checkIfFieldExist(item?.issuer),
subjectName: subjectNames,
type: checkIfFieldExist(typeMap[item?.type]),
validity: item?.validity ? parseValidityDate(item.validity) : '-',
status: item?.status ? parseStatusData(item.status) : '-'
}
})
: []

const count = httpResponse.body?.count ?? 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,20 @@ describe('DigitalCertificatesServices', () => {
url: `v4/digital_certificates/certificates?ordering=name&page=1&page_size=10&fields=&search=Certificate1`,
method: 'GET'
})
expect(result).toEqual([{
id: fixtures.certificateMock.id,
name: fixtures.certificateMock.name,
issuer: fixtures.certificateMock.issuer,
type: 'TLS Certificate',
subjectName: "Subject 1,Subject 2",
validity: "Nov 10, 2023, 12:00 AM",
status: {
content: "Active",
severity: "success",
},
}])
expect(result).toEqual([
{
id: fixtures.certificateMock.id,
name: fixtures.certificateMock.name,
issuer: fixtures.certificateMock.issuer,
type: 'TLS Certificate',
subjectName: 'Subject 1,Subject 2',
validity: 'Nov 10, 2023, 12:00 AM',
status: {
content: 'Active',
severity: 'success'
}
}
])
})

it('should return correct certificates when ordering parameters are provided', async () => {
Expand All @@ -205,18 +207,20 @@ describe('DigitalCertificatesServices', () => {
url: `v4/digital_certificates/certificates?ordering=issuer&page=1&page_size=10&fields=&search=`,
method: 'GET'
})
expect(result).toEqual([{
id: fixtures.certificateMock.id,
name: fixtures.certificateMock.name,
issuer: fixtures.certificateMock.issuer,
type: 'TLS Certificate',
subjectName: "Subject 1,Subject 2",
validity: "Nov 10, 2023, 12:00 AM",
status: {
content: "Active",
severity: "success",
},
}])
expect(result).toEqual([
{
id: fixtures.certificateMock.id,
name: fixtures.certificateMock.name,
issuer: fixtures.certificateMock.issuer,
type: 'TLS Certificate',
subjectName: 'Subject 1,Subject 2',
validity: 'Nov 10, 2023, 12:00 AM',
status: {
content: 'Active',
severity: 'success'
}
}
])
})

it.each([
Expand Down

0 comments on commit 998fa40

Please sign in to comment.