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 2, 2024
1 parent 0275996 commit 91023f7
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 39 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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
with:
submodules: "recursive"

- 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
61 changes: 24 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -56,9 +58,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,40 +80,28 @@ jobs:
with:
submodules: "recursive"

- uses: actions/download-artifact@v4
with:
name: artifact

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

- uses: pnpm/action-setup@v2
name: Install pnpm
if: ${{ matrix.pm == '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: login to 'verdaccio'
run: npx npm-cli-login -u test -p 1234 -e [email protected] -r http://localhost:4873

- name: build
- name: version for 'verdaccio'
run: |
pnpm esb
npm version patch --commit-hooks false --git-tag-version false
- name: login to verdaccio
run: npx npm-cli-login -u test -p 1234 -e [email protected] -r http://localhost:4873

- name: publish to verdaccio
- name: publish to 'verdaccio'
run: |
npm publish --registry http://localhost:4873
Expand All @@ -124,8 +117,8 @@ 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]
Expand All @@ -134,8 +127,12 @@ jobs:

steps:
- uses: actions/checkout@v4
# with:
# submodules: "recursive"

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

- uses: actions/setup-node@v4
with:
Expand All @@ -145,31 +142,21 @@ jobs:
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
run: pnpm add @actions/core -D

- name: config for test
run: |
Expand Down
5 changes: 3 additions & 2 deletions scripts/getversion.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFileSync } from "node:fs";
import * as core from "@actions/core";
import { exportVariable } from "@actions/core";
const { version } = JSON.parse(readFileSync("package.json"));
console.info(version);
core.exportVariable("version", version);
// process.stdout.write(`::set-env name=version::${version}`);
exportVariable("version", version);

0 comments on commit 91023f7

Please sign in to comment.