diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..87380ba --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ['16.x', '18.x', '20.x'] + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install + run: npm ci + env: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 + - name: Lint + if: matrix.node-version == '20.x' + run: npm run lint + - name: Types + if: matrix.node-version == '20.x' + run: node_modules/.bin/tsc + - name: Test Node + run: npm run test:node + - name: Test Browser + if: matrix.node-version == '20.x' + run: | + export PUPPETEER_EXECUTABLE_PATH=$(which google-chrome-stable) + npm run test:browser diff --git a/package.json b/package.json index c6ffba2..808a00b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "lib/log.js", "scripts": { "lint": "eslint .", - "test": "mocha && mochify", + "test": "npm run test:node && npm run test:browser", + "test:node": "mocha", + "test:browser": "mochify", "watch": "mocha --watch", "build": "tsc --project tsconfig.pack.json", "clean": "rimraf --glob 'lib/*.d.ts'",