Skip to content

Commit

Permalink
Split ci testing out to action
Browse files Browse the repository at this point in the history
  • Loading branch information
klippx committed Aug 30, 2023
1 parent f19601c commit 70a60da
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 87 deletions.
20 changes: 8 additions & 12 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
name: 'Setup Environment'
description: 'Setup Environment'

inputs:
node-version:
description: 'The node version to use'
required: true
os:
description: 'The operating system to use'
required: true

runs:
using: composite
steps:
- name: Use Node.js ${{ inputs.node-version }}
- name: Use Node.js ${{ runner.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
node-version: ${{ runner.node-version }}

# https://github.com/actions/cache/blob/main/examples.md#node---yarn-2
- name: Get yarn cache directory path
Expand All @@ -28,6 +20,10 @@ runs:
with:
enableCrossOsArchive: true
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ inputs.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ inputs.os }}-yarn-
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --immutable --immutable-cache
shell: bash
14 changes: 0 additions & 14 deletions .github/actions/test-linux/action.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/actions/test-windows/action.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Test'
description: 'Test'

runs:
using: composite
steps:
- uses: ./.github/actions/setup-environment

- name: Lint
run: yarn lint
shell: bash
# Skip this step on Windows:
if: ${{ runner.os != 'Windows' }}

- name: Browser tests
run: yarn test:browser
shell: bash

- name: Browser tests
run: yarn test:browser
shell: bash

- name: Node tests
run: yarn test:node
shell: bash

- name: Service Worker tests
run: yarn test:service-worker
shell: bash

- name: Service Worker tests
run: yarn test:service-worker
shell: bash

- name: Browser integration tests
run: yarn test:browser:integration:ci
shell: bash

- name: Node integration tests
run: yarn test:node:integration:ci
shell: bash

- name: Build
run: yarn build
shell: bash
# Skip this step on Windows:
if: ${{ runner.os != 'Windows' }}
40 changes: 1 addition & 39 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,4 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# https://github.com/actions/cache/blob/main/examples.md#node---yarn-2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
enableCrossOsArchive: true
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --immutable --immutable-cache

# - name: Test (Linux)
# id: test-linux
# run: yarn test
# if: runner.os == 'Linux'
- uses: ./.github/actions/test-linux
if: runner.os == 'Linux'

# with:
# os: ${{ matrix.os }}
# node-version: ${{ matrix.node-version }}

- uses: ./.github/actions/test-windows
if: runner.os == 'Windows'

# with:
# os: ${{ matrix.os }}
# node-version: ${{ matrix.node-version }}
- uses: ./.github/actions/test
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"integration-server": "node spec/integration/server.js",
"test:browser": "jest --config jestSetup/configs/config.web.json",
"test:browser:integration": "cross-env NODE_ENV=test yarn karma start spec/integration/browser/karma.conf.js",
"test:browser:integration:ci": "cross-env SINGLE_RUN=true cross-env NODE_ENV=test yarn karma start spec/integration/browser/karma.conf.js",
"test:browser:watch": "yarn jest --config jestSetup/configs/config.web.json --watchAll",
"test:node": "yarn jest --config jestSetup/configs/config.node.json",
"test:node:integration": "cross-env NODE_ENV=test cross-env NODE_PATH=. cross-env JASMINE_CONFIG_PATH=spec/integration/node/support/jasmine.json ts-node node_modules/jasmine/bin/jasmine",
"test:node:integration:ci": "cross-env SINGLE_RUN=true cross-env NODE_ENV=test cross-env NODE_PATH=. cross-env JASMINE_CONFIG_PATH=spec/integration/node/support/jasmine.json ts-node node_modules/jasmine/bin/jasmine",
"test:node:watch": "yarn jest --config jestSetup/configs/config.node.json --watchAll",
"test:service-worker": "yarn jest --config jestSetup/configs/config.sw.json",
"test:service-worker:watch": "yarn jest --config jestSetup/configs/config.sw.json --watchAll",
Expand Down

0 comments on commit 70a60da

Please sign in to comment.