From 1839f9d71e5931c3ea929cbba6e91ef37cc0f35f Mon Sep 17 00:00:00 2001 From: Alexis Choupault Date: Tue, 21 Jan 2025 07:35:29 +0100 Subject: [PATCH] cache & inherited workflows --- .github/workflows/android.yml | 20 +-------------- .github/workflows/dart.yml | 13 +--------- .github/workflows/flutter_setup.yml | 39 +++++++++++++++++++++++++++++ .github/workflows/ios.yml | 21 ++++------------ .github/workflows/jdk_setup.yml | 31 +++++++++++++++++++++++ 5 files changed, 77 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/flutter_setup.yml create mode 100644 .github/workflows/jdk_setup.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d3b8eba..7a291c9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -9,27 +9,9 @@ on: jobs: build-and-test: runs-on: macos-latest + needs: [flutter_setup, jdk_setup] steps: - uses: actions/checkout@v4 - - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: '17' - cache: 'gradle' - - - name: Setup Flutter SDK - uses: flutter-actions/setup-flutter@v4 - with: - channel: stable - version: 3.27.0 - - - name: Install dependencies - run: flutter pub get - - - name: flutter doctor - run: flutter doctor -v - name: Set up local.properties run: | diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index b00e85f..d9fe2bf 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -7,24 +7,13 @@ on: branches: [ main ] jobs: + needs: flutter_setup build-and-test: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - name: Setup Flutter SDK - uses: flutter-actions/setup-flutter@v4 - with: - channel: stable - version: 3.27.0 - - - name: Install dependencies - run: flutter pub get - - - name: Flutter doctor - run: flutter doctor -v - - name: Analyze project source run: dart analyze diff --git a/.github/workflows/flutter_setup.yml b/.github/workflows/flutter_setup.yml new file mode 100644 index 0000000..97688bd --- /dev/null +++ b/.github/workflows/flutter_setup.yml @@ -0,0 +1,39 @@ +name: Flutter Setup + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + flutter_setup: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ${{ runner.tool_cache }}/flutter + key: flutter-${{ runner.os }}-stable-${{ hashFiles('**/.flutter-plugins') }} + restore-keys: | + flutter-${{ runner.os }}-stable- + + - name: Setup Flutter SDK + uses: flutter-actions/setup-flutter@v4 + with: + channel: stable + version: 3.27.0 + skip-install: ${{ steps.cache.outputs.cache-hit }} + + - name: Install dependencies + run: | + flutter pub get + cd example/ios + pod install + cd ../.. + + - name: Verify Flutter Installation + run: flutter doctor -v \ No newline at end of file diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 2c73a0c..72bdbde 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -7,34 +7,23 @@ on: branches: [ main ] jobs: + needs: flutter_setup build-and-test: runs-on: macOS-latest steps: - uses: actions/checkout@v4 - - name: Setup Flutter SDK - uses: flutter-actions/setup-flutter@v4 - with: - channel: stable - version: 3.27.0 - - - name: Install dependencies - run: | - flutter pub get - cd example/ios - pod install - cd ../.. - - name: Run tests run: | xcodebuild test -workspace ./example/ios/Runner.xcworkspace \ -scheme EasyCalendarTests \ -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.1' \ - | xcpretty --report html && exit ${PIPESTATUS[0]} + -resultBundlePath build/reports/EasyCalendarTests.xcresult + | exit ${PIPESTATUS[0]} - name: Upload xcresult file uses: actions/upload-artifact@v4 if: ${{ failure() }} with: - name: EasyCalendarTests-${{ github.run_number }}.html - path: build/reports/tests.html + name: EasyCalendarTests-${{ github.run_number }}.xcresult + path: build/reports/EasyCalendarTests.xcresult diff --git a/.github/workflows/jdk_setup.yml b/.github/workflows/jdk_setup.yml new file mode 100644 index 0000000..8e198b9 --- /dev/null +++ b/.github/workflows/jdk_setup.yml @@ -0,0 +1,31 @@ +name: JDK Setup + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + setup: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Cache JDK 17 + uses: actions/cache@v4 + with: + path: /usr/lib/jvm/java-17 + key: jdk-17-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + jdk-17-${{ runner.os }}- + + - name: Setup JDK 17 + if: steps.cache.outputs == '' + with: + distribution: 'corretto' + java-version: '17' + cache: 'gradle' + + - name: Verify JDK Installation + run: java -version \ No newline at end of file