Skip to content

Commit

Permalink
ci: adds ci linting
Browse files Browse the repository at this point in the history
Adds the steps to lint the codebase in the CI workflow.

closes #259

ci(release): updates github actions

Bumps the github actions to the latest version.

chore(package): fixes the linting command

Corrects the linting command in the package.json file.

chore(eslint): ignores .astro and dist folders

ci: fixes commitlint job

Uses the pre-installed commitlint and config for the commitlint job.

ci: replaces `npm ci` `npm install` in workflows

ci: adds job permissions for checks

ci(commitlint): adds missing checkout step
  • Loading branch information
anguspiv committed Dec 24, 2024
1 parent 1c322bd commit c0018b0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 25 deletions.
71 changes: 52 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,62 @@ name: CI
on: [push, pull_request]

jobs:
lint:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Cache Node.js modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

commitlint:
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: read

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install required dependencies
run: |
apt update
apt install -y sudo
sudo apt install -y git curl
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
- name: Print versions
run: |
git --version
node --version
npm --version
npx commitlint --version
- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
npm install commitlint@latest

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

- name: Cache Node.js modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules-

- name: Install dependencies
run: npm install

- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

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

- name: Cache Node.js modules
uses: actions/cache@v3
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
run: npm ci
run: npm install

- name: Run Semantic Release
run: npx semantic-release
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import prettier from 'eslint-config-prettier';
export default [
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { globals: globals.browser } },
{ ignores: ['!.storybook'] },
{ ignores: ['!.storybook', 'dist', '.astro'] },
{ settings: { react: { version: 'detect' } } },
pluginJs.configs.recommended,
...typescript.configs.recommended,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "astro build",
"build-storybook": "storybook build",
"dev": "astro dev",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint": "eslint .",
"prepare": "husky",
"preview": "astro preview",
"storybook": "storybook dev -p 6006",
Expand Down

0 comments on commit c0018b0

Please sign in to comment.