Skip to content

Commit

Permalink
separate deps, create setup-job shared action
Browse files Browse the repository at this point in the history
  • Loading branch information
tranhl committed Mar 24, 2024
1 parent d357686 commit a033351
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 213 deletions.
20 changes: 20 additions & 0 deletions .github/actions/setup-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Setup Job
description: Checks out code, sets up Node.js, and installs dependencies

runs:
using: composite
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
id: install
run: npm ci
20 changes: 3 additions & 17 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,14 @@ jobs:
runs-on: ubuntu-latest

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

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
id: install
run: npm ci
- name: Setup Job
id: setup-job
uses: .github/actions/setup-job.yml

- name: Build dist/ Directory
id: build
run: npm run build

# This will fail the workflow if the PR wasn't created by Dependabot.
- name: Compare Directories
id: diff
run: |
Expand All @@ -59,8 +47,6 @@ jobs:
exit 1
fi
# If `dist/` was different than expected, and this was not a Dependabot
# PR, upload the expected version as a workflow artifact.
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
pull_request:
branches:
- '**'
push:
branches:
- 'main'

concurrency:
group: ci-${{ github.sha }}
cancel-in-progress: true

permissions:
contents: read

jobs:
eslint:
name: Lint - ESLint
runs-on: ubuntu-latest

steps:
- name: Setup Job
id: setup-job
uses: .github/actions/setup-job.yml

- name: Lint
id: lint
run: |
npm run lint:eslint
editorconfig:
name: Lint - EditorConfig
runs-on: ubuntu-latest

steps:
- name: Setup Job
id: setup-job
uses: .github/actions/setup-job.yml

- name: Lint
id: lint
run: npm run lint:ec

tests:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Setup Job
id: setup-job
uses: .github/actions/setup-job.yml

- name: Tests
id: tests
run: npm run test:ci
63 changes: 0 additions & 63 deletions .github/workflows/linting.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
npm exec lint-staged
npm exec ec -- -config .editorconfig-checker
npm exec vitest -- run
npm run lint:ec
npm run test:ci
Loading

0 comments on commit a033351

Please sign in to comment.