Skip to content

Instantly share code, notes, and snippets.

@alvseven
Created December 11, 2023 15:49
Show Gist options
  • Select an option

  • Save alvseven/15338d59fb8dd0d86d53f9f21fc30738 to your computer and use it in GitHub Desktop.

Select an option

Save alvseven/15338d59fb8dd0d86d53f9f21fc30738 to your computer and use it in GitHub Desktop.
github actions pipeline with dependencies cache, eslint and tests run
name: Run Eslint And Tests
on:
pull_request:
branches:
- development # the branches you want
push:
branches:
- development # you probably you dont need this if you are using branch protection/gitflow
jobs:
workflow-dev:
runs-on: ubuntu-latest # choose the operational system
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.17.1 # specify the node version you want to use
- name: Install pnpm
run: npm install -g pnpm # if you are not using pnpm, you can remove this step or install yarn
- name: Install Dependencies
run: pnpm install
- name: Cache pnpm dependencies
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} # i will provide some links bellow so you can see how to cache npm or yarn dependencies
- name: Run Eslint
run: pnpm run lint:check-errors # change for the command you are using in your scripts in package.json
- name: Run Tests-E2E
run: pnpm run tests # same here, change it :D
# How to cache npm/yarn dependencies
# https://stackoverflow.com/questions/55110729/how-do-i-cache-steps-in-github-actions - npm
# https://github.com/actions/cache/blob/v3/examples.md#node---npm - npm
# https://github.com/actions/cache/blob/v3/examples.md#node---yarn - yarn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment