From 8307cededf7f85d7f1f4c0824601927f91a8118a Mon Sep 17 00:00:00 2001 From: moca_tao7 Date: Fri, 8 Oct 2021 15:08:49 +0800 Subject: [PATCH] Feat/add ci headless (#998) * feat: update git action * feat: add puppeteer to ci browser test * feat: add puppeteer to ci browser test --- .github/workflows/node_test.yml | 30 ++++++++++++++++++++++++++++++ karma.conf.js | 5 ++++- package.json | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node_test.yml b/.github/workflows/node_test.yml index 025d6882e..0a48ae6c6 100644 --- a/.github/workflows/node_test.yml +++ b/.github/workflows/node_test.yml @@ -13,6 +13,36 @@ on: - completed jobs: + browser_test: + environment: ali_oss_AK + runs-on: macos-latest + + env: + ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}} + ALI_SDK_OSS_SECRET: ${{secrets.ALI_SDK_OSS_SECRET}} + ALI_SDK_STS_BUCKET: ${{secrets.ALI_SDK_STS_BUCKET}} + ALI_SDK_STS_ID: ${{secrets.ALI_SDK_STS_ID}} + ALI_SDK_STS_REGION: ${{secrets.ALI_SDK_STS_REGION}} + ALI_SDK_STS_ROLE: ${{secrets.ALI_SDK_STS_ROLE}} + ALI_SDK_STS_SECRET: ${{secrets.ALI_SDK_STS_SECRET}} + ONCI: true + + + strategy: + matrix: + node-version: [14.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: browser build and test + run: | + npm install + mkdir test/browser/build + node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js + node task/browser-test-build.js > test/browser/build/tests.js + npx karma start + node_10: environment: ali_oss_AK runs-on: macos-latest diff --git a/karma.conf.js b/karma.conf.js index 6db054a82..9f8a83f90 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,3 +1,6 @@ +process.env.CHROME_BIN = require('puppeteer').executablePath() +const isCiEnv = process.env.ONCI + module.exports = function (config) { config.set({ frameworks: ['mocha', 'browserify'], @@ -8,7 +11,7 @@ module.exports = function (config) { require('karma-safari-launcher'), require('karma-firefox-launcher') ], - browsers: ['Chrome', 'Safari', 'Firefox'], + browsers: isCiEnv ? ['ChromeHeadless'] : ['ChromeHeadless', 'Chrome', 'Safari', 'Firefox'], files: ['test/browser/build/aliyun-oss-sdk.min.js', 'test/browser/build/tests.js'], // preprocessors: { // 'dist/aliyun-oss-sdk.js': ['coverage'] diff --git a/package.json b/package.json index 9fecdbffe..1ab7621b0 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "mocha": "^9.1.2", "nyc": "^15.1.0", "promise-polyfill": "^6.0.2", + "puppeteer": "^10.4.0", "request": "^2.88.0", "should": "^11.0.0", "sinon": "^1.17.7",