Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for octopus observer #13

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions .github/workflows/checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,36 @@ name: Checkout

on:
workflow_dispatch:
push:
branches:
- "main"
- "master"
#- "dev"
#- "develop"
#- "feature/**"
#- "bugfix/**"
#- "hotfix/**"
#- "support/**"
paths:
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- .github/workflows/*.yml
- "pubspec.yaml"
- "example/pubspec.yaml"
#push:
# branches:
# - "master"
# - "develop"
# - "feature/**"
# - "bugfix/**"
# - "hotfix/**"
# - "support/**"
# paths:
# - ".github/workflows/*.yml"
# - "lib/pubspec.yaml"
# - "lib/**.dart"
# - "test/**.dart"
# - "example/**.dart"
pull_request:
branches:
- "main"
- "master"
- "dev"
- "develop"
- "feature/**"
- "bugfix/**"
- "hotfix/**"
- "support/**"
paths:
- "pubspec.yaml"
- "example/pubspec.yaml"
- ".github/workflows/*.yml"
- "lib/pubspec.yaml"
- "lib/**.dart"
- "test/**.dart"
- "example/**.dart"
- .github/workflows/*.yml
- "pubspec.yaml"
- "example/pubspec.yaml"

jobs:
checkout:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ build/
log.pana.json

# Test
coverage/
.coverage/
/test/**/*.json
/test/.test_coverage.dart
Expand Down
120 changes: 116 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,120 @@
.PHONY: help
SHELL :=/bin/bash -e -o pipefail
PWD := $(shell pwd)

.DEFAULT_GOAL := all
.PHONY: all
all: ## build pipeline
all: setup codegen format analyze test build

.PHONY: precommit
precommit: ## validate the branch before commit
precommit: all

# Script description and usage through `make` or `make help` commands
.PHONY: ci
ci: ## CI build pipeline
ci: analyze test

.PHONY: git-hooks
git-hooks: ## install git hooks
@git config --local core.hooksPath .githooks/

.PHONY: help
help:
@echo "Let's make something good"
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: setup
setup: ## setup environment
$(call print-target)
@fvm dart --disable-analytics
@fvm flutter config --no-analytics --enable-android --enable-web
@yes | fvm flutter doctor --android-licenses
@fvm flutter precache --universal --android --web
$(call get)

.PHONY: version
version: ## show current flutter version
$(call print-target)
@fvm flutter --version

-include tool/makefile/pub.mk tool/makefile/test.mk tool/makefile/setup.mk tool/makefile/deploy.mk
.PHONY: get
get: ## get dependencies
$(call print-target)
@fvm flutter pub get

.PHONY: upgrade
upgrade: get ## upgrade dependencies
$(call print-target)
@fvm flutter pub upgrade

.PHONY: outdated
outdated: ## check for outdated dependencies
$(call print-target)
@fvm flutter pub outdated

.PHONY: codegen
codegen: get ## run codegenerators
$(call print-target)
@fvm dart run build_runner build --delete-conflicting-outputs
$(call fix)

.PHONY: gen
gen: codegen

.PHONY: fix
fix: get ## format and fix code
$(call print-target)
@fvm dart format --fix -l 110 lib/ test/
@fvm dart fix --apply lib/
@fvm dart fix --apply test/

.PHONY: format
format: fix

.PHONY: fmt
fmt: fix

.PHONY: clean
clean: ## remove files created during build pipeline
$(call print-target)
@fvm flutter clean
@rm -rf .dart_tool build coverage .flutter-plugins .flutter-plugins-dependencies
$(call get)

.PHONY: analyze
analyze: get ## check source code for errors and warnings
$(call print-target)
@fvm dart format --set-exit-if-changed -l 110 -o none lib/ test/
@fvm flutter analyze --fatal-infos --fatal-warnings lib/ test/

.PHONY: check
check: analyze

.PHONY: lint
lint: analyze

.PHONY: test
test: ## run tests
$(call print-target)
@fvm flutter test --color --coverage --concurrency=50 --platform=tester --reporter=compact --timeout=30s

