From e9804d195138e5f6b2a19407f288d932b5d31bbf Mon Sep 17 00:00:00 2001 From: Alex Li Date: Sun, 5 Nov 2023 23:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Combines=20workflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publishable.yml | 60 -------------- .github/workflows/tests.yml | 132 +++--------------------------- 2 files changed, 13 insertions(+), 179 deletions(-) delete mode 100644 .github/workflows/publishable.yml diff --git a/.github/workflows/publishable.yml b/.github/workflows/publishable.yml deleted file mode 100644 index 1de8313a8..000000000 --- a/.github/workflows/publishable.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Publishable - -on: - push: - branches: - - main - - '6.0.0' - paths: - - "**.md" - - "**.yaml" - - "**.yml" - pull_request: - branches: - - main - - '6.0.0' - paths: - - "**.md" - - "**.yaml" - - "**.yml" - -jobs: - publish-dry-run: - name: Publish dry-run with packages - runs-on: ubuntu-latest - strategy: - matrix: - directory: ["dio", "plugins/cookie_manager", "plugins/http2_adapter", "plugins/native_dio_adapter"] - steps: - - uses: actions/checkout@v3 - - name: "Check documents file size < 128kb" - working-directory: ${{ matrix.directory }} - run: | - limit_size=$(expr 128 \* 1024) # Maximum 128kb. - changelog_size=$(stat -c%s CHANGELOG.md) - echo "CHANGELOG.md file size: $changelog_size." - if [ $changelog_size -gt $limit_size ]; then - echo "CHANGELOG.md exceeded the maximum size: $changelog_size > $limit_size." - exit 1 - fi - readme_size=$(stat -c%s README.md) - echo "README.md file size: $readme_size." - if [ $readme_size -gt $limit_size ]; then - echo "README.md exceeded the maximum size: $readme_size > $limit_size." - exit 1 - fi - if [ -f README_ZH.md ]; then - readme_zh_size=$(stat -c%s README_ZH.md) - echo "README_ZH.md file size: $readme_zh_size." - if [ readme_zh_size -gt $limit_size ]; then - echo "README_ZH.md exceeded the maximum size: $readme_zh_size > $limit_size." - exit 1 - fi - fi - - uses: subosito/flutter-action@v2 - - run: | - if grep -q "flutter:" "${{ matrix.directory }}/pubspec.yaml"; then - flutter pub get - fi - - run: dart pub publish --dry-run - working-directory: ${{ matrix.directory }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b7170deaf..71669a6ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Tests +name: Format & Analyze & Dry-run & Test on: push: @@ -15,135 +15,29 @@ on: - "**.md" jobs: - format: - name: Check formatting - runs-on: ubuntu-latest - strategy: - matrix: - directory: [ - "dio", - "example", - "example_flutter_app", - "plugins/cookie_manager", - "plugins/http2_adapter", - "plugins/native_dio_adapter" - ] - defaults: - run: - working-directory: ${{ matrix.directory }} - steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1.3 - with: - sdk: stable - - run: dart format --set-exit-if-changed . - - analyze: - needs: format - name: Analyze Dart-only libraries - runs-on: ubuntu-latest - strategy: - matrix: - directory: ["dio", "example", "plugins/cookie_manager", "plugins/http2_adapter"] - defaults: - run: - working-directory: ${{ matrix.directory }} - steps: - - uses: actions/checkout@v3 - - name: Prepare Dart SDK - uses: dart-lang/setup-dart@v1.3 - with: - sdk: stable - - name: Analyze - run: dart pub get && dart analyze --fatal-infos - - analyze_flutter: - needs: format - name: Analyze Flutter libraries - runs-on: ubuntu-latest - strategy: - matrix: - directory: ["example_flutter_app", "plugins/native_dio_adapter"] - defaults: - run: - working-directory: ${{ matrix.directory }} - steps: - - uses: actions/checkout@v3 - - name: Prepare Flutter SDK - uses: subosito/flutter-action@v2.8.0 - with: - cache: true - channel: stable - - name: Analyze - run: flutter pub get && flutter analyze --fatal-infos - - test_dio: - needs: [analyze, analyze_flutter] - name: Run unit tests with dio + workflows: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - sdk: [ 2.15.0, stable, beta ] - platform: [ vm, chrome, firefox ] + sdk: [ min, stable, beta ] steps: - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1.3 + - uses: subosito/flutter-action@v2.8.0 with: - sdk: ${{ matrix.sdk }} - - run: | - chmod +x ./scripts/prepare_pinning_certs.sh - ./scripts/prepare_pinning_certs.sh - shell: bash - - run: dart pub get - working-directory: dio - - run: dart test --chain-stack-traces --platform=${{ matrix.platform }} - working-directory: dio - - test_plugins: - needs: [analyze, analyze_flutter] - name: Run unit tests with plugins - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - sdk: [ 2.15.0, stable, beta ] - directory: ["plugins/cookie_manager", "plugins/http2_adapter"] - steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1.3 - with: - sdk: ${{ matrix.sdk }} + cache: true + flutter-version: ${{ matrix.sdk == 'min' && '2.8.0' || '' }} + channel: ${{ matrix.sdk == 'min' && '' || matrix.channel }} - run: | chmod +x ./scripts/prepare_pinning_certs.sh ./scripts/prepare_pinning_certs.sh shell: bash - - name: Install proxy - if: matrix.directory == 'plugins/http2_adapter' + - name: Install proxy for tests run: sudo apt-get install -y squid - run: dart pub get - working-directory: ${{ matrix.directory }} - - run: dart test --chain-stack-traces - working-directory: ${{ matrix.directory }} - - test_flutter_plugins: - needs: [analyze, analyze_flutter] - name: Run unit tests with Flutter plugins - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - channel: [ min, stable, beta ] - directory: ["plugins/native_dio_adapter"] - defaults: - run: - working-directory: ${{ matrix.directory }} - steps: - - uses: actions/checkout@v3 - - name: Prepare Flutter SDK - uses: subosito/flutter-action@v2.8.0 + - uses: bluefireteam/melos-action@v2 with: - cache: true - flutter-version: ${{ matrix.channel == 'min' && '3.13.0' || '' }} - channel: ${{ matrix.channel == 'min' && 'stable' || matrix.channel }} - - run: flutter test + run-bootstrap: false + - run: melos run files-patch + - run: melos run pre-bootstrap + - run: melos run github-ci