Compare commits

..

1 Commits
appium ... dev

Author SHA1 Message Date
Calcitem 40e6f0a026 ci: Merge some GitHub Action yml files
* Merge dart-analyze.yml to flutter.yml.
* When the dart analyze hook fails don't try to build the apk.
* Merge cui-on-xxx.yml to cui.yml and remove "Archive apk" comments.
2021-11-29 23:05:55 +08:00
21 changed files with 112 additions and 241 deletions

View File

@ -10,7 +10,7 @@ indent_size = 4
end_of_line = lf
insert_final_newline = true
[*.{dart,js}]
[*.dart]
indent_style = space
indent_size = 2
end_of_line = lf

View File

@ -7,7 +7,6 @@ andnetwork
APARTMENTTHREADED
APIENTRY
appbundle
appium
APSTUDIO
ARGB
argc

View File

@ -1,30 +0,0 @@
name: CUI on macOS
on:
push:
paths:
- 'src/*.cpp'
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Export environment valuables
run: export
- name: Print clang version
run: g++ -v
# Build
- name: Build CUI
run: cd src; make -j build ARCH=x86-64
# Archive apk
- name: Archive CUI
uses: actions/upload-artifact@v2
with:
name: sanmill-for-macos
path: src/sanmill

View File

@ -1,33 +0,0 @@
name: CUI on Ubuntu
on:
push:
paths:
- 'src/*.cpp'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Export environment valuables
run: export
- name: Print g++ version
run: g++ -v
- name: Create App version
run: git fetch --tags; git tag; git log -n1; bash -x ./version.sh
# Build
- name: Build CUI
run: cd src; make -j build ARCH=x86-64
# Archive apk
- name: Archive CUI
uses: actions/upload-artifact@v2
with:
name: sanmill-for-linux
path: src/sanmill

View File

@ -1,30 +0,0 @@
name: CUI on Windows
on:
push:
paths:
- 'src/*.cpp'
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up Cygwin
uses: egor-tensin/setup-cygwin@v3
with:
platform: x64
packages: make gcc-g++
# Build
- name: Build CUI
run: cd src; make -j build ARCH=x86-64
# Archive apk
- name: Archive CUI
uses: actions/upload-artifact@v2
with:
name: sanmill-for-cygwin
path: src/sanmill.exe

79
.github/workflows/cui.yml vendored Normal file
View File

@ -0,0 +1,79 @@
name: CUI
on:
push:
paths:
- 'src/*.cpp'
jobs:
cygwin-g++:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up Cygwin
uses: egor-tensin/setup-cygwin@v3
with:
platform: x64
packages: make gcc-g++
# Build
- name: Build with cygwin-g++
run: cd src; make -j build ARCH=x86-64
# Archive
- name: Archive
uses: actions/upload-artifact@v2
with:
name: sanmill_cygwin-g++.exe
path: src/sanmill.exe
linux-g++:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Export environment valuables
run: export
- name: Print g++ version
run: g++ -v
- name: Create version
run: git fetch --tags; git tag; git log -n1; bash -x ./version.sh
# Build
- name: Build with linux-g++
run: cd src; make -j build ARCH=x86-64
# Archive
- name: Archive
uses: actions/upload-artifact@v2
with:
name: sanmill_linux-g++
path: src/sanmill
darwin-g++:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Export environment valuables
run: export
- name: Print g++ version
run: g++ -v
# Build
- name: Build with darwin-g++
run: cd src; make -j build ARCH=x86-64
# Archive
- name: Archive
uses: actions/upload-artifact@v2
with:
name: sanmill_darwin-g++
path: src/sanmill

View File

@ -1,23 +0,0 @@
name: Dart Analyze
on:
push:
paths:
- 'src/ui/flutter_app/**'
jobs:
linter:
runs-on: ubuntu-latest
name: Lint flutter code
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Flutter
uses: subosito/flutter-action@v1
- run: bash -x ./flutter-init.sh
- run: cp -f ./src/ui/flutter_app/analysis_options.yaml ./
- name: Analyze Flutter
uses: ValentinVignal/action-dart-analyze@v0.11
with:
fail-on: 'format'
working-directory: src/ui/flutter_app

