From 7755b9c8129f706937993ce835c60cfd5ca42992 Mon Sep 17 00:00:00 2001 From: konrad Date: Mon, 15 Oct 2018 17:16:47 +0000 Subject: [PATCH] Added formatting check to makefile and ci (#17) --- .drone.yml | 23 ++++++++++++----------- Makefile | 23 +++++++++++++++++++---- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.drone.yml b/.drone.yml index a504da8..a1b2801 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,6 +8,18 @@ clone: tags: true pipeline: + build: + image: nathansamson/flutter-builder-docker:v0.6.0 + pull: true + commands: + - flutter packages get + - make format-check + - make build-all + - mkdir apks + - mv build/app/outputs/apk/*/*/*.apk apks + when: + event: [ push, tag ] + test: image: nathansamson/flutter-builder-docker:v0.6.0 pull: true @@ -16,17 +28,6 @@ pipeline: when: event: [ push, tag, pull_request ] - build: - image: nathansamson/flutter-builder-docker:v0.6.0 - pull: true - commands: - - flutter packages get - - make build-all - - mkdir apks - - mv build/app/outputs/apk/*/*/*.apk apks - when: - event: [ push, tag ] - # Push the releases to our pseudo-s3-bucket release: image: plugins/s3:1 diff --git a/Makefile b/Makefile index b14bbd2..36134c0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ GIT_LAST_COMMIT := $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') +FLUTTER ?= flutter ifneq ($(DRONE_TAG),) VERSION ?= $(subst v,,$(DRONE_TAG))-$(GIT_LAST_COMMIT) @@ -12,19 +13,33 @@ endif .PHONY: test test: - flutter test + $(FLUTTER) test .PHONY: build-all build-all: build-release build-debug build-profile .PHONY: build-release build-release: - flutter build apk --release --build-name=$(VERSION) --flavor main + $(FLUTTER) build apk --release --build-name=$(VERSION) --flavor main .PHONY: build-debug build-debug: - flutter build apk --debug --build-name=$(VERSION) --flavor unsigned + $(FLUTTER) build apk --debug --build-name=$(VERSION) --flavor unsigned .PHONY: build-profile build-profile: - flutter build apk --profile --build-name=$(VERSION) --flavor unsigned + $(FLUTTER) build apk --profile --build-name=$(VERSION) --flavor unsigned + +.PHONY: format +format: + $(FLUTTER) format lib + +.PHONY: format-check +format-check: + @diff=$$(flutter format -n lib); \ + if [ -n "$$diff" ]; then \ + echo "The following files are not formatted correctly:"; \ + echo "$${diff}"; \ + echo "Please run 'make format' and commit the result."; \ + exit 1; \ + fi; \ No newline at end of file