diff --git a/.github/workflows/codeCov.yml b/.github/workflows/codeCov.yml new file mode 100644 index 000000000..de3084039 --- /dev/null +++ b/.github/workflows/codeCov.yml @@ -0,0 +1,32 @@ +name: CodeCov + +on: + push: + branches: [master] + workflow_run: + workflows: ['Receive PR'] + types: + - completed + +jobs: + CodeCov: + environment: ali_oss_AK + runs-on: ubuntu-latest + env: + ONCI: true + ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}} + ALI_SDK_OSS_SECRET: ${{secrets.ALI_SDK_OSS_SECRET}} + ALI_SDK_OSS_REGION: ${{secrets.ALI_SDK_OSS_REGION}} + 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}} + steps: + - uses: actions/checkout@v2 + - name: test and report upload + run: | + npm install + npm run tsc + npx nyc --reporter=lcov node_modules/.bin/_mocha -t 60000 -r should test/node/*.test.js test/node/**/*.test.js + npx codecov -t ${{secrets.CODECOV_KEY}} diff --git a/.github/workflows/node_test.yml b/.github/workflows/node_test.yml index 0a48ae6c6..d1a0a7a21 100644 --- a/.github/workflows/node_test.yml +++ b/.github/workflows/node_test.yml @@ -18,14 +18,15 @@ jobs: runs-on: macos-latest env: + ONCI: true ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}} + ALI_SDK_OSS_REGION: ${{secrets.ALI_SDK_OSS_REGION}} 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: @@ -37,6 +38,7 @@ jobs: - uses: actions/checkout@v2 - name: browser build and test run: | + curl cip.cc npm install mkdir test/browser/build node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js @@ -50,11 +52,13 @@ jobs: env: ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}} ALI_SDK_OSS_SECRET: ${{secrets.ALI_SDK_OSS_SECRET}} + ALI_SDK_OSS_REGION: ${{secrets.ALI_SDK_OSS_REGION}} 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: @@ -77,12 +81,14 @@ jobs: env: ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}} + ALI_SDK_OSS_REGION: ${{secrets.ALI_SDK_OSS_REGION}} 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: @@ -105,13 +111,14 @@ jobs: env: ALI_SDK_OSS_ID: ${{secrets.ALI_SDK_OSS_ID}} + ALI_SDK_OSS_REGION: ${{secrets.ALI_SDK_OSS_REGION}} 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: diff --git a/karma.conf.js b/karma.conf.js index 9f8a83f90..b6319d480 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,5 +1,5 @@ -process.env.CHROME_BIN = require('puppeteer').executablePath() -const isCiEnv = process.env.ONCI +process.env.CHROME_BIN = require('puppeteer').executablePath(); +const isCiEnv = process.env.ONCI; module.exports = function (config) { config.set({ @@ -8,10 +8,10 @@ module.exports = function (config) { require('karma-mocha'), require('karma-browserify'), require('karma-chrome-launcher'), - require('karma-safari-launcher'), - require('karma-firefox-launcher') + require('karma-firefox-launcher'), + require('karma-safari-launcher') ], - browsers: isCiEnv ? ['ChromeHeadless'] : ['ChromeHeadless', 'Chrome', 'Safari', 'Firefox'], + browsers: isCiEnv ? ['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 1ab7621b0..f47d20e9b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "scripts": { "build-change-log": "standard-version", "test": "npm run tsc && mocha -t 60000 -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js", - "test-cov": "npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 60000 -r thunk-mocha -r should test/node/*.test.js test/node/**/*.test.js", + "test-cov": "npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 60000 -r should test/node/*.test.js test/node/**/*.test.js", "jshint": "jshint .", "autod": "autod", "build-test": "MINIFY=1 node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js && node -r dotenv/config task/browser-test-build.js > test/browser/build/tests.js", diff --git a/test/config.js b/test/config.js index 201ed45e7..f8c17d085 100644 --- a/test/config.js +++ b/test/config.js @@ -5,8 +5,8 @@ const config = module.exports; config.oss = { accessKeyId: env.ALI_SDK_OSS_ID, accessKeySecret: env.ALI_SDK_OSS_SECRET, - endpoint: env.ALI_SDK_OSS_ENDPOINT, - region: env.ALI_SDK_OSS_REGION || 'oss-cn-hangzhou' + region: env.ALI_SDK_OSS_REGION || 'oss-cn-hangzhou', + endpoint: env.ONCI ? 'https://oss-us-west-1.aliyuncs.com' : null }; config.sts = { @@ -14,7 +14,7 @@ config.sts = { accessKeySecret: env.ALI_SDK_STS_SECRET, roleArn: env.ALI_SDK_STS_ROLE, bucket: env.ALI_SDK_STS_BUCKET, - endpoint: env.TRAVIS ? 'https://sts.us-west-1.aliyuncs.com/' : null + endpoint: env.ONCI ? 'https://sts.aliyuncs.com/' : null }; -config.metaSyncTime = env.TRAVIS ? '30s' : '1000ms'; +config.metaSyncTime = env.ONCI ? '30s' : '1000ms'; diff --git a/test/node/sts.test.js b/test/node/sts.test.js index 717e3876b..1eae8e130 100644 --- a/test/node/sts.test.js +++ b/test/node/sts.test.js @@ -20,9 +20,7 @@ describe('test/sts.test.js', () => { const policy = { Statement: [ { - Action: [ - 'oss:*' - ], + Action: ['oss:*'], Effect: 'Allow', Resource: ['acs:oss:*:*:*'] } @@ -106,9 +104,7 @@ describe('test/sts.test.js', () => { let policy = { Statement: [ { - Action: [ - 'oss:PutObject' - ], + Action: ['oss:PutObject'], Effect: 'Allow', Resource: ['acs:oss:*:*:*'] } @@ -145,9 +141,7 @@ describe('test/sts.test.js', () => { policy = { Statement: [ { - Action: [ - 'oss:DeleteObject' - ], + Action: ['oss:DeleteObject'], Effect: 'Allow', Resource: ['acs:oss:*:*:*'] } @@ -205,5 +199,4 @@ describe('test/sts.test.js', () => { } }); }); - });