View File

@ -6,8 +6,25 @@ on:
- 'src/ui/flutter_app/**'
jobs:
linter:
runs-on: ubuntu-latest
name: Lint flutter code
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Flutter
uses: subosito/flutter-action@v1
- run: bash -x ./flutter-init.sh
- run: cp -f ./src/ui/flutter_app/analysis_options.yaml ./
- name: Analyze Flutter
uses: ValentinVignal/action-dart-analyze@v0.11
with:
fail-on: 'format'
working-directory: src/ui/flutter_app
build:
runs-on: ubuntu-latest
needs: linter
# Note that this workflow uses the latest stable version of the Dart SDK.
# Docker images for other release channels - like dev and beta - are also

View File

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Sanmill-monkey" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define monkey_test=true" />
<option name="filePath" value="$PROJECT_DIR$/src/ui/flutter_app/lib/main.dart" />
<method v="2" />
</configuration>
</component>

View File

@ -1,7 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Sanmill-test" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define test=true" />
<option name="filePath" value="$PROJECT_DIR$/src/ui/flutter_app/lib/main.dart" />
<method v="2" />
</configuration>
</component>

4
.vscode/launch.json vendored
View File

@ -30,14 +30,14 @@
]
},
{
"name": "Sanmill-test",
"name": "Sanmill-monkey",
"type": "dart",
"request": "launch",
"cwd": "src/ui/flutter_app",
"program": "lib/main.dart",
"args": [
"--dart-define",
"test=true"
"monkey_test=true"
]
},
{

View File

@ -2,7 +2,6 @@
"cSpell.words": [
"ALIGNAS",
"appbundle",
"Appium",
"APSTUDIO",
"ARGB",
"autobuild",
@ -127,8 +126,6 @@
"VERSIONINFO",
"VNNI",
"vsync",
"wdio",
"webdriverio",
"winbase",
"winres",
"winver",

View File

@ -73,7 +73,7 @@ Run `./flutter-init.sh` , copy `src/ui/flutter_app/android/key.properties.exampl
We use compile-time environment configs to enable specific parts of the code:
* `test` to prepare the app for Monkey and Appium testing. (References to external sites are going to be disabled.)
* `monkey_test` to prepare the app for monkey tests. (References to external sites are going to be disabled.)
* `dev_mode` to show the developer mode without needing to enable it first.
* `catcher` to control the use of catcher. (This is on by default and needs to be disabled when required.)

View File

@ -24,7 +24,6 @@ import 'package:double_back_to_close_app/double_back_to_close_app.dart';
import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:hive_flutter/hive_flutter.dart' show Box;
import 'package:path_provider/path_provider.dart';
import 'package:sanmill/generated/intl/l10n.dart';
@ -44,11 +43,7 @@ part 'package:sanmill/services/init_system_ui.dart';
Future<void> main() async {
debugPrint('Environment [catcher]: ${EnvironmentConfig.catcher}');
debugPrint('Environment [dev_mode]: ${EnvironmentConfig.devMode}');
debugPrint('Environment [test]: ${EnvironmentConfig.test}');
if (EnvironmentConfig.test) {
enableFlutterDriverExtension();
}
debugPrint('Environment [monkey_test]: ${EnvironmentConfig.monkeyTest}');
await LocalDatabaseService.initStorage();

View File

@ -993,7 +993,6 @@ class _GamePageState extends State<GamePage>
),
actions: <Widget>[
TextButton(
key: const Key('infoDialogOkButton'),
child:
Text(S.of(context).ok, style: AppTheme.moveHistoryTextStyle),
onPressed: () => Navigator.pop(context),
@ -1426,28 +1425,24 @@ class _GamePageState extends State<GamePage>
List<Widget> get toolbar {
final gameButton = ToolbarItem.icon(
key: const Key('gameButton'),
onPressed: onGameButtonPressed,
icon: const Icon(FluentIcons.table_simple_24_regular),
label: Text(S.of(context).game),
);
final optionsButton = ToolbarItem.icon(
key: const Key('optionsButton'),
onPressed: onOptionButtonPressed,
icon: const Icon(FluentIcons.settings_24_regular),
label: Text(S.of(context).options),
);
final moveButton = ToolbarItem.icon(
key: const Key('moveButton'),
onPressed: onMoveButtonPressed,
icon: const Icon(FluentIcons.calendar_agenda_24_regular),
label: Text(S.of(context).move_number(0)),
);
final infoButton = ToolbarItem.icon(
key: const Key('infoButton'),
onPressed: onInfoButtonPressed,
icon: const Icon(FluentIcons.book_information_24_regular),
label: Text(S.of(context).info),

View File

@ -22,13 +22,13 @@
class EnvironmentConfig {
const EnvironmentConfig._();
/// Gets whether we build for Monkey/Appium testing
static const test = bool.fromEnvironment('test');
/// gets weather we build for a monkey test
static const monkeyTest = bool.fromEnvironment('monkey_test');
/// Gets whether we build for devMode
/// gets weather we build for devMode
static const devMode = bool.fromEnvironment('dev_mode');
/// Gets whether we want catcher to be enabled
/// gets weather we want catcher to be enabled
/// defaults to true
static const catcher = bool.fromEnvironment('catcher', defaultValue: true);
}

View File

@ -45,9 +45,6 @@ dependencies:
dev_dependencies:
build_runner: ^2.1.5
copy_with_extension_gen: ^2.0.3
flutter_driver:
sdk: flutter
flutter_gen_runner: ^4.1.2
flutter_test:
sdk: flutter
@ -58,7 +55,6 @@ dev_dependencies:
lint: ^1.7.2
msix: ^2.6.2
source_gen: ^1.1.1
test: any
flutter_gen:
output: lib/generated/assets/

View File

@ -1 +0,0 @@
/package-lock.json

View File

@ -1,49 +0,0 @@
# How to Test
## Environment configuration
### Install Node.js
Download and install [Node.js](https://nodejs.org).
### Install the dependencies
```shell
npm install -g appium
npm install -g appium-flutter-driver
npm install -g appium-flutter-finder
npm install -g cjs
npm install -g wd
npm install -g webdriverio
```
## Test
### Run Appium server
```shell
appium --base-path /
```
### Build debug apk
```shell
cd src/ui/flutter_app
flutter build apk --debug -v
```
### Start testing
```shell
cd tests/appium
npm start
```
### Known issues
You need to modify app's path in the test.js.
## Reference
[Getting Started - Appium](http://appium.io/docs/en/about-appium/getting-started)
[GitHub - appium-flutter-driver](https://github.com/appium-userland/appium-flutter-driver)

View File

@ -1,20 +0,0 @@
{
"dependencies": {
"appium-flutter-finder": "^0.1.0",
"cjs": "^0.0.11",
"webdriverio": "^7.16.10"
},
"name": "appium",
"description": "https://nodejs.org/en/",
"version": "1.0.0",
"main": "test.js",
"scripts": {
"start": "node test.js",
"ios": "APPIUM_OS=ios npm start",
"android": "APPIUM_OS=android npm start",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Calcitem <calcitem@outlook.com>",
"license": "GPLv3"
}

View File

@ -1,21 +0,0 @@
const wdio = require('webdriverio');
const assert = require('assert');
const find = require('appium-flutter-finder');
const { compileFunction } = require('vm');
const opts = {
port: 4723,
capabilities: {
deviceName: "PIXEL 5",
platformName: "Android",
platformVersion: "12",
app: "D:\\repos\\Sanmill\\src\\ui\\flutter_app\\build\\app\\outputs\\flutter-apk\\app-debug.apk",
automationName: "Flutter"
}
};
(async () => {
const driver = await wdio.remote(opts);
await driver.elementClick(find.byValueKey('infoButton'));
await driver.elementClick(find.byValueKey('infoDialogOkButton'));
})();