From 81fd66c62004d8b9b42714b929c754b92e33c574 Mon Sep 17 00:00:00 2001 From: Renan <6718144+renancaraujo@users.noreply.github.com> Date: Fri, 17 Sep 2021 11:04:11 +0100 Subject: [PATCH] update CI scripts (#468) --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ .github/workflows/test.yml | 19 ------------------- format.sh | 6 ------ scripts/format.sh | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml delete mode 100755 format.sh create mode 100755 scripts/format.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4a43f101 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + types: [opened, reopened, synchronize] + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install flutter + uses: subosito/flutter-action@v1 + with: + channel: stable + - name: Install packages + run: flutter pub get + - name: Check format + run: ./scripts/format.sh . + - name: Test + run: flutter test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 9ef0b88b..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Test - -on: push - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-java@v1 - with: - java-version: '12.x' - - uses: subosito/flutter-action@v1 - with: - channel: 'stable' - - run: flutter pub get - - run: ./format.sh - - run: flutter test diff --git a/format.sh b/format.sh deleted file mode 100755 index d6703875..00000000 --- a/format.sh +++ /dev/null @@ -1,6 +0,0 @@ -if [[ $(flutter format -n .) ]]; then - echo "files not formatted" - exit 1 -else - exit 0 -fi \ No newline at end of file diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 00000000..17bef9ea --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +function run_format() { + output=$(flutter format --set-exit-if-changed -n .) + if [ $? -eq 1 ]; then + echo "flutter format issues on" + echo $output + exit 1 + fi +} + +cd $1 || exit + +run_format