Skip to content

Commit

Permalink
⚙️ config(ci): Run client and server tests separately.
Browse files Browse the repository at this point in the history
Fixes #812.
  • Loading branch information
make-github-pseudonymous-again committed May 19, 2024
1 parent 8ea91fd commit 2cd19ad
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 120 deletions.
181 changes: 61 additions & 120 deletions .github/workflows/ci:test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,123 +14,64 @@ concurrency:
jobs:

test:
name: Continuous integration (tests)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Cache ~/.cache/puppeteer 🎭
uses: actions/cache@v4
id: cache-puppeteer
env:
cache-name: cache-puppeteer
with:
path: ~/.cache/puppeteer
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Install 💾
uses: ./.github/actions/install

- name: Cache build 💽
uses: meteor-actions/cache-build@v4
with:
key: test

- name: Tests 🔬
run: meteor npm run ci:test

- name: Archive coverage data 💽
uses: actions/upload-artifact@v4
with:
name: test-coverage
path: .coverage
retention-days: 1

test-coverage-upload:
name: Continuous integration (upload tests coverage)

needs:
- test

runs-on: ubuntu-latest

timeout-minutes: 1

steps:
- name: Load coverage data 💽
uses: actions/download-artifact@v4
with:
name: test-coverage
path: .coverage

- name: Publish coverage report 📰
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: test
directory: ./.coverage/
fail_ci_if_error: true

test-app:
name: Continuous integration (app tests)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Cache ~/.cache/puppeteer 🎭
uses: actions/cache@v4
id: cache-puppeteer
env:
cache-name: cache-puppeteer
with:
path: ~/.cache/puppeteer
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Install 💾
uses: ./.github/actions/install

- name: Cache build 💽
uses: meteor-actions/cache-build@v4
with:
key: test-app

- name: App Tests 🕹️
run: meteor npm run ci:test -- --full-app

- name: Archive coverage data 💽
uses: actions/upload-artifact@v4
with:
name: test-app-coverage
path: .coverage
retention-days: 1

test-app-coverage-upload:
name: Continuous integration (upload app tests coverage)

needs:
- test-app

runs-on: ubuntu-latest

timeout-minutes: 1

steps:
- name: Load coverage data 💽
uses: actions/download-artifact@v4
with:
name: test-app-coverage
path: .coverage

- name: Publish coverage report 📰
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: test-app
directory: ./.coverage/
fail_ci_if_error: true
name: Continuous integration
strategy:

matrix:

test-type:
- test
- test-app

test-target:
- client
- server

include:

- test-target: client
test-env: 'TEST_SERVER=0'

- test-target: server
test-env: 'TEST_CLIENT=0'

- test-type: test
test-flags: '--'

- test-type: test-app
test-flags: '-- --full-app'

- test-target: client
test-type: test
test-timeout: 20
test-icon: 🕹️
coverage-flags: client,test

- test-target: client
test-type: test-app
test-timeout: 20
test-icon: 🧑‍💻
coverage-flags: client, test-app

- test-target: server
test-type: test
test-timeout: 20
test-icon: 🔬
coverage-flags: server,test

- test-target: server
test-type: test-app
test-timeout: 20
test-icon: 🤖
coverage-flags: server, test-app

uses: ./.github/workflows/test.yml
secrets: inherit
with:
test-target: ${{ matrix.test-target }}
test-type: ${{ matrix.test-type }}
test-icon: ${{ matrix.test-icon }}
test-env: ${{ matrix.test-env }}
test-flags: ${{ matrix.test-flags }}
test-timeout: ${{ matrix.test-timeout }}
coverage-flags: ${{ matrix.coverage-flags }}
87 changes: 87 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: test

on:
workflow_call:
inputs:
test-target:
type: string
required: true
test-type:
type: string
required: true
test-icon:
type: string
required: true
test-env:
type: string
required: true
test-flags:
type: string
required: true
test-timeout:
type: number
required: true
coverage-flags:
type: string
required: true

jobs:

test:
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.test-timeout }}

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Cache ~/.cache/puppeteer 🎭
uses: actions/cache@v4
id: cache-puppeteer
env:
cache-name: cache-puppeteer
with:
path: ~/.cache/puppeteer
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Install 💾
uses: ./.github/actions/install

- name: Cache build 💽
uses: meteor-actions/cache-build@v4
with:
key: ${{ inputs.test-target }}-${{ inputs.test-type }}

- name: Tests ${{ inputs.test-icon }}
run: ${{ inputs.test-env }} meteor npm run ci:test ${{ inputs.test-flags }}

- name: Archive coverage data 💽
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test-target }}-${{ inputs.test-type }}-coverage
path: .coverage
retention-days: 1

test-coverage-upload:
needs:
- test

runs-on: ubuntu-latest

timeout-minutes: 1

steps:
- name: Load coverage data 💽
uses: actions/download-artifact@v4
with:
name: ${{ inputs.test-target }}-${{ inputs.test-type }}-coverage
path: .coverage

- name: Publish coverage report 📰
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: ${{ inputs.coverage-flags }}
directory: ./.coverage/
fail_ci_if_error: true

0 comments on commit 2cd19ad

Please sign in to comment.