From 4d11f39737cc9425c3d14990a4920749a8adcdec Mon Sep 17 00:00:00 2001 From: uiolee <22849383+uiolee@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:51:18 +0800 Subject: [PATCH] ci: add lint, build --- .github/workflows/ci.yml | 90 ++++++++++++++++++++++++++++++++++++ .github/workflows/tester.yml | 58 ----------------------- package.json | 1 - 3 files changed, 90 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/tester.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7724e92 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: CI + +on: + push: + branches: + - "master" + pull_request: + +env: + default_node_version: 14 + +jobs: + test: + name: Test + needs: build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + node-version: ["14", "16", "18"] + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js ${{ matrix.node-version }} and Cache + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: npm + cache-dependency-path: "package.json" + + - name: Install Dependencies + run: npm install + - name: Test + run: npm run test + + coverage: + name: Coverage + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js ${{env.default_node_version}} and Cache + uses: actions/setup-node@v4 + with: + node-version: ${{env.default_node_version}} + cache: npm + cache-dependency-path: "package.json" + + - name: Install Dependencies + run: npm install + - name: Coverage + run: npm run test-cov + - name: Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.github_token }} + + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js ${{env.default_node_version}} and Cache + uses: actions/setup-node@v4 + with: + node-version: ${{env.default_node_version}} + cache: npm + cache-dependency-path: "package.json" + + - name: Install Dependencies + run: npm install + - name: Build + run: npm run build + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js ${{env.default_node_version}} and Cache + uses: actions/setup-node@v4 + with: + node-version: ${{env.default_node_version}} + cache: npm + cache-dependency-path: "package.json" + + - name: Install Dependencies + run: npm install + - name: Lint + run: npm run eslint diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml deleted file mode 100644 index d676bc8..0000000 --- a/.github/workflows/tester.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Tester - -on: [push, pull_request] - -jobs: - tester: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - node-version: ['14.x', '16.x', '18.x'] - fail-fast: false - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Cache NPM dependencies - uses: actions/cache@v1 - with: - path: node_modules - key: ${{ runner.os }}-npm-cache - restore-keys: ${{ runner.os }}-npm-cache - - name: Install Dependencies - run: npm install - - name: Test - run: npm run test - env: - CI: true - coverage: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - node-version: ['14.x'] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Cache NPM dependencies - uses: actions/cache@v1 - with: - path: node_modules - key: ${{ runner.os }}-npm-cache - restore-keys: ${{ runner.os }}-npm-cache - - name: Install Dependencies - run: npm install - - name: Coverage - run: npm run test-cov - env: - CI: true - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.github_token }} \ No newline at end of file diff --git a/package.json b/package.json index d10d00f..7cc0d55 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "build": "tsc -b", "clean": "tsc -b --clean", "eslint": "eslint .", - "pretest": "npm run clean && npm run build", "test": "mocha test/index.js --require ts-node/register", "test-cov": "c8 --reporter=lcovonly npm run test" },