name: Samples Dart

on:
  push:
    branches:
      - master
      - '[5-9]+.[0-9]+.x'
  pull_request:
    branches:
      - master
      - '[5-9]+.[0-9]+.x'
    paths:
      - 'samples/openapi3/client/petstore/dart*/**'

jobs:
  tests-dart:
    name: Tests Dart
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: 11
          cache: maven
      - name: Cache test dependencies
        uses: actions/cache@v3
        env:
          cache-name: pub-cache
        with:
          path: $PUB_CACHE
          key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('samples/**/pubspec.*') }}
      - uses: dart-lang/setup-dart@v1
        with:
          sdk: 2.15.0
      - name: Run tests
        uses: ./.github/actions/run-samples
        with:
          name: samples.dart
