Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: deduplicate dart tests in actions #2114

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/actions/coverage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dart tests
description: Run Dart Tests and collect coverage
inputs:
directory:
description: The directory to run tests in
required: false
default: ''
coverage:
description: Codecov name
required: false
default: ''
min-coverage:
description: Minimum coverage percentage
required: false
default: '0'

runs:
using: composite

steps:
- name: Format coverage info
if: ${{ inputs.coverage != '' }}
run: dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib
shell: bash
working-directory: ${{ inputs.directory }}

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v3
if: ${{ inputs.coverage != '' }}
with:
name: ${{ inputs.coverage != '' }}
files: ./${{ inputs.directory }}/coverage/lcov.info

- uses: VeryGoodOpenSource/very_good_coverage@c953fca3e24a915e111cc6f55f03f756dcb3964c # pin@v3.0.0
if: ${{ inputs.coverage != '' }}
with:
path: './${{ inputs.directory }}/coverage/lcov.info'
min_coverage: ${{ inputs.min-coverage }}
34 changes: 34 additions & 0 deletions .github/actions/dart-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Dart tests
description: Run Dart tests
inputs:
directory:
description: The directory to run tests in
required: false
default: ''
web:
description: Whether to run tests for web
required: false
default: 'true'

runs:
using: composite

steps:
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 # pin@v1
with:
sdk: ${{ matrix.sdk }}

- run: dart pub get
shell: bash
working-directory: ${{ inputs.directory }}

- name: Test VM
run: dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces
shell: bash
working-directory: ${{ inputs.directory }}

- name: Test dart2js
if: ${{ inputs.web == 'true' }}
run: dart test -p chrome --test-randomize-ordering-seed=random --chain-stack-traces
shell: bash
working-directory: ${{ inputs.directory }}
47 changes: 16 additions & 31 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:
- release/**
pull_request:
paths:
- "!**/*.md"
- "!**/class-diagram.svg"
- ".github/workflows/dart.yml"
- "dart/**"
- '!**/*.md'
- '!**/class-diagram.svg'
- '.github/workflows/dart.yml'
- 'dart/**'

jobs:
cancel-previous-workflow:
Expand All @@ -24,10 +24,6 @@ jobs:
name: Build ${{matrix.sdk}} on ${{matrix.os}}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash
working-directory: ./dart
strategy:
fail-fast: false
matrix:
Expand All @@ -39,47 +35,36 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4

- name: Test (VM and browser)
run: |
dart pub get
dart test -p chrome --test-randomize-ordering-seed=random --chain-stack-traces
dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces
dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib
- uses: ./.github/actions/dart-test
with:
directory: dart

- uses: ./.github/actions/coverage
if: runner.os == 'Linux' && matrix.sdk == 'stable'
with:
directory: dart
coverage: sentry
min-coverage: 85

- name: Install webdev
if: runner.os != 'Windows'
run: dart pub global activate webdev

- name: Build example
working-directory: dart/example
run: |
cd example
dart pub get
dart compile aot-snapshot bin/example.dart

- name: Build Web example
if: runner.os != 'Windows'
working-directory: dart/example_web
run: |
cd example_web
dart pub get
webdev build

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v3
if: runner.os == 'Linux' && matrix.sdk == 'stable'
with:
name: sentry
files: ./dart/coverage/lcov.info

- uses: VeryGoodOpenSource/very_good_coverage@c953fca3e24a915e111cc6f55f03f756dcb3964c # pin@v3.0.0
if: runner.os == 'Linux' && matrix.sdk == 'stable'
with:
path: "./dart/coverage/lcov.info"
min_coverage: 85

analyze:
uses: ./.github/workflows/analyze.yml
with:
Expand Down
37 changes: 11 additions & 26 deletions .github/workflows/dio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
- release/**
pull_request:
paths:
- "!**/*.md"
- "!**/class-diagram.svg"
- ".github/workflows/dio.yml"
- "dart/**"
- "dio/**"
- '!**/*.md'
- '!**/class-diagram.svg'
- '.github/workflows/dio.yml'
- 'dart/**'
- 'dio/**'

