diff --git a/.github/actions/coverage/action.yml b/.github/actions/coverage/action.yml new file mode 100644 index 0000000000..9eaf7f0393 --- /dev/null +++ b/.github/actions/coverage/action.yml @@ -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 }} diff --git a/.github/actions/dart-test/action.yml b/.github/actions/dart-test/action.yml new file mode 100644 index 0000000000..606f145c64 --- /dev/null +++ b/.github/actions/dart-test/action.yml @@ -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 }} diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 625dcf9c86..650adefa46 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -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: @@ -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: @@ -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: diff --git a/.github/workflows/dio.yml b/.github/workflows/dio.yml index e096e3a10e..902012b688 100644 --- a/.github/workflows/dio.yml +++ b/.github/workflows/dio.yml @@ -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: @@ -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: @@ -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 diff --git a/.github/workflows/file.yml b/.github/workflows/file.yml index 34e2e42ba4..30416c4f0a 100644 --- a/.github/workflows/file.yml +++ b/.github/workflows/file.yml @@ -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: @@ -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: @@ -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 diff --git a/.github/workflows/hive.yml b/.github/workflows/hive.yml index 2855960115..2f32603646 100644 --- a/.github/workflows/hive.yml +++ b/.github/workflows/hive.yml @@ -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: @@ -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: @@ -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 diff --git a/.github/workflows/logging.yml b/.github/workflows/logging.yml index a8e08fd172..6b6c1bf6be 100644 --- a/.github/workflows/logging.yml +++ b/.github/workflows/logging.yml @@ -6,11 +6,11 @@ on: - release/** pull_request: paths: - - "!**/*.md" - - "!**/class-diagram.svg" - - ".github/workflows/logging.yml" - - "dart/**" - - "logging/**" + - '!**/*.md' + - '!**/class-diagram.svg' + - '.github/workflows/logging.yml' + - 'dart/**' + - 'logging/**' jobs: cancel-previous-workflow: @@ -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: ./logging strategy: fail-fast: false matrix: @@ -40,28 +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_logging - files: ./logging/coverage/lcov.info + directory: logging - - uses: VeryGoodOpenSource/very_good_coverage@c953fca3e24a915e111cc6f55f03f756dcb3964c # pin@v2.1.0 if: runner.os == 'Linux' && matrix.sdk == 'stable' + - uses: ./.github/actions/coverage + if: runner.os == 'Linux' && matrix.sdk == 'stable' with: - path: "./logging/coverage/lcov.info" - min_coverage: 90 + directory: logging + coverage: sentry_logging + min-coverage: 90 analyze: uses: ./.github/workflows/analyze.yml