Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c9a9632ccc | |||
| 4174e14517 | 
							
								
								
									
										86
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										86
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -2,45 +2,83 @@ 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 | ||||
|       - name: 准备 | 获取包管理器版本 | ||||
|         run: | | ||||
|           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: | ||||
|           version: 9 | ||||
|           path: ~/.npm | ||||
|           key: ${{ runner.os }}-npm-pnpm-${{ env.PNPM_VERSION }} | ||||
|           restore-keys: | | ||||
|             ${{ runner.os }}-npm-pnpm- | ||||
|  | ||||
|       - name: Install dependencies | ||||
|         run: pnpm install --frozen-lockfile | ||||
|  | ||||
|       - name: Check JavaScript Syntax | ||||
|       - name: 准备 | 安装包管理器 | ||||
|         run: | | ||||
|           echo "🔍 Checking JavaScript syntax..." | ||||
|           node -c index.js | ||||
|           echo "✅ All JavaScript files have valid syntax" | ||||
|           npm install -g pnpm | ||||
|           pnpm --version | ||||
|           echo "✅ 包管理器安装成功" | ||||
|  | ||||
|       - name: Run Tests | ||||
|         run: | | ||||
|           echo "🧪 Running test suite..." | ||||
|           pnpm test | ||||
|  | ||||
|       - name: Test Action Execution | ||||
|       - name: 准备 | 获取项目依赖哈希 | ||||
|         id: files-hash | ||||
|         uses: ./ | ||||
|         with: | ||||
|           files: 'examples/*' | ||||
|           algorithm: 'sha256' | ||||
|           files: '**/pnpm-lock.yaml' | ||||
|  | ||||
|       - name: 准备 | 配置依赖缓存 | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: ~/.pnpm-store | ||||
|           key: ${{ runner.os }}-pnpm-store-${{ steps.files-hash.outputs.hash }} | ||||
|           restore-keys: | | ||||
|             ${{ runner.os }}-pnpm-store- | ||||
|  | ||||
|       - name: 准备 | 安装依赖 | ||||
|         run: | | ||||
|           pnpm install --frozen-lockfile | ||||
|           echo "✅ 依赖安装完成" | ||||
|  | ||||
|       - name: 测试 | 执行语法检查 | ||||
|         run: | | ||||
|           echo "🔍 执行 JavaScript 语法检查..." | ||||
|           node -c src/index.js | ||||
|           echo "✅ 语法检查通过" | ||||
|  | ||||
|       - name: 测试 | 执行 Lint 检查 | ||||
|         run: | | ||||
|           echo "🔍 执行 Lint 检查..." | ||||
|           pnpm run lint | ||||
|           echo "✅ Lint 检查通过" | ||||
|  | ||||
|       - name: 测试 | 执行格式化检查 | ||||
|         run: | | ||||
|           echo "🔍 执行格式化检查..." | ||||
|           pnpm run format:check | ||||
|           echo "✅ 格式化检查通过" | ||||
|  | ||||
|       - name: 测试 | 执行测试 | ||||
|         run: | | ||||
|           echo "🧪 执行测试..." | ||||
|           pnpm run test | ||||
|           echo "✅ 测试通过" | ||||
|   | ||||
| @@ -73,7 +73,7 @@ jobs: | ||||
| ## 输入参数 | ||||
|  | ||||
| | 输入参数    | 描述                                        | 必需  | 默认值   | | ||||
| | ----------------- | ------------------------------------------- | ----- | -------- | | ||||
| | ----------- | ------------------------------------------- | ----- | -------- | | ||||
| | `files`     | 文件路径或 glob 模式(每行一个)            | ✅ 是 | -        | | ||||
| | `algorithm` | 哈希算法:`md5`、`sha1`、`sha256`、`sha512` | ❌ 否 | `sha256` | | ||||
|  | ||||
|   | ||||
| @@ -22,4 +22,4 @@ outputs: | ||||
|  | ||||
| runs: | ||||
|   using: 'node20' | ||||
|   main: 'index.js' | ||||
|   main: 'src/index.js' | ||||
|   | ||||
							
								
								
									
										28
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,16 +1,16 @@ | ||||
| { | ||||
|   "name": "files-hash-action", | ||||
|   "version": "0.1.1", | ||||
|   "description": "A lightweight GitHub Action to calculate hash of multiple files", | ||||
|   "main": "index.js", | ||||
|   "description": "A lightweight Gitea Action to calculate hash of multiple files", | ||||
|   "main": "src/index.js", | ||||
|   "scripts": { | ||||
|     "test": "vitest run", | ||||
|     "test:watch": "vitest watch", | ||||
|     "test:coverage": "vitest run --coverage", | ||||
|     "lint": "eslint .", | ||||
|     "lint:fix": "eslint . --fix", | ||||
|     "format": "prettier --write .", | ||||
|     "format:check": "prettier --check .", | ||||
|     "lint": "eslint ./src", | ||||
|     "lint:fix": "eslint ./src --fix", | ||||
|     "format": "prettier --write ./src", | ||||
|     "format:check": "prettier --check ./src", | ||||
|     "check": "pnpm run lint && pnpm run format:check", | ||||
|     "preinstall": "npx only-allow pnpm" | ||||
|   }, | ||||
| @@ -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" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import { | ||||
|   ErrorType, | ||||
|   ActionInputs, | ||||
|   ActionOutputs, | ||||
| } from '../index.js'; | ||||
| } from '../src/index.js'; | ||||
| import { createTestFile, createTestDir, cleanupTestFiles, cleanupTestDirs } from './utils.js'; | ||||
|  | ||||
| describe('测试 FileDiscovery 类', () => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user