From b62e191425a1fa4bfa0b03ea0269c7ef6f59f1d9 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Fri, 19 Jul 2024 12:44:39 +0400 Subject: [PATCH] refactor: Update lcov filtering in Makefile and SpinifyTransport$WS$PB$VM --- .github/workflows/checkout.yml | 60 +++++++++--------- .github/workflows/tests.yml | 112 +++++++++++++++++++++++++++++++++ Makefile | 2 +- 3 files changed, 142 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/checkout.yml b/.github/workflows/checkout.yml index f99517c..02c2acb 100644 --- a/.github/workflows/checkout.yml +++ b/.github/workflows/checkout.yml @@ -4,7 +4,9 @@ on: workflow_dispatch: push: branches: + - "main" - "master" + - "dev" - "develop" - "feature/**" - "bugfix/**" @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..1a1c79e --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 diff --git a/Makefile b/Makefile index caca2eb..f47c6e8 100644 --- a/Makefile +++ b/Makefile @@ -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