Skip to content

Commit

Permalink
refactor: Update lcov filtering in Makefile and SpinifyTransport$WS$P…
Browse files Browse the repository at this point in the history
…B$VM
  • Loading branch information
PlugFox committed Jul 19, 2024
1 parent 02a6cab commit b62e191
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 32 deletions.
60 changes: 29 additions & 31 deletions .github/workflows/checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
workflow_dispatch:
push:
branches:
- "main"
- "master"
- "dev"
- "develop"
- "feature/**"
- "bugfix/**"
Expand All @@ -14,19 +16,7 @@ on:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- "pubspec.yaml"
pull_request:
branches:
- "master"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- .github/workflows/*.yml
- "pubspec.yaml"

jobs:
Expand All @@ -38,38 +28,54 @@ jobs:
working-directory: ./
container:
image: dart:stable
env:
cache-name: cache-spinify-package
timeout-minutes: 10
steps:
- name: 🚂 Get latest code
uses: actions/checkout@v3
id: checkout
uses: actions/checkout@v4

- name: 🚃 Cache pub modules
uses: actions/cache@v2
env:
cache-name: cache-spinify-package
- name: 📤 Restore pub modules
id: cache-spinify-package-restore
uses: actions/cache/restore@v4
with:
path: |
$PWD/.pub_cache/
key: ${{ runner.os }}-spinify-${{ env.cache-name }}-${{ hashFiles('**/pubspec.yaml') }}

- name: 🗄️ Export pub cache directory
id: export-pub-cache
timeout-minutes: 1
run: |
export PUB_CACHE=$PWD/.pub_cache/
export PATH="$PATH":"$HOME/.pub-cache/bin"
- name: 👷 Install Dependencies
id: install-dependencies
timeout-minutes: 1
run: dart pub get --no-example

- name: 📥 Save pub modules
id: cache-spinify-package-save
uses: actions/cache/save@v4
with:
path: |
$PWD/.pub_cache/
key: ${{ runner.os }}-spinify-${{ env.cache-name }}-${{ hashFiles('**/pubspec.yaml') }}

- name: 🔎 Check format
id: check-format
timeout-minutes: 1
run: dart format --set-exit-if-changed -l 80 -o none lib/

- name: 📈 Check analyzer
id: check-analyzer
timeout-minutes: 1
run: dart analyze --fatal-infos --fatal-warnings lib/

- name: 👀 Verify versions
id: verify-versions
timeout-minutes: 1
run: |
test -f pubspec.yaml && test -f lib/src/model/pubspec.yaml.g.dart
Expand All @@ -82,18 +88,10 @@ jobs:
echo "$version_dart" > /tmp/version_dart
diff /tmp/version_pubspec /tmp/version_dart
- name: 🧪 Run tests
- name: 🧪 Run unit tests
id: run-unit-tests
timeout-minutes: 2
run: |
dart pub global activate coverage
dart pub global run coverage:test_with_coverage -fb -o coverage -- \
--platform vm --compiler=kernel --coverage=coverage \
--reporter=github --file-reporter=json:coverage/tests.json \
--timeout=30s --concurrency=12 --color \
test/unit_test.dart
- name: 📥 Upload coverage to Codecov
timeout-minutes: 1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
dart test --color --platform=vm --concurrency=12 \
--timeout=60s --reporter=github --file-reporter=json:coverage/tests.json \
--coverage=coverage -- test/unit_test.dart
112 changes: 112 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Tests

on:
workflow_dispatch:
push:
branches:
- "main"
- "master"
- "dev"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- .github/workflows/*.yml
- "pubspec.yaml"
pull_request:
branches:
- "main"
- "master"
- "dev"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- .github/workflows/*.yml
- "pubspec.yaml"

jobs:
tests:
name: "Tests"
runs-on: ubuntu-latest
#runs-on: ${{ matrix.os }}
#strategy:
# matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
defaults:
run:
working-directory: ./
container:
image: dart:stable
env:
cache-name: cache-spinify-package
timeout-minutes: 15
steps:
- name: 🚂 Get latest code
id: checkout
uses: actions/checkout@v4

- name: 📤 Restore pub modules
id: cache-spinify-package-restore
uses: actions/cache/restore@v4
with:
path: |
$PWD/.pub_cache/
key: ${{ runner.os }}-spinify-${{ env.cache-name }}-${{ hashFiles('**/pubspec.yaml') }}

- name: 🗄️ Export pub cache directory
id: export-pub-cache
timeout-minutes: 1
run: |
export PUB_CACHE=$PWD/.pub_cache/
export PATH="$PATH":"$HOME/.pub-cache/bin"
- name: 👷 Install Dependencies
id: install-dependencies
timeout-minutes: 1
run: dart pub get --no-example

- name: 📥 Save pub modules
id: cache-spinify-package-save
uses: actions/cache/save@v4
with:
path: |
$PWD/.pub_cache/
key: ${{ runner.os }}-spinify-${{ env.cache-name }}-${{ hashFiles('**/pubspec.yaml') }}

- name: 🧪 Run tests
id: run-tests
timeout-minutes: 10
run: |
dart pub global activate coverage
dart pub global run coverage:test_with_coverage -fb -o coverage -- \
--platform vm --compiler=kernel --coverage=coverage \
--reporter=github --file-reporter=json:coverage/tests.json \
--timeout=10m --concurrency=12 --color \
test/unit_test.dart
- name: 🔍 Format coverage
id: format-coverage
timeout-minutes: 1
run: |
mv coverage/lcov.info coverage/lcov.base.info
lcov -r coverage/lcov.base.info -o coverage/lcov.base.info "lib/src/protobuf/client.*.dart" "lib/**/*.g.dart"
mv coverage/lcov.base.info coverage/lcov.info
lcov --list coverage/lcov.info
- name: 📥 Upload coverage to Codecov
id: upload-coverage
timeout-minutes: 2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ coverage: get
@dart pub global run coverage:test_with_coverage -fb -o coverage -- \
--platform vm --compiler=kernel --coverage=coverage \
--reporter=expanded --file-reporter=json:coverage/tests.json \
--timeout=30s --concurrency=12 --color \
--timeout=10m --concurrency=12 --color \
test/unit_test.dart test/smoke_test.dart
# @dart test --concurrency=6 --platform vm --coverage=coverage test/
# @dart run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib
Expand Down

0 comments on commit b62e191

Please sign in to comment.