.PHONY: coverage
coverage: test ## generate coverage report
$(call print-target)
@lcov --list coverage/lcov.info

.PHONY: build
build: get ## build the application
$(call print-target)
@fvm flutter build web --web-renderer canvaskit --release --source-maps --base-href / --dart-define VERSION=0.0.0 --dart-define-from-file=.env.dev

.PHONY: diff
diff: ## git diff
$(call print-target)
@git diff --exit-code
@RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi

define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef
120 changes: 120 additions & 0 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
SHELL :=/bin/bash -e -o pipefail
PWD := $(shell pwd)

.DEFAULT_GOAL := all
.PHONY: all
all: ## build pipeline
all: setup codegen format analyze test build

.PHONY: precommit
precommit: ## validate the branch before commit
precommit: all

.PHONY: ci
ci: ## CI build pipeline
ci: analyze test

.PHONY: git-hooks
git-hooks: ## install git hooks
@git config --local core.hooksPath .githooks/

.PHONY: help
help:
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: setup
setup: ## setup environment
$(call print-target)
@fvm dart --disable-analytics
@fvm flutter config --no-analytics --enable-android --enable-web
@yes | fvm flutter doctor --android-licenses
@fvm flutter precache --universal --android --web
$(call get)

.PHONY: version
version: ## show current flutter version
$(call print-target)
@fvm flutter --version

.PHONY: get
get: ## get dependencies
$(call print-target)
@fvm flutter pub get

.PHONY: upgrade
upgrade: get ## upgrade dependencies
$(call print-target)
@fvm flutter pub upgrade

.PHONY: outdated
outdated: ## check for outdated dependencies
$(call print-target)
@fvm flutter pub outdated

.PHONY: codegen
codegen: get ## run codegenerators
$(call print-target)
@fvm dart run build_runner build --delete-conflicting-outputs
$(call fix)

.PHONY: gen
gen: codegen

.PHONY: fix
fix: get ## format and fix code
$(call print-target)
@fvm dart format --fix -l 110 lib/ test/
@fvm dart fix --apply lib/
@fvm dart fix --apply test/

.PHONY: format
format: fix

.PHONY: fmt
fmt: fix

.PHONY: clean
clean: ## remove files created during build pipeline
$(call print-target)
@fvm flutter clean
@rm -rf .dart_tool build coverage .flutter-plugins .flutter-plugins-dependencies
$(call get)

.PHONY: analyze
analyze: get ## check source code for errors and warnings
$(call print-target)
@fvm dart format --set-exit-if-changed -l 110 -o none lib/ test/
@fvm flutter analyze --fatal-infos --fatal-warnings lib/ test/

.PHONY: check
check: analyze

.PHONY: lint
lint: analyze

.PHONY: test
test: ## run tests
$(call print-target)
@fvm flutter test --color --coverage --concurrency=50 --platform=tester --reporter=compact --timeout=30s

.PHONY: coverage
coverage: test ## generate coverage report
$(call print-target)
@lcov --list coverage/lcov.info

.PHONY: build
build: get ## build the application
$(call print-target)
@fvm flutter build web --web-renderer canvaskit --release --source-maps --base-href / --dart-define VERSION=0.0.0 --dart-define-from-file=.env.dev

.PHONY: diff
diff: ## git diff
$(call print-target)
@git diff --exit-code
@RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi

define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef
11 changes: 9 additions & 2 deletions test/octopus_test.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// ignore_for_file: unnecessary_lambdas

import 'package:flutter_test/flutter_test.dart';

import 'src/hash_test.dart' as hash_test;
import 'src/state_test.dart' as state_test;
import 'src/unit/hash_test.dart' as hash_test;
import 'src/unit/state_test.dart' as state_test;
import 'src/widget/observer_test.dart' as observer_test;

void main() {
group('unit', () {
state_test.main();
hash_test.main();
});

group('widget', () {
observer_test.main();
});
}
File renamed without changes.
File renamed without changes.
Loading
Loading