Skip to content

Commit

Permalink
ci: codecov action adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
50rayn committed Jan 17, 2025
1 parent 1d664c8 commit 2a57582
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 42 deletions.
123 changes: 83 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ on:
pull_request:
branches:
- main

jobs:
lint:
prepare:
runs-on: ubuntu-latest
outputs:
store_path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
steps:
- uses: actions/checkout@v3

- name: Set node version to 18
- name: Set Node.js version
uses: actions/setup-node@v3
with:
node-version: 22

- uses: pnpm/action-setup@v2
name: Install pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 10
Expand All @@ -31,68 +34,108 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-node-22-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
${{ runner.os }}-node-22-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

lint:
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@v3

- name: Set Node.js version
uses: actions/setup-node@v3
with:
node-version: 22

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10

- name: Use pnpm cache
uses: actions/cache@v3
with:
path: ${{ needs.prepare.outputs.store_path }}
key: ${{ runner.os }}-node-22-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-22-pnpm-store-
- name: Run ESLint
run: pnpm lint

typecheck:
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@v3

- name: Installing modules
run: pnpm i
- name: Set Node.js version
uses: actions/setup-node@v3
with:
node-version: 22

- name: Building module
run: pnpm build
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10

- name: Running eslint
run: npx eslint
- name: Use pnpm cache
uses: actions/cache@v3
with:
path: ${{ needs.prepare.outputs.store_path }}
key: ${{ runner.os }}-node-22-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-22-pnpm-store-
- name: Running typecheck
- name: Run TypeScript Typecheck
run: pnpm run typecheck

unit-test:
runs-on: ubuntu-latest

needs: prepare
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3

- name: Setup Node.js
- name: Set Node.js version
uses: actions/setup-node@v3
with:
node-version: 22

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
- name: Use pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
path: ${{ needs.prepare.outputs.store_path }}
key: ${{ runner.os }}-node-22-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
${{ runner.os }}-node-22-pnpm-store-
- name: Installing modules
run: pnpm i

- name: Running tests
- name: Run Tests with Coverage
run: pnpm run test:coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Upload Coverage Reports
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./test-report.junit.xml
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./

- name: Upload Test Results
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true
files: ./coverage/cobertura-coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml.bk
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: ci

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set node version to 18
uses: actions/setup-node@v3
with:
node-version: 22

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 10
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Installing modules
run: pnpm i

- name: Building module
run: pnpm build

- name: Running eslint
run: npx eslint

- name: Running typecheck
run: pnpm run typecheck

unit-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 22

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 10
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Installing modules
run: pnpm i

- name: Running tests
run: pnpm run test:coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./test-report.junit.xml
token: ${{ secrets.CODECOV_TOKEN }}

# - name: Upload test results to Codecov
# uses: codecov/test-results-action@v1
# with:
# fail_ci_if_error: true
# files: ./coverage/cobertura-coverage.xml
# token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage
.DS_Store
.idea
*.log
*.tgz
*.tgz
*junit.xml
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// vite.config.ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
outputFile: './test-report.junit.xml',
reporters: ['junit'],
coverage: {
reporter: ['cobertura'],
},
Expand Down

0 comments on commit 2a57582

Please sign in to comment.