diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 42960d83..26e8b5c8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,29 +6,35 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - run: npm install - - run: grunt check - working-directory: ./scripts + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "14" + - run: npm install + - run: grunt check + working-directory: ./scripts + build-matrix: + name: Build matrix for unit test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: read-matrix + name: Read build matrix + run: echo "::set-output name=matrix::`jq -c . test/unit/config/run_matrix.json`" + outputs: + matrix: ${{ steps.read-matrix.outputs.matrix }} unit-test: + needs: build-matrix runs-on: ${{ matrix.os }} strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - browser: [ChromeWithFlags, FirefoxWithFlags] - include: - - os: windows-latest - browser: EdgeWithFlags + matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix)[github.event_name] }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '14' - - run: npm install - - name: Run test cases - env: - BROWSER: ${{matrix.browser}} - run: npm run unittest + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "14" + - run: npm install + - name: Run test cases + env: + BROWSER: ${{ matrix.browser }} + run: npm run unittest diff --git a/package.json b/package.json index d9b4cc4f..3884d46a 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,6 @@ }, "scripts": { "postinstall": "cd scripts && grunt prepare", - "unittest": "node ./node_modules/karma/bin/karma start test/unit/karma/ci.config.js" + "unittest": "node ./node_modules/karma/bin/karma start test/unit/config/karma.config.js" } } diff --git a/test/unit/karma/ci.config.js b/test/unit/config/karma.config.js similarity index 100% rename from test/unit/karma/ci.config.js rename to test/unit/config/karma.config.js diff --git a/test/unit/config/run_matrix.json b/test/unit/config/run_matrix.json new file mode 100644 index 00000000..d28e14b3 --- /dev/null +++ b/test/unit/config/run_matrix.json @@ -0,0 +1,34 @@ +{ + "push": { + "os": [ + "ubuntu-latest", + "windows-latest", + "macos-latest" + ], + "browser": [ + "ChromeWithFlags", + "FirefoxWithFlags" + ], + "include": [ + { + "os": "windows-latest", + "browser": "EdgeWithFlags" + } + ] + }, + "pull_request": { + "os": [ + "ubuntu-latest" + ], + "browser": [ + "ChromeWithFlags", + "FirefoxWithFlags" + ], + "include": [ + { + "os": "windows-latest", + "browser": "EdgeWithFlags" + } + ] + } +} \ No newline at end of file