Skip to content

Commit

Permalink
ci: improve test, build
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Jan 1, 2024
1 parent 0275996 commit 5c6c4cb
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 60 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
on:
workflow_call:
inputs:
cache:
description: "(boolean) use actions/cache"
required: false
default: true
type: boolean
node_version:
description: "(string) "
required: false
default: "lts/*"
type: string
runs_on:
description: "(string) "
required: false
default: "ubuntu-latest"
type: string

env:
CI: true

jobs:
build:
runs-on: ${{ inputs.runs_on }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}

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

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
if: ${{ inputs.cache }}
with:
path: |
${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm i

- name: Build
run: |
pnpm esb
- name: pack
run: |
npm pack
- uses: actions/upload-artifact@v4
with:
retention-days: 1
compression-level: 1
name: artifact
path: |
bin
*.tgz
71 changes: 11 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ jobs:
run: |
pnpm run lint
build:
uses: ./.github/workflows/build.yml

test-ve:
needs: build
runs-on: ${{ matrix.os }}
name: test (${{ matrix.pm }}, ${{ matrix.os }})
services:
verdaccio:
image: verdaccio/verdaccio:5
Expand All @@ -75,35 +78,13 @@ jobs:
with:
submodules: "recursive"

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

- uses: pnpm/action-setup@v2
name: Install pnpm
- uses: actions/download-artifact@v4
with:
version: 8
name: artifact

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
- uses: actions/setup-node@v4
with:
path: |
${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm i

- name: build
run: |
pnpm esb
node-version: "lts/*"

- name: login to verdaccio
run: npx npm-cli-login -u test -p 1234 -e [email protected] -r http://localhost:4873
Expand All @@ -124,53 +105,23 @@ jobs:
${{ matrix.pm }} create hexo
test-ln:
needs: build
runs-on: ${{ matrix.os }}
name: test (${{ matrix.pm }}, ${{ matrix.os }})
strategy:
matrix:
os: [windows-latest, macos-latest]
pm: ["pnpm", "npm"]
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
submodules: "recursive"
name: artifact

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

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

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: |
${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm i

- name: build
run: |
pnpm esb
- name: pack
run: |
npm pack
- name: config for test
run: |
mkdir ../temp
Expand Down

0 comments on commit 5c6c4cb

Please sign in to comment.