name: package:cupertino_http CI

on:
  push:
    branches:
      - main
      - master
    paths:
      - '.github/workflows/cupertino.yml'
      - 'pkgs/cupertino_http/**'
      - 'pkgs/http_client_conformance_tests/**'
      - 'pkgs/web_socket_conformance_tests/**'
  pull_request:
    paths:
      - '.github/workflows/cupertino.yml'
      - 'pkgs/cupertino_http/**'
      - 'pkgs/http_client_conformance_tests/**'
      - 'pkgs/web_socket_conformance_tests/**'
  schedule:
    - cron: "0 0 * * 0"

env:
  PUB_ENVIRONMENT: bot.github

jobs:
  format:
    name: "Format & Analyze"
    runs-on: macos-latest
    defaults:
      run:
        working-directory: pkgs/cupertino_http
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
        with:
          channel: 'stable'
      - id: install
        name: Install dependencies
        run: |
          dart pub get
          cd ios_test && flutter pub get
      - name: Check formatting
        run: dart format --output=none --set-exit-if-changed .
        if: always() && steps.install.outcome == 'success'
      - name: Analyze code
        run: flutter analyze --fatal-infos
        if: always() && steps.install.outcome == 'success'
  macos:
    name: "macOS: Test"
    runs-on: macos-latest
    defaults:
      run:
        working-directory: pkgs/cupertino_http
    strategy:
      fail-fast: false
      matrix:
        sdk: ['3.10.0', 'latest']
        os: [macos-13, macos-latest]
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260
        with:
          sdk: ${{ matrix.sdk }}
      - id: install
        name: Install dependencies
        run: dart pub get
      - name: Run tests
        run: dart test --test-randomize-ordering-seed=random
  ios:
    name: "iOS: Test"
    runs-on: macos-latest
    defaults:
      run:
        working-directory: pkgs/cupertino_http
    strategy:
      fail-fast: false
      matrix:
        # Test on the minimum supported flutter version and the latest
        # version.
        flutter-version: ["3.38.1", "any"]
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
        with:
          flutter-version: ${{ matrix.flutter-version }}
          channel: 'stable'
      - id: install
        name: Install dependencies
        run: flutter pub get
      - uses: futureware-tech/simulator-action@e89aa8f93d3aec35083ff49d2854d07f7186f7f5
        with:
          os: iOS
          os_version: '>=15.0'
      - name: Run tests
        run: |
          cd ios_test
          flutter pub get
          flutter test integration_test/combined_test.dart --test-randomize-ordering-seed=random
