From 18adc5b557fe55542d789ff3172b9d84d6e6585b Mon Sep 17 00:00:00 2001 From: Luka S Date: Tue, 25 Jul 2023 13:52:57 +0100 Subject: [PATCH] Simplify workflows (#1597) --- .github/workflows/analyse-test.yml | 35 ----- .github/workflows/branch.yml | 141 ++++++++++++++++++ .../workflows/{build-io.yml => master.yml} | 51 ++++++- .github/workflows/pr.yml | 48 ------ .github/workflows/publish.yml | 13 -- .github/workflows/push.yml | 54 ------- .github/workflows/score.yml | 26 ---- 7 files changed, 186 insertions(+), 182 deletions(-) delete mode 100644 .github/workflows/analyse-test.yml create mode 100644 .github/workflows/branch.yml rename .github/workflows/{build-io.yml => master.yml} (50%) delete mode 100644 .github/workflows/pr.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/push.yml delete mode 100644 .github/workflows/score.yml diff --git a/.github/workflows/analyse-test.yml b/.github/workflows/analyse-test.yml deleted file mode 100644 index 011db6706..000000000 --- a/.github/workflows/analyse-test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Analyse & Test -on: - workflow_call: - -jobs: - analyse-code: - name: "Analyse Code" - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Setup Flutter Environment - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - name: Get All Dependencies - run: flutter pub get - - name: Check Formatting - run: dart format --output=none --set-exit-if-changed . - - name: Check Lints - run: dart analyze --fatal-infos --fatal-warnings - - run-tests: - name: "Run Tests" - runs-on: ubuntu-latest - needs: analyse-code - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Setup Flutter Environment - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - name: Run Tests - run: flutter test -r expanded \ No newline at end of file diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml new file mode 100644 index 000000000..01015c88b --- /dev/null +++ b/.github/workflows/branch.yml @@ -0,0 +1,141 @@ +name: "Branch & Fork CI/CD" +on: + push: + branches: + - '!master' + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + score-package: + name: "Score Package" + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Run Dart Package Analyser + uses: axel-op/dart-package-analyzer@master + id: analysis + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + - name: Check Package Scores + env: + TOTAL: ${{ steps.analysis.outputs.total }} + TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} + run: | + if (( $TOTAL < $TOTAL_MAX )) + then + echo Package score less than available score. Improve the score! + exit 1 + fi + + analyse-code: + name: "Analyse Code" + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Flutter Environment + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Get All Dependencies + run: flutter pub get + - name: Check Formatting + run: dart format --output=none --set-exit-if-changed . + - name: Check Lints + run: dart analyze --fatal-infos --fatal-warnings + + run-tests: + name: "Run Tests" + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Flutter Environment + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Run Tests + run: flutter test -r expanded + + build-android: + name: "Build Android Example App" + runs-on: ubuntu-latest + needs: [run-tests, analyse-code, score-package] + defaults: + run: + working-directory: ./example + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Java 17 Environment + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "17" + - name: Setup Flutter Environment + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Build Android Application + run: flutter build apk + - name: Archive Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: apk-build + path: example/build/app/outputs/apk/release + if-no-files-found: error + + build-windows: + name: "Build Windows Example App" + runs-on: windows-latest + needs: [run-tests, analyse-code, score-package] + defaults: + run: + working-directory: ./example + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Flutter Environment + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Build Windows Application + run: flutter build windows + - name: Create Windows Application Installer + run: iscc "windowsApplicationInstallerSetup.iss" + working-directory: . + - name: Archive Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: exe-build + path: windowsTemp/WindowsApplication.exe + if-no-files-found: error + + build-web: + name: "Build Web Example App" + runs-on: ubuntu-latest + needs: [run-tests, analyse-code, score-package] + defaults: + run: + working-directory: ./example + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Flutter Environment + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Build Web Application + run: flutter build web --web-renderer canvaskit + - name: Archive Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: web-build + path: example/build/web + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/build-io.yml b/.github/workflows/master.yml similarity index 50% rename from .github/workflows/build-io.yml rename to .github/workflows/master.yml index 9026d14b7..806a51043 100644 --- a/.github/workflows/build-io.yml +++ b/.github/workflows/master.yml @@ -1,11 +1,19 @@ -name: Build IO Example Apps +name: "'fleaflet/flutter_map' 'master' CI/CD" on: - workflow_call: + push: + branches: + - master + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: build-android: - name: "Android" + name: "Build Android Example App" runs-on: ubuntu-latest + if: github.repository == 'fleaflet/flutter_map' defaults: run: working-directory: ./example @@ -29,10 +37,11 @@ jobs: name: apk-build path: example/build/app/outputs/apk/release if-no-files-found: error - + build-windows: - name: "Windows" + name: "Build Windows Example App" runs-on: windows-latest + if: github.repository == 'fleaflet/flutter_map' defaults: run: working-directory: ./example @@ -53,4 +62,34 @@ jobs: with: name: exe-build path: windowsTemp/WindowsApplication.exe - if-no-files-found: error \ No newline at end of file + if-no-files-found: error + + build-web: + name: "Build & Deploy Web Example App" + runs-on: ubuntu-latest + if: github.repository == 'fleaflet/flutter_map' + defaults: + run: + working-directory: ./example + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Setup Flutter Environment + uses: subosito/flutter-action@v2 + with: + channel: "stable" + - name: Build Web Application + run: flutter build web --web-renderer canvaskit + - name: Archive Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: web-build + path: example/build/web + if-no-files-found: error + - name: Publish Live Web App + uses: FirebaseExtended/action-hosting-deploy@main + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_FLEAFLET }}" + channelId: live + projectId: fleaflet-firebase \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 1848cf21d..000000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Branch Push & PR CI/CD -on: - push: - branches: - - '!master' - pull_request: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - score: - name: "Score Package" - uses: ./.github/workflows/score.yml - - analyse-test: - name: "Analyse & Test" - uses: ./.github/workflows/analyse-test.yml - - build-io: - name: "Build IO Example Apps" - needs: analyse-test - uses: ./.github/workflows/build-io.yml - - build-web: - name: "Build Web Example App" - runs-on: ubuntu-latest - needs: analyse-test - defaults: - run: - working-directory: ./example - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Setup Flutter Environment - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - name: Build Web Application - run: flutter build web --web-renderer canvaskit - - name: Archive Artifact - uses: actions/upload-artifact@v3.1.2 - with: - name: web-build - path: example/build/web - if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index c53c8e686..000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Publish To pub.dev - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+*' - -jobs: - publish: - name: "Publish" - uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 - with: - environment: 'pub.dev' \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index b6deb4e7f..000000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Master Push CI/CD -on: - push: - branches: - - master - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - score: - name: "Score Package" - uses: ./.github/workflows/score.yml - - analyse-test: - name: "Analyse & Test" - uses: ./.github/workflows/analyse-test.yml - - build-io: - name: "Build IO Example Apps" - needs: analyse-test - uses: ./.github/workflows/build-io.yml - - build-web: - name: "Build & Deploy Web Example App" - runs-on: ubuntu-latest - needs: analyse-test - defaults: - run: - working-directory: ./example - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Setup Flutter Environment - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - name: Build Web Application - run: flutter build web --web-renderer canvaskit - - name: Archive Artifact - uses: actions/upload-artifact@v3.1.2 - with: - name: web-build - path: example/build/web - if-no-files-found: error - - name: Publish Live Web App - uses: FirebaseExtended/action-hosting-deploy@main - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_FLEAFLET }}" - channelId: live - projectId: fleaflet-firebase \ No newline at end of file diff --git a/.github/workflows/score.yml b/.github/workflows/score.yml deleted file mode 100644 index 3eac35aa3..000000000 --- a/.github/workflows/score.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Score Package -on: - workflow_call: - -jobs: - score-package: - name: "Score Package" - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Run Dart Package Analyser - uses: axel-op/dart-package-analyzer@master - id: analysis - with: - githubToken: ${{ secrets.GITHUB_TOKEN }} - - name: Check Package Scores - env: - TOTAL: ${{ steps.analysis.outputs.total }} - TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} - run: | - if (( $TOTAL < $TOTAL_MAX )) - then - echo Package score less than available score. Improve the score! - exit 1 - fi \ No newline at end of file