83
.github/workflows/ci.yml
vendored
83
.github/workflows/ci.yml
vendored
@@ -2,45 +2,78 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [dev, release, master]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches: [dev, release, master]
|
||||
|
||||
jobs:
|
||||
lint-and-test:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Lint and Test
|
||||
name: 测试
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
- name: 准备 | 签出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
- name: 准备 | 配置开发环境
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Check JavaScript Syntax
|
||||
- name: 准备 | 获取包管理器版本
|
||||
run: |
|
||||
echo "🔍 Checking JavaScript syntax..."
|
||||
PNPM_VERSION=$(grep -o '"packageManager": "[^"]*"' package.json | cut -d'@' -f2 | tr -d '"')
|
||||
echo "PNPM_VERSION=$PNPM_VERSION" >> $GITHUB_ENV
|
||||
echo "✅ 包管理器版本为 pnpm@$PNPM_VERSION"
|
||||
|
||||
- name: 准备 | 配置全局缓存
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-npm-pnpm-${{ env.PNPM_VERSION }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-npm-pnpm-
|
||||
|
||||
- name: 准备 | 安装包管理器
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm --version
|
||||
echo "✅ 包管理器安装成功"
|
||||
|
||||
- name: 准备 | 配置依赖缓存
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.pnpm-store
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: 准备 | 安装依赖
|
||||
run: |
|
||||
pnpm install --frozen-lockfile
|
||||
echo "✅ 依赖安装完成"
|
||||
|
||||
- name: 测试 | 执行语法检查
|
||||
run: |
|
||||
echo "🔍 执行 JavaScript 语法检查..."
|
||||
node -c index.js
|
||||
echo "✅ All JavaScript files have valid syntax"
|
||||
echo "✅ 语法检查通过"
|
||||
|
||||
- name: Run Tests
|
||||
- name: 测试 | 执行 Lint 检查
|
||||
run: |
|
||||
echo "🧪 Running test suite..."
|
||||
pnpm test
|
||||
echo "🔍 执行 Lint 检查..."
|
||||
pnpm run lint
|
||||
echo "✅ Lint 检查通过"
|
||||
|
||||
- name: 测试 | 执行格式化检查
|
||||
run: |
|
||||
echo "🔍 执行格式化检查..."
|
||||
pnpm run format:check
|
||||
echo "✅ 格式化检查通过"
|
||||
|
||||
- name: 测试 | 执行测试
|
||||
run: |
|
||||
echo "🧪 执行测试..."
|
||||
pnpm run test
|
||||
echo "✅ 测试通过"
|
||||
|
||||
- name: Test Action Execution
|
||||
uses: ./
|
||||
with:
|
||||
files: 'examples/*'
|
||||
algorithm: 'sha256'
|
||||
|
||||
18
package.json
18
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "files-hash-action",
|
||||
"version": "0.1.1",
|
||||
"description": "A lightweight GitHub Action to calculate hash of multiple files",
|
||||
"description": "A lightweight Gitea Action to calculate hash of multiple files",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
@@ -33,17 +33,9 @@
|
||||
"sha256",
|
||||
"sha512"
|
||||
],
|
||||
"author": "Files Hash Action",
|
||||
"license": "MIT",
|
||||
"packageManager": "pnpm@10.18.3",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/your-username/files-hash-action.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/your-username/files-hash-action/issues"
|
||||
},
|
||||
"homepage": "https://github.com/your-username/files-hash-action#readme"
|
||||
"node": ">=20",
|
||||
"pnpm": ">=10"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user