jobs:
cancel-previous-workflow:
Expand All @@ -25,10 +25,6 @@ jobs:
name: Build ${{matrix.sdk}} on ${{matrix.os}}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash
working-directory: ./dio
strategy:
fail-fast: false
matrix:
Expand All @@ -40,29 +36,18 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4

- name: Test (VM and browser)
run: |
dart pub get
dart test -p chrome --test-randomize-ordering-seed=random --chain-stack-traces
dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces
dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v3
if: runner.os == 'Linux' && matrix.sdk == 'stable'
- uses: ./.github/actions/dart-test
with:
name: sentry_dio
files: ./dio/coverage/lcov.info
directory: dio

- uses: VeryGoodOpenSource/very_good_coverage@c953fca3e24a915e111cc6f55f03f756dcb3964c # pin@v3.0.0
- uses: ./.github/actions/coverage
if: runner.os == 'Linux' && matrix.sdk == 'stable'
with:
path: "./dio/coverage/lcov.info"
min_coverage: 81
directory: dio
coverage: sentry_dio
min-coverage: 81

analyze:
uses: ./.github/workflows/analyze.yml
Expand Down
39 changes: 13 additions & 26 deletions .github/workflows/file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
- release/**
pull_request:
paths:
- "!**/*.md"
- "!**/class-diagram.svg"
- ".github/workflows/file.yml"
- "dart/**"
- "flutter/**"
- "file/**"
- '!**/*.md'
- '!**/class-diagram.svg'
- '.github/workflows/file.yml'
- 'dart/**'
- 'flutter/**'
- 'file/**'

jobs:
cancel-previous-workflow:
Expand All @@ -26,10 +26,6 @@ jobs:
name: Build ${{matrix.sdk}} on ${{matrix.os}}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash
working-directory: ./file
strategy:
fail-fast: false
matrix:
Expand All @@ -41,28 +37,19 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4

- name: Test VM
run: |
dart pub get
dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces
dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v3
if: runner.os == 'Linux' && matrix.sdk == 'stable'
- uses: ./.github/actions/dart-test
with:
name: sentry_file
files: ./file/coverage/lcov.info
directory: file
web: false

- uses: VeryGoodOpenSource/very_good_coverage@c953fca3e24a915e111cc6f55f03f756dcb3964c # pin@v3.0.0
- uses: ./.github/actions/coverage
if: runner.os == 'Linux' && matrix.sdk == 'stable'
with:
path: "./file/coverage/lcov.info"
min_coverage: 55
directory: file
coverage: sentry_file
min-coverage: 55

analyze:
uses: ./.github/workflows/analyze.yml
Expand Down
37 changes: 12 additions & 25 deletions .github/workflows/hive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
- release/**
pull_request:
paths:
- "!**/*.md"
- "!**/class-diagram.svg"
- ".github/workflows/hive.yml"
- "dart/**"
- "hive/**"
- '!**/*.md'
- '!**/class-diagram.svg'
- '.github/workflows/hive.yml'
- 'dart/**'
- 'hive/**'

jobs:
cancel-previous-workflow:
Expand All @@ -25,10 +25,6 @@ jobs:
name: Build ${{matrix.sdk}} on ${{matrix.os}}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
defaults:
run:
shell: bash
working-directory: ./hive
strategy:
fail-fast: false
matrix:
Expand All @@ -40,28 +36,19 @@ jobs:
- os: macos-latest
sdk: beta
steps:
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4

- name: Test VM
run: |
dart pub get
dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces
dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=lib

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v3
if: runner.os == 'Linux' && matrix.sdk == 'stable'
- uses: ./.github/actions/dart-test
with:
name: sentry_hive
files: ./hive/coverage/lcov.info
directory: hive
web: false

- uses: VeryGoodOpenSource/very_good_coverage@c953fca3e24a915e111cc6f55f03f756dcb3964c # pin@v3.0.0
- uses: ./.github/actions/coverage
if: runner.os == 'Linux' && matrix.sdk == 'stable'
with:
path: "./hive/coverage/lcov.info"
min_coverage: 55
directory: hive
coverage: sentry_hive
min-coverage: 55

analyze:
uses: ./.github/workflows/analyze.yml
Expand Down
Loading
Loading