From dc554b8fd812a7ef6eee890d17e081dcac673043 Mon Sep 17 00:00:00 2001 From: LokiSharp Date: Sun, 15 Oct 2023 02:53:23 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=20Github=20Action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 1 + .github/workflows/main.yml | 28 ++++++++++++++++++++++++++++ common/package.json | 4 ++-- driver/package.json | 4 ++-- package.json | 2 +- storage/package.json | 4 ++-- storage/tests/DataBase.test.ts | 5 ++--- 7 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/main.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e6bf9a7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + branches: ["master", "dev", "releases/**"] + pull_request: + branches: ["master"] + +jobs: + build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node-version: [16.x, 18.x, 20.x, latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run lint + - run: npm run build + - run: npm run test \ No newline at end of file diff --git a/common/package.json b/common/package.json index c363cf5..409746b 100644 --- a/common/package.json +++ b/common/package.json @@ -17,8 +17,8 @@ "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx", - "test": "jest", - "coverage": "jest --coverage" + "test": "jest --forceExit", + "coverage": "jest --forceExit --coverage" }, "devDependencies": { "@types/jest": "^29.5.5", diff --git a/driver/package.json b/driver/package.json index b3e3328..b8bdd67 100644 --- a/driver/package.json +++ b/driver/package.json @@ -10,8 +10,8 @@ "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx", - "test": "jest", - "coverage": "jest --coverage" + "test": "jest --forceExit", + "coverage": "jest --forceExit --coverage" }, "devDependencies": { "@types/jest": "^29.5.5", diff --git a/package.json b/package.json index 51ebaf0..2dfeab0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "npm run test --workspaces", - "bulid": "npm run build --workspaces", + "build": "npm run build --workspaces", "lint": "npm run lint --workspaces" }, "repository": { diff --git a/storage/package.json b/storage/package.json index d813271..6494f78 100644 --- a/storage/package.json +++ b/storage/package.json @@ -17,8 +17,8 @@ "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx", - "test": "jest", - "coverage": "jest --coverage" + "test": "jest --forceExit", + "coverage": "jest --forceExit --coverage" }, "_moduleAliases": { "@": "src" diff --git a/storage/tests/DataBase.test.ts b/storage/tests/DataBase.test.ts index 0d84293..eeb6ef8 100644 --- a/storage/tests/DataBase.test.ts +++ b/storage/tests/DataBase.test.ts @@ -8,8 +8,7 @@ let db: DataBase; beforeAll(() => { process.env = { ...OLD_ENV }; // Make a copy - process.env.DB_PATH = "tmp/db.json"; - fs.mkdir("tmp", { recursive: true }); + process.env.DB_PATH = "db.json"; }); beforeEach(() => { @@ -19,7 +18,7 @@ beforeEach(() => { afterAll(() => { process.env = OLD_ENV; // Restore old environment - fs.rm("tmp", { recursive: true, force: true }); + fs.rm("db.json", { recursive: true, force: true }); }); test("DataBase", () => {