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: | on: | ||||||
|   push: |   push: | ||||||
|     branches: [main] |     branches: [dev, release, master] | ||||||
|   pull_request: |   pull_request: | ||||||
|     branches: [main] |     branches: [dev, release, master] | ||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|   lint-and-test: |   test: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     name: Lint and Test |     name: 测试 | ||||||
|  |  | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout |       - name: 准备 | 签出代码 | ||||||
|         uses: actions/checkout@v4 |         uses: actions/checkout@v4 | ||||||
|  |  | ||||||
|       - name: Setup Node.js |       - name: 准备 | 配置开发环境 | ||||||
|         uses: actions/setup-node@v4 |         uses: actions/setup-node@v4 | ||||||
|         with: |         with: | ||||||
|           node-version: '20' |           node-version: '20' | ||||||
|  |  | ||||||
|       - name: Setup pnpm |       - name: 准备 | 获取包管理器版本 | ||||||
|         uses: pnpm/action-setup@v4 |         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: |         with: | ||||||
|           version: 9 |           path: ~/.npm | ||||||
|  |           key: ${{ runner.os }}-npm-pnpm-${{ env.PNPM_VERSION }} | ||||||
|  |           restore-keys: | | ||||||
|  |             ${{ runner.os }}-npm-pnpm- | ||||||
|  |  | ||||||
|       - name: Install dependencies |       - name: 准备 | 安装包管理器 | ||||||
|         run: pnpm install --frozen-lockfile |  | ||||||
|  |  | ||||||
|       - name: Check JavaScript Syntax |  | ||||||
|         run: | |         run: | | ||||||
|           echo "🔍 Checking JavaScript syntax..." |           npm install -g pnpm | ||||||
|           node -c index.js |           pnpm --version | ||||||
|           echo "✅ All JavaScript files have valid syntax" |           echo "✅ 包管理器安装成功" | ||||||
|  |  | ||||||
|       - name: Run Tests |       - name: 准备 | 获取项目依赖哈希 | ||||||
|         run: | |         id: files-hash | ||||||
|           echo "🧪 Running test suite..." |  | ||||||
|           pnpm test |  | ||||||
|  |  | ||||||
|       - name: Test Action Execution |  | ||||||
|         uses: ./ |         uses: ./ | ||||||
|         with: |         with: | ||||||
|           files: 'examples/*' |           files: '**/pnpm-lock.yaml' | ||||||
|           algorithm: 'sha256' |  | ||||||
|  |       - 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 "✅ 测试通过" | ||||||
|   | |||||||
| @@ -72,10 +72,10 @@ jobs: | |||||||
|  |  | ||||||
| ## 输入参数 | ## 输入参数 | ||||||
|  |  | ||||||
| | 输入参数          | 描述                                        | 必需  | 默认值   | | | 输入参数    | 描述                                        | 必需  | 默认值   | | ||||||
| | ----------------- | ------------------------------------------- | ----- | -------- | | | ----------- | ------------------------------------------- | ----- | -------- | | ||||||
| | `files`           | 文件路径或 glob 模式(每行一个)            | ✅ 是 | -        | | | `files`     | 文件路径或 glob 模式(每行一个)            | ✅ 是 | -        | | ||||||
| | `algorithm`       | 哈希算法:`md5`、`sha1`、`sha256`、`sha512` | ❌ 否 | `sha256` | | | `algorithm` | 哈希算法:`md5`、`sha1`、`sha256`、`sha512` | ❌ 否 | `sha256` | | ||||||
|  |  | ||||||
| ### 文件模式 | ### 文件模式 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,4 +22,4 @@ outputs: | |||||||
|  |  | ||||||
| runs: | runs: | ||||||
|   using: 'node20' |   using: 'node20' | ||||||
|   main: 'index.js' |   main: 'src/index.js' | ||||||
|   | |||||||
							
								
								
									
										28
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,16 +1,16 @@ | |||||||
| { | { | ||||||
|   "name": "files-hash-action", |   "name": "files-hash-action", | ||||||
|   "version": "0.1.1", |   "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", |   "main": "src/index.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "test": "vitest run", |     "test": "vitest run", | ||||||
|     "test:watch": "vitest watch", |     "test:watch": "vitest watch", | ||||||
|     "test:coverage": "vitest run --coverage", |     "test:coverage": "vitest run --coverage", | ||||||
|     "lint": "eslint .", |     "lint": "eslint ./src", | ||||||
|     "lint:fix": "eslint . --fix", |     "lint:fix": "eslint ./src --fix", | ||||||
|     "format": "prettier --write .", |     "format": "prettier --write ./src", | ||||||
|     "format:check": "prettier --check .", |     "format:check": "prettier --check ./src", | ||||||
|     "check": "pnpm run lint && pnpm run format:check", |     "check": "pnpm run lint && pnpm run format:check", | ||||||
|     "preinstall": "npx only-allow pnpm" |     "preinstall": "npx only-allow pnpm" | ||||||
|   }, |   }, | ||||||
| @@ -33,17 +33,9 @@ | |||||||
|     "sha256", |     "sha256", | ||||||
|     "sha512" |     "sha512" | ||||||
|   ], |   ], | ||||||
|   "author": "Files Hash Action", |   "packageManager": "pnpm@10.18.3", | ||||||
|   "license": "MIT", |  | ||||||
|   "engines": { |   "engines": { | ||||||
|     "node": ">=20" |     "node": ">=20", | ||||||
|   }, |     "pnpm": ">=10" | ||||||
|   "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" |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import { | |||||||
|   ErrorType, |   ErrorType, | ||||||
|   ActionInputs, |   ActionInputs, | ||||||
|   ActionOutputs, |   ActionOutputs, | ||||||
| } from '../index.js'; | } from '../src/index.js'; | ||||||
| import { createTestFile, createTestDir, cleanupTestFiles, cleanupTestDirs } from './utils.js'; | import { createTestFile, createTestDir, cleanupTestFiles, cleanupTestDirs } from './utils.js'; | ||||||
|  |  | ||||||
| describe('测试 FileDiscovery 类', () => { | describe('测试 FileDiscovery 类', () => { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user