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

Converge melos usage and CI scripts & add code coverage #2136

Merged
merged 29 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
03c2439
Converge melos usage and CI scripts
kuhnroyal Mar 13, 2024
058c41b
Bootstrap has no no-select flag
kuhnroyal Mar 13, 2024
597aad1
Only run format/analyze/publish on stable SDK
kuhnroyal Mar 13, 2024
47d5650
Fix ignore packages env variable
kuhnroyal Mar 13, 2024
ab20bd7
Squid seems to be unused
kuhnroyal Mar 13, 2024
eabf922
Fix ignored packages env variable
kuhnroyal Mar 13, 2024
3483045
Improve generated ignored package env variable
kuhnroyal Mar 13, 2024
7a1a9ee
Fix package filter for publish dry-run step
kuhnroyal Mar 13, 2024
3d952b5
More fixes for ignored packages
kuhnroyal Mar 13, 2024
268b9c4
Revert "Squid seems to be unused"
kuhnroyal Mar 13, 2024
e790e0b
Cancel in progress workflow runs for new pushes
kuhnroyal Mar 13, 2024
1a6ca24
More fixes to ignored packages
kuhnroyal Mar 13, 2024
52e314e
New try
kuhnroyal Mar 13, 2024
cd06df4
Improve coverage setup & flow
kuhnroyal Mar 13, 2024
fa634c8
.....!!
kuhnroyal Mar 13, 2024
6246483
More env variable tries
kuhnroyal Mar 13, 2024
ae75699
This seems to work...
kuhnroyal Mar 13, 2024
c1ee5d9
Invert melos packages step by using the official MELOS_PACKAGES variable
kuhnroyal Mar 13, 2024
4ef7d91
Work around old melos version constraints
kuhnroyal Mar 13, 2024
b781212
Configure melos 2.9.0 which is the latest available on SDK 2.15.0
kuhnroyal Mar 13, 2024
be2ecc4
Attempt to generate coverage report
kuhnroyal Mar 13, 2024
94f2460
Add coverage for Flutter tests
kuhnroyal Mar 13, 2024
3fa6c9a
Add workflow that generates the coverage baseline
kuhnroyal Mar 13, 2024
686b67f
Merge branch 'main' into infra/melos-scripts
kuhnroyal Mar 17, 2024
0ed2802
Simplify and name web test scripts
kuhnroyal Mar 17, 2024
aa39208
Fix typo
kuhnroyal Mar 17, 2024
ee0eccc
Add a CONTRIBUTING doc
kuhnroyal Mar 17, 2024
b7c7000
Improve doc
kuhnroyal Mar 17, 2024
ec42167
Add Chinese contribution guidelines
kuhnroyal Mar 18, 2024
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
52 changes: 52 additions & 0 deletions .github/workflows/coverage_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'coverage_baseline'

# The code-coverage-report-action uses workflow artifacts to store the coverage report.
# The action will upload the coverage report as an artifact,
# and the action will also download the coverage report from the artifact in PRs.
# The action will then compare the coverage report from the PR with the coverage report from the base branch.
# For this to work, the action needs to be run on the base branch after each pushed commit
# or at least once before the artifact retention period ends.

on:
# Allow for manual runs
workflow_dispatch:
# Runs at 00:00, on day 1 of the month (every ~30 days)
schedule:
- cron: '0 0 1 * *'
push:
branches:
- main

jobs:
cron:
kuhnroyal marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
cache: true
channel: stable
- run: |
chmod +x ./scripts/prepare_pinning_certs.sh
./scripts/prepare_pinning_certs.sh
- name: Install proxy for tests
run: sudo apt-get update && sudo apt-get install -y squid
- run: dart pub get
- uses: bluefireteam/melos-action@v3
- name: '[Verify step] Test Dart packages [VM]'
run: melos run test:dart
- name: '[Verify step] Test Dart packages [Chrome]'
run: melos run test:web
env:
TEST_PLATFORM: chrome
- name: '[Verify step] Test Dart packages [Firefox]'
run: melos run test:web
env:
TEST_PLATFORM: firefox
- name: '[Verify step] Test Flutter packages'
run: melos run test:flutter
- name: '[Coverage] Generate report'
run: melos run coverage:combine
- uses: clearlyip/code-coverage-report-action@v4
with:
filename: 'coverage/cobertura.xml'
kuhnroyal marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.event.issue.number == 1633
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.CFUG_PUBLISHER }}
- uses: dart-lang/[email protected]
Expand Down
57 changes: 38 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
paths-ignore:
- "**.md"

# Ensure that new pushes/updates cancel running jobs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -leo pipefail {0}
Expand All @@ -25,9 +30,11 @@ jobs:
fail-fast: false
matrix:
sdk: [ min, stable, beta ]
env:
TEST_PRESET: all
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2.8.0
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
cache: true
flutter-version: ${{ matrix.sdk == 'min' && '2.8.0' || '' }}
Expand All @@ -38,30 +45,42 @@ jobs:
- name: Install proxy for tests
run: sudo apt-get update && sudo apt-get install -y squid
- run: dart pub get
- uses: bluefireteam/melos-action@v2
- uses: bluefireteam/melos-action@v3
with:
run-bootstrap: false
- name: Patching files for Flutter ${{ matrix.sdk }}
run: dart ./scripts/files_patch.dart
- name: Check satisfied packages
run: |
dart ./scripts/melos_ignored_packages.dart
echo $(cat .melos_ignored_packages) >> ~/.bash_profile
- name: Bootstrap
run: melos bootstrap $(eval echo $IGNORED_PACKAGES)
dart ./scripts/melos_packages.dart
echo $(cat .melos_packages) >> $GITHUB_ENV
- name: Melos Bootstrap
run: melos bootstrap
- name: '[Verify step] Format'
run: melos exec $(eval echo $IGNORED_PACKAGES) -- "dart format --set-exit-if-changed ."
- name: '[Verify step] Analyze Dart packages'
run: melos exec $(eval echo $IGNORED_PACKAGES) --no-flutter -- "dart analyze --fatal-infos"
- name: '[Verify step] Analyze Flutter packages'
run: melos exec $(eval echo $IGNORED_PACKAGES) --flutter -- "flutter analyze --fatal-infos"
if: ${{ matrix.sdk == 'stable' }}
run: melos run format
- name: '[Verify step] Analyze packages'
if: ${{ matrix.sdk == 'stable' }}
run: melos run analyze
- name: '[Verify step] Publish dry-run'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="dio_test" -- "dart pub publish --dry-run"
if: ${{ matrix.sdk == 'stable' }}
run: melos run publish-dry-run
- name: '[Verify step] Test Dart packages [VM]'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="dio_test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=vm"
run: melos run test:dart
- name: '[Verify step] Test Dart packages [Chrome]'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="*http2*" --ignore="dio_test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=chrome"
run: melos run test:web
env:
TEST_PLATFORM: chrome
- name: '[Verify step] Test Dart packages [Firefox]'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="*http2*" --ignore="dio_test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=firefox"
run: melos run test:web
env:
TEST_PLATFORM: firefox
- name: '[Verify step] Test Flutter packages'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --flutter -- "flutter test"
run: melos run test:flutter
- name: '[Coverage] Format & print test coverage'
if: ${{ matrix.sdk == 'stable' }}
run: melos run coverage:show
- name: '[Coverage] Coverage Report'
uses: clearlyip/code-coverage-report-action@v4
if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]'}}
with:
artifact_download_workflow_names: 'tests,coverage_base'
filename: 'coverage/cobertura.xml'
25 changes: 3 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,11 @@ pubspec_overrides.yaml
doc/api/
.cookies/

dio/.packages
dio/.dart_tool/
dio/.pub/
dio/.idea/
dio/.exampl
dio/coverage

# plugins
plugins/cookie_manager/.packages
plugins/cookie_manager/.dart_tool/
plugins/cookie_manager/.pub/
plugins/cookie_manager/.idea/
plugins/cookie_manager/.exampl

