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 all 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
96 changes: 96 additions & 0 deletions CONTRIBUTING-ZH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# 贡献指南

Language: [English](CONTRIBUTING.md) | 简体中文

首先,感谢您考虑为 `dio` 项目做出贡献!像这样的开源项目得以成长和繁荣,多亏了像您这样的贡献者。无论您是在修复错误、添加新功能、改进文档还是报告问题,每一份贡献都是宝贵和值得赞赏的。

本文档提供了一些指南,以帮助确保您的贡献尽可能有效。在提交您的贡献之前,请花一点时间阅读这些指南。

请记住,每个为这个项目做出贡献的人都需要遵循我们的行为准则。这有助于确保所有贡献者的积极和包容环境。

再次感谢您的贡献,我们期待看到您将为 `dio` 项目带来什么!

## 创建好的工单

> [!TIP]
> 在创建新问题之前,搜索已有的工单和拉取请求以避免重复是一个好习惯。

### 错误报告

报告错误时,请包括以下信息:

1. **标题**:简短描述性的错误标题。
2. **包**:指定有问题的包。
3. **版本**:您正在使用的包版本。
4. **操作系统**:出现问题的操作系统。
5. **适配器**:指定使用的适配器。
6. **`flutter doctor -v` 的输出**:使用 Flutter 时需要。
7. **Dart 版本**:您使用的 Dart 版本。
8. **重现步骤**:详细步骤说明如何重现错误。
9. **预期结果**:您期望发生的事情。
10. **实际结果**:实际发生的事情。包括日志、屏幕截图或任何其他相关信息。

### 功能请求

请求新功能时,请包括以下信息:

1. **标题**:功能请求的简短描述性标题。
2. **请求声明**:描述您认为 `dio` 项目能解决但目前没有解决的问题。
3. **解决方案头脑风暴**:分享您的想法,关于如何解决问题。如果您没有特定的解决方案,那也没关系!

> [!TIP]
> 记住,您提供的信息越多,我们就越容易理解和解决问题。感谢您的贡献!
> 请避免评论旧的、已关闭的工单。如果旧问题似乎与您的问题有关但并未完全解决您的问题,最好开一个新工单并引用旧的。

## 开发

此项目使用 [Melos](https://github.com/invertase/melos) 管理单体仓库和大多数任务。Melos 是一个为 Dart 和 Flutter 的多包项目优化工作流的工具。有关如何使用 Melos 的更多信息,请参阅 [Melos 文档](https://melos.invertase.dev)。

### 设置

开始之前,您需要全局安装 Melos:

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

在安装 Melos 后,可以克隆仓库并安装依赖项:

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

## 提交更改

在以拉取请求提交您的更改之前,请确保格式化和分析您的代码并运行所有测试。以下是您应该了解的主要 melos 脚本:

### 代码质量

要格式化(和修复)所有包,请运行:
```bash
melos run format
# 或者
melos run format:fix
```

要分析所有包,请运行:
```bash
melos run analyze
```

### 测试

要运行所有测试,请使用:
```bash
melos run test
```

可以使用适当的脚本运行单个测试目标:
```bash
melos run test:vm
melos run test:web
melos run test:web:chrome
melos run test:web:firefox
```
97 changes: 97 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Contributing Guidelines

Language: English | [简体中文](CONTRIBUTING-ZH.md)

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