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 28 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
48 changes: 48 additions & 0 deletions .github/workflows/coverage_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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:
generate:
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:vm
- name: '[Verify step] Test Dart packages [Chrome]'
run: melos run test:web:chrome
- name: '[Verify step] Test Dart packages [Firefox]'
run: melos run test:web: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'
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
53 changes: 34 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,38 @@ 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:vm
- 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: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: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
95 changes: 95 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Contributing Guidelines

First of all, thank you for considering contributing to the `dio` project! Open source projects like this one grow and thrive thanks to the contributions from people like you. Whether you're fixing bugs, adding new features, improving the documentation, or even reporting issues, every contribution is valuable and appreciated.

This document provides some guidelines to help ensure that your contributions are as effective as possible. Please take a moment to read through these guidelines before submitting your contribution.

Remember, everyone contributing to this project is expected to follow our code of conduct. This helps ensure a positive and inclusive environment for all contributors.

Thank you again for your contributions, and we look forward to seeing what you will bring to the `dio` project!

## Creating Good Tickets

> [!TIP]
> Before creating a new issue, it's a good practice to search for open tickets and pull requests to avoid duplicates.

### Bug Reports

When reporting a bug, please include the following information:

1. **Title**: A brief, descriptive title for the bug.
2. **Package**: Specify which package has the problem.
3. **Version**: The version of the package you are using.
4. **Operating System**: The OS on which the problem occurs.
5. **Adapter**: Specify which adapter(s) are used.
6. **Output of `flutter doctor -v`**: Required when used with Flutter.
7. **Dart Version**: The version of Dart you are using.
8. **Steps to Reproduce**: Detailed steps on how to reproduce the bug.
9. **Expected Result**: What you expected to happen.
10. **Actual Result**: What actually happened. Include logs, screenshots, or any other relevant information.

### Feature Requests

When requesting a new feature, please include the following information:

1. **Title**: A brief, descriptive title for the feature request.
2. **Request Statement**: Describe the problem that you believe the `dio` project could solve but currently doesn't.
3. **Solution Brainstorm**: Share your ideas on how the problem could be solved. If you don't have a specific solution in mind, that's okay too!

> [!TIP]
> Remember, the more information you provide, the easier it is for us to understand and address the issue. Thank you for your contributions!
> Please refrain from commenting on old, closed tickets. If an old issue seems related but doesn't fully address your problem, it's best to open a new ticket and reference the old one instead.

## Development

This project uses [Melos](https://github.com/invertase/melos) to manage the mono-repo and most tasks. Melos is a tool that optimizes the workflow for multi-package Dart and Flutter projects. For more information on how to use Melos, please refer to the [Melos documentation](https://melos.invertase.dev).


### Setup

To get started, you'll need to install Melos globally:

```bash
dart pub global activate melos
```

After installing Melos, you can clone the repository and install the dependencies:

```bash
git clone https://github.com/cfug/dio.git
cd dio
melos bootstrap
```

## Submitting changes

Before submitting your changes as a pull request, please make sure to format and analyze your and run the all tests. Here are the main melos scripts you should be aware of:

### Code quality

To format (and fix) all packages, run:
```bash
melos run format
# OR
melos run format:fix
```

To analyze all packages, run:
```bash
melos run analyze
```

### Testing

To run all tests, use:
```bash
melos run test
```

Individual test targets can be run with the appropriate scripts:
```bash
melos run test:vm
melos run test:web
melos run test:web:chrome
melos run test:web:firefox
```
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
Loading
Loading