Setup some github actions (#37)
This commit is contained in:
parent
f3fab82e34
commit
3a37802f4d
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue