From a2b5a408d57edcfee9e805e0c98de1438b38bb86 Mon Sep 17 00:00:00 2001 From: Neevash Ramdial Date: Fri, 8 Jan 2021 16:18:08 -0400 Subject: [PATCH] [WIP] github workflow --- .github/workflows/build.yml | 63 ------------- .github/workflows/flutter-analyze.yml | 24 ----- .github/workflows/scripts/install-flutter.sh | 13 +++ .github/workflows/scripts/install-tools.sh | 6 ++ .../workflows/scripts/validate-formatting.sh | 30 +++++++ .github/workflows/stream_flutter_workflow.yml | 88 +++++++++++++++++++ .github/workflows/test.yml | 30 ------- 7 files changed, 137 insertions(+), 117 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/flutter-analyze.yml create mode 100644 .github/workflows/scripts/install-flutter.sh create mode 100644 .github/workflows/scripts/install-tools.sh create mode 100644 .github/workflows/scripts/validate-formatting.sh create mode 100644 .github/workflows/stream_flutter_workflow.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index e4c6f701..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Build - -on: - push: - branches: - - master - - feature/new-ui - release: - types: - - created - -jobs: - build_and_deploy_ios: - runs-on: [macos-latest] - steps: - - uses: actions/checkout@v2 - - name: Install RubyGems - run: | - cd example/ios - bundle install - - uses: subosito/flutter-action@v1.4.0 - with: - channel: 'stable' - - name: Install firebase-tools - run: npm install -g firebase-tools - - name: Flutter setup - run: | - cd example - flutter pub get - - name: Build and release - env: - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }} - FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} - run: | - cd example - flutter build ios --release --no-codesign - cd ios - bundle exec fastlane deploy_to_firebase - build_and_deploy_android: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v1 - with: - java-version: '12.x' - - uses: subosito/flutter-action@v1.4.0 - with: - channel: 'stable' - - run: | - cd example - flutter pub get - - name: Build - run: | - cd example - flutter build apk - - name: Deploy - uses: wzieba/Firebase-Distribution-Github-Action@v1.2.1 - with: - appId: ${{secrets.FIREBASE_ANDROID_APPID}} - token: ${{secrets.FIREBASE_TOKEN}} - groups: stream-testers - file: example/build/app/outputs/apk/release/app-release.apk diff --git a/.github/workflows/flutter-analyze.yml b/.github/workflows/flutter-analyze.yml deleted file mode 100644 index 312a65ba..00000000 --- a/.github/workflows/flutter-analyze.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Flutter Analyze -on: - push: - branches: - - master - - pull_request: - branches: - - '*' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: subosito/flutter-action@v1 - with: - channel: 'beta' - - run: flutter pub get - - - name: 'Flutter Format Check' - run: flutter format --set-exit-if-changed --dry-run . - - - run: flutter analyze diff --git a/.github/workflows/scripts/install-flutter.sh b/.github/workflows/scripts/install-flutter.sh new file mode 100644 index 00000000..247d2797 --- /dev/null +++ b/.github/workflows/scripts/install-flutter.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +BRANCH=$1 + +if [ "$BRANCH" == "dev" ] +then + # TODO Flutter dev branch is currently broken so we're unable to test MacOS. + echo "TODO: Skipping macOS testing due to Flutter dev branch issue. Switching branch to stable." + BRANCH=stable +fi + +git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH _flutter +echo "::add-path::$GITHUB_WORKSPACE/_flutter/bin" \ No newline at end of file diff --git a/.github/workflows/scripts/install-tools.sh b/.github/workflows/scripts/install-tools.sh new file mode 100644 index 00000000..087cfecb --- /dev/null +++ b/.github/workflows/scripts/install-tools.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +flutter pub global activate melos +echo "::add-path::$HOME/.pub-cache/bin" +echo "::add-path::$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" +echo "::add-path::$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" \ No newline at end of file diff --git a/.github/workflows/scripts/validate-formatting.sh b/.github/workflows/scripts/validate-formatting.sh new file mode 100644 index 00000000..27e33215 --- /dev/null +++ b/.github/workflows/scripts/validate-formatting.sh @@ -0,0 +1,30 @@ +#!/bin/bash +if [[ $(git ls-files --modified) ]]; then + echo "" + echo "" + echo "These files are not formatted correctly:" + for f in $(git ls-files --modified); do + echo "" + echo "" + echo "-----------------------------------------------------------------" + echo "$f" + echo "-----------------------------------------------------------------" + echo "" + git --no-pager diff --unified=0 --minimal $f + echo "" + echo "-----------------------------------------------------------------" + echo "" + echo "" + done + if [[ $GITHUB_WORKFLOW ]]; then + git checkout . > /dev/null 2>&1 + fi + echo "" + echo "❌ Some files are incorrectly formatted, see above output." + echo "" + echo "To fix these locally, run: 'melos run format'." + exit 1 +else + echo "" + echo "✅ All files are formatted correctly." +fi \ No newline at end of file diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml new file mode 100644 index 00000000..282b2a8f --- /dev/null +++ b/.github/workflows/stream_flutter_workflow.yml @@ -0,0 +1,88 @@ + +name: stream_flutter_workflow + +env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + +on: + pull_request: + push: + branches: + - main + paths-ignore: + - 'docs/**' + +jobs: + analyze: + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 0 + - name: 'Install Flutter' + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: 'Install Tools' + run: | + ./.github/workflows/scripts/install-tools.sh + flutter pub global activate tuneup + - name: 'Bootstrap Workspace' + run: melos bootstrap + - name: 'Dart Analyze' + run: | + melos exec -c 3 -- \ + tuneup check + - name: 'Pub Check' + run: | + melos exec -c 1 --no-private --ignore="*example*" -- \ + pub publish --dry-run + format: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 0 + - name: 'Install Flutter' + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: 'Install Tools' + run: | + ./.github/workflows/scripts/install-tools.sh + curl -sL https://github.com/google/google-java-format/releases/download/google-java-format-1.3/google-java-format-1.3-all-deps.jar -o $HOME/google-java-format.jar + - name: 'Bootstrap Workspace' + run: melos bootstrap + - name: 'Dart' + run: | + melos exec -c 1 -- \ + flutter format . + ./.github/workflows/scripts/validate-formatting.sh + - name: 'Objective-C' + if: ${{ success() || failure() }} + run: | + melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" -- \ + find . -maxdepth 3 -name "*.h" -o -name "*.m" -print0 \| xargs -0 clang-format -i --style=Google --verbose + ./.github/workflows/scripts/validate-formatting.sh + - name: 'Java' + if: ${{ success() || failure() }} + run: | + melos exec -c 4 --ignore="*platform_interface*" --ignore="*web*" -- \ + find . -maxdepth 12 -name "*.java" -print0 \| xargs -0 java -jar $HOME/google-java-format.jar --replace + ./.github/workflows/scripts/validate-formatting.sh + + test: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 0 + - name: 'Install Flutter' + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: 'Install Tools' + run: ./.github/workflows/scripts/install-tools.sh + - name: 'Bootstrap Workspace' + run: melos bootstrap + - name: 'Flutter Test' + run: | + melos exec -c 3 --dir-exists=test --ignore="*example*" --ignore="*web*" -- \ + flutter test \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index a76cc4c8..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Test - -on: - pull_request: -jobs: - test: - runs-on: [ubuntu-latest] - steps: - - uses: actions/checkout@v2 - - name: Flutter action - uses: subosito/flutter-action@v1.4.0 - with: - channel: 'stable' - - name: Get dependencies - run: flutter pub get - - name: Run formatter - run: flutter format -n --set-exit-if-changed . - - name: Coverage fix - run: | - file=test/coverage_helper_test.dart - echo "// Helper file to make coverage work for all dart files\n" > $file - echo "// ignore_for_file: unused_import" >> $file - find lib -name '*.dart' | grep -e '[^g]\.dart' | grep -v '_html.dart' | cut -c4- | awk -v package=stream_chat_flutter '{printf "import '\''package:%s%s'\'';\n", package, $1}' >> $file - echo "" >> $file - echo "void main(){}" >> $file - cat $file - - name: Run tests - run: flutter test --coverage - - name: Codecov - run: bash <(curl -s https://codecov.io/bash) -c -t ${{ secrets.CODECOV_TOKEN }} -f coverage/lcov.info -F flutter_tool