From 3a37802f4d805710bf9b3dbb15f606e1eadab97e Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Mon, 3 May 2021 16:55:51 -0500 Subject: [PATCH] Setup some github actions (#37) --- .github/workflows/flutterfmt.sh | 10 ++++++++++ .github/workflows/flutterfmt.yml | 27 +++++++++++++++++++++++++ .github/workflows/gofmt.sh | 14 +++++++++++++ .github/workflows/gofmt.yml | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100755 .github/workflows/flutterfmt.sh create mode 100644 .github/workflows/flutterfmt.yml create mode 100755 .github/workflows/gofmt.sh create mode 100644 .github/workflows/gofmt.yml diff --git a/.github/workflows/flutterfmt.sh b/.github/workflows/flutterfmt.sh new file mode 100755 index 0000000..5dfddc8 --- /dev/null +++ b/.github/workflows/flutterfmt.sh @@ -0,0 +1,10 @@ +#!/bin/sh +DIRS="lib test" +EXIT=0 + +for DIR in $DIRS; do + OUT="$(flutter format -l 120 --suppress-analytics "$DIR" | sed -e "s/^Formatted \(.*\)/::error file=$DIR\/\1::Not formatted/g")" + echo "$OUT" | grep "::error" && EXIT=1 +done + +exit $EXIT \ No newline at end of file diff --git a/.github/workflows/flutterfmt.yml b/.github/workflows/flutterfmt.yml new file mode 100644 index 0000000..f7d9229 --- /dev/null +++ b/.github/workflows/flutterfmt.yml @@ -0,0 +1,27 @@ +name: Flutter format +on: + push: + branches: + - main + pull_request: + paths: + - '.github/workflows/flutterfmt.yml' + - '.github/workflows/flutterfmt.sh' + - '**.dart' +jobs: + + gofmt: + name: Run flutter format + runs-on: ubuntu-latest + steps: + + - name: Install flutter + uses: subosito/flutter-action@v1 + with: + flutter-version: '2.0.5' + + - name: Check out code + uses: actions/checkout@v2 + + - name: flutter format + run: $GITHUB_WORKSPACE/.github/workflows/flutterfmt.sh diff --git a/.github/workflows/gofmt.sh b/.github/workflows/gofmt.sh new file mode 100755 index 0000000..98532ba --- /dev/null +++ b/.github/workflows/gofmt.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -z "$1" ]; then + rm -f ./gofmterr + find . -iname '*.go' ! -name '*.pb.go' -exec "$0" {} \; + [ -f ./gofmterr ] && exit 1 + exit 0 +fi + +OUT="$(./nebula/goimports -d "$1" | awk '{printf "%s%%0A",$0}')" +if [ -n "$OUT" ]; then + echo "::error file=$1::$OUT" + touch ./gofmterr +fi \ No newline at end of file diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml new file mode 100644 index 0000000..a17ee0d --- /dev/null +++ b/.github/workflows/gofmt.yml @@ -0,0 +1,34 @@ +name: gofmt +on: + push: + branches: + - main + pull_request: + paths: + - '.github/workflows/gofmt.yml' + - '.github/workflows/gofmt.sh' + - '**.go' +jobs: + + gofmt: + name: Run gofmt + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.16 + uses: actions/setup-go@v2 + with: + go-version: 1.16 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Install goimports + working-directory: nebula + run: | + go get golang.org/x/tools/cmd/goimports + go build golang.org/x/tools/cmd/goimports + + - name: gofmt + run: $GITHUB_WORKSPACE/.github/workflows/gofmt.sh \ No newline at end of file