Skip to content

Commit

Permalink
workflow with cache
Browse files Browse the repository at this point in the history
  • Loading branch information
DevTeaLeaf committed Jul 20, 2024
1 parent 6072394 commit be5efcf
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 22 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/0_common-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Common Setup

runs-on: ubuntu-latest

defaults:
run:
shell: bash

jobs:
setup:
runs-on: ubuntu-latest
outputs:
node_modules-cache-key: ${{ steps.cache.outputs.cache-hit }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache node_modules
id: cache
uses: actions/cache@v4
with:
path: |
node_modules
.yarn/cache
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
34 changes: 27 additions & 7 deletions .github/workflows/1_lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# name: ESLint Check

# on:
# push:
# branches: [main, master]
# pull_request:
# branches: [main, master]

# jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: lts/*
# - name: Install dependencies
# run: |
# yarn add eslint eslint-plugin-astro @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-prettier astro-eslint-parser --dev
# - name: Run ESLint
# run: yarn lint
# timeout-minutes: 20

name: ESLint Check

on:
Expand All @@ -9,14 +32,11 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: |
yarn add eslint eslint-plugin-astro @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-prettier astro-eslint-parser --dev
- name: Use common setup
uses: ./.github/workflows/0_common-setup.yml

- name: Run ESLint
run: yarn lint
timeout-minutes: 20
34 changes: 27 additions & 7 deletions .github/workflows/2_unit.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
name: Unit Tests(Vitest)
# name: Unit Tests(Vitest)
# on:
# push:
# branches: [main, master]
# pull_request:
# branches: [main, master]
# jobs:
# test:
# timeout-minutes: 60
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: lts/*
# - name: Install dependencies
# run: yarn install
# - name: Run vitest
# run: yarn test:unit

name: Unit Tests (Vitest)

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: yarn install
- name: Use common setup
uses: ./.github/workflows/0_common-setup.yml

- name: Run vitest
run: yarn test:unit
44 changes: 36 additions & 8 deletions .github/workflows/3_e2e.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,52 @@
name: End-to-End Tests(Playwright)
# name: End-to-End Tests(Playwright)
# on:
# push:
# branches: [main, master]
# pull_request:
# branches: [main, master]
# jobs:
# test:
# timeout-minutes: 60
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: lts/*
# - name: Install dependencies
# run: yarn install
# - name: Install Playwright Browsers
# run: yarn playwright install --with-deps
# - name: Run Playwright tests
# run: yarn test:e2e
# - uses: actions/upload-artifact@v4
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30

name: End-to-End Tests (Playwright)

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: yarn install
- name: Use common setup
uses: ./.github/workflows/0_common-setup.yml

- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn test:2e2
run: yarn test:e2e
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down

0 comments on commit be5efcf

Please sign in to comment.