plugins/http2_adapter/.packages
plugins/http2_adapter/.dart_tool/
plugins/http2_adapter/.pub/
plugins/http2_adapter/.idea/
plugins/http2_adapter/.exampl
plugins/http2_adapter/test/*_pinning.txt

.vscode/

# FVM
.fvm
.fmvrc
.fvmrc

# Miscellaneous
.DS_Store
Expand All @@ -47,3 +26,5 @@ plugins/http2_adapter/test/*_pinning.txt
/.idea/*
!/.idea/dio.iml
!/.idea/modules.xml

coverage
2 changes: 2 additions & 0 deletions dio/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ build/

# Project related.
test/*_pinning.txt

coverage
2 changes: 2 additions & 0 deletions dio/dart_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tags:
presets:
all:
skip: false
default:
skip: true

override_platforms:
chrome:
Expand Down
108 changes: 108 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,111 @@ ide:
command:
bootstrap:
runPubGetInParallel: false
clean:
hooks:
post: |
# Clean all flutter projects
melos exec --flutter -- "flutter clean"
# Clean coverage files
rm -rf coverage
rm -rf pubspec.lock
melos exec --dir-exists coverage -- "rm -rf coverage"

scripts:
analyze:
description: Analyze all packages
exec: dart analyze --fatal-infos
format:
description: Format check all packages
exec: dart format --set-exit-if-changed .
format:fix:
description: Format all packages
exec: dart format .
publish-dry-run:
description: Publish dry-run all packages
exec: dart pub publish --dry-run
packageFilters:
noPrivate: true
test:
name: All tests
run: |
melos run test:dart
TEST_PLATFORM=chrome melos run test:web
TEST_PLATFORM=firefox melos run test:web
melos run test:flutter
test:dart:
name: Dart VM tests
exec: dart test --preset ${TEST_PRESET:-default} --coverage coverage/vm --chain-stack-traces
packageFilters:
flutter: false
dirExists: test
# Old syntax for melos <= 2.9.0 - this can be removed once we bump the minimum Dart SDK.
select-package:
flutter: false
dir-exists: test
ignore:
- 'dio_compatibility_layer'
- 'dio_http2_adapter'
test:web:
name: Dart Web tests
exec: dart test --platform ${TEST_PLATFORM:-chrome} --coverage coverage/${TEST_PLATFORM:-chrome} --preset ${TEST_PRESET:-default} --chain-stack-traces
packageFilters:
flutter: false
dirExists: test
ignore:
- '*http2*'
- '*cookie*'
# Old syntax for melos <= 2.9.0 - this can be removed once we bump the minimum Dart SDK.
select-package:
flutter: false
dir-exists: test
ignore:
- 'dio_compatibility_layer'
- '*http2*'
- '*cookie*'
test:flutter:
name: Flutter tests
exec: flutter test --coverage
packageFilters:
flutter: true
dirExists: test
ignore:
- '*example*'
# Old syntax for melos <= 2.9.0 - this can be removed once we bump the minimum Dart SDK.
# There is no packages to run on min SDK for this command.
select-package:
flutter: true
dir-exists: test
ignore:
- '*'
test:coverage:
name: Run all tests and display coverage
run: |
melos run test
melos run coverage:format
melos run coverage:show
coverage:format:
name: Format coverage
run: |
dart pub global activate coverage
melos run coverage:format:package
coverage:format:package:
name: Format coverage for each package
exec: dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib
packageFilters:
flutter: false
dirExists: coverage
coverage:combine:
name: Combine & convert coverage report
run: |
rm -rf coverage
dart pub global activate combine_coverage
dart pub global activate cobertura
melos run coverage:format
dart pub global run combine_coverage --repo-path=$pwd
dart pub global run cobertura convert --pubspec dio/pubspec.yaml
coverage:show:
name: Show coverage report
run: |
melos run coverage:combine
dart pub global run cobertura show
2 changes: 2 additions & 0 deletions plugins/compatibility_layer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

coverage
3 changes: 2 additions & 1 deletion plugins/compatibility_layer/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
presets:
# empty placeholder required in CI scripts
# empty placeholders required in CI scripts
all:
default:

override_platforms:
chrome:
Expand Down
43 changes: 1 addition & 42 deletions plugins/cookie_manager/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,4 @@
.pub/
build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
coverage
3 changes: 2 additions & 1 deletion plugins/cookie_manager/dart_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ file_reporters:
json: build/reports/test-results.json

presets:
# empty placeholder required in CI scripts
# empty placeholders required in CI scripts
all:
default:
Loading
Loading