Skip to content

Commit

Permalink
feat: impoves linting and testing in CI (#163)
Browse files Browse the repository at this point in the history
* feat: adds eslint to as a github action

* feat: setup cache for gh actions

* fix: stylelint not finding any files

* fix: commitlint

* feat: adds css.js files to lint-staged

* feat: adds snapshot testing to CI
  • Loading branch information
orivaa authored Apr 13, 2023
1 parent a833c97 commit b0305dc
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 10,522 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/build-design-tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,32 @@ jobs:
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/[email protected]
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}

- name: Install modules
run: npm ci

- name: Generate tokens
run: npm run tokens:generate
- name: Commit changes
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Commit lint

on: [push, pull_request]
on: [push]

jobs:
default:
commitlint:
runs-on: ubuntu-latest

steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
Expand All @@ -29,4 +29,6 @@ jobs:

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
run:
npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to
${{ github.event.pull_request.head.sha }} --verbose
44 changes: 30 additions & 14 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
# name: eslint
name: eslint

# on: [push, pull_request]
on: [push, pull_request]

# jobs:
# eslint:
# runs-on: ubuntu-latest
jobs:
eslint:
runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v2
steps:
- name: Checkout code
uses: actions/checkout@v3

# - name: Install dependencies
# run: npm install
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

# - name: Eslint
# uses: wagoid/eslint-pr-action@v1
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# eslint_args: '--ext .js,.jsx,.ts,.tsx'
- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/[email protected]
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}

- name: Install modules
run: npm ci

- name: Run ESLint
run: npm run lint
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on: [push, pull_request]

jobs:
snapshot-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/[email protected]
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}

- name: Install modules
run: npm ci

- name: Run Snapshot Tests
run: npm run test
1 change: 1 addition & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "packages/ui-library/**/*.{ts,tsx,js}": ["eslint --fix", "stylelint", "prettier --write"] }
10 changes: 9 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
"arrowParens": "always",
"quoteProps": "consistent",
"endOfLine": "lf",
"proseWrap": "always"
"proseWrap": "always",
"overrides": [
{
"files": "*.css.js",
"options": {
"singleQuote": false
}
}
]
}
13 changes: 0 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
"build:types": "npm run build:types --workspace=@boiler/ui-library",
"lint": "npm run lint --workspace=@boiler/ui-library",
"format": "npm run format:eslint --workspace=@boiler/ui-library && npm run format:prettier --workspace=@boiler/ui-library",
"lint:eslint": "npm run lint:eslint --workspace=@boiler/ui-library",
"lint:stylelint": "npm run lint:stylelint --workspace=@boiler/ui-library",
"format:eslint": "npm run format:eslint --workspace=@boiler/ui-library",
"lint:prettier": "prettier \"**/*.{ts,tsx}\" --check",
"format:prettier": "prettier \"**/*.{ts,tsx}\" --write",
"build-storybook": "build-storybook",
"test": "npm run test --workspace=@boiler/ui-library",
"test:update-snapshots": "npm run test:update-snapshots --workspace=@boiler/ui-library",
"test:a11y": "npm run test:a11y --workspace=@boiler/storybook",
Expand All @@ -41,13 +35,6 @@
"url": "https://github.com/deven-org/BO1LER-Kitchen/issues"
},
"homepage": "https://github.com/deven-org/BO1LER-Kitchen#readme",
"lint-staged": {
"packages/ui-library/**/*.{ts,tsx}": [
"eslint --fix",
"stylelint",
"prettier --write"
]
},
"devDependencies": {
"@boiler/react-example-app": "0.0.1",
"@boiler/figma-design-tokens": "0.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ module.exports = {
return typeToFilter.includes(token.attributes.type);
},
},
{
format: 'javascript/object',
destination: '__all-tokens.generated.js',
},
],
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-library/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ module.exports = {

plugins: ['@typescript-eslint'],
extends: ['../eslint-config-boiler'],
ignorePatterns: ['types/', '*.svg', '*.scss', '*.css', '*.md', '*.config.mjs', '.*'],
ignorePatterns: ['types/', '*.svg', '*.scss', '*.css', '*.md', '*.config.mjs', '.*', 'webpack*.js'],
};
5 changes: 3 additions & 2 deletions packages/ui-library/.stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"declaration-empty-line-before": null,
"property-no-vendor-prefix": null,
"alpha-value-notation": null,
"value-keyword-case": ["lower", { "ignoreProperties": ["--font-family-sans"] }],
"value-keyword-case": ["lower", { "ignoreProperties": ["--font-family-sans"], "ignoreKeywords": ["/POSTCSS/"] }],
"selector-class-pattern": null,
"no-descending-specificity": null,
"value-no-vendor-prefix": null
"value-no-vendor-prefix": null,
"font-family-name-quotes": null
}
}
4 changes: 3 additions & 1 deletion packages/ui-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"lint": "npm run lint:eslint && npm run lint:stylelint",
"format": "npm run format:eslint && npm run format:prettier",
"lint:eslint": "eslint 'src/**' --ext .ts,.tsx",
"lint:stylelint": "stylelint 'src/**/css.ts'",
"lint:stylelint": "stylelint 'src/**/*.css.js'",
"format:eslint": "eslint 'src/**' --ext .ts,.tsx --fix",
"lint:prettier": "prettier \"**/*.{ts,tsx}\" --check",
"format:prettier": "prettier \"**/*.{ts,tsx}\" --write",
"test": "wtr --config web-test-runner.config.mjs",
"test:update-snapshots": "npm run test -- --update-snapshots"
},
Expand Down
Loading

0 comments on commit b0305dc

Please sign in to comment.