Skip to content

Commit

Permalink
Issue #340 - Feature: CI(Github Actions) - Performs linting, formatti…
Browse files Browse the repository at this point in the history
…ng, and type-checking (#432)

* feature/ci-workflow: add ci workflow

* feature/ci-workflow: checkout submodule in build job

* feature/ci-workflow: add caching, fixes

* feature/ci-workflow: add caching, fixes

* feature/ci-workflow: change workflow name

* feature/ci-workflow: change file name as per conventions

* feature/ci-workflow: add next build cache, fixes

* feature/ci-workflow: update actions/cache to v4
  • Loading branch information
ayushtiwari110 authored Mar 5, 2024
1 parent 32e036d commit c80509b
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: PR Workflow
on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
linting_and_type-checking:
name: Linting, Formatting and Type checking
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache Node dependencies
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: yarn list

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

- name: Install dependencies
run: yarn install --frozen-lockfile


- name: Linting and Formatting checks
run: yarn run lint

- name: Type checking
run: yarn run typecheck

build:
name: Build check
runs-on: ubuntu-latest
needs: linting_and_type-checking
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache Node dependencies
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: yarn list

- name: Cache Next Build
uses: actions/cache@v4
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn run build

0 comments on commit c80509b

Please sign in to comment.