From 73a0e45c5af48b54bde04dedd5ead81a8290fa30 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Mon, 13 Sep 2021 16:58:36 +0900 Subject: [PATCH] WIP Signed-off-by: Boram Bae --- .github/workflows/analyze.yml | 28 +++++++++++++++++++++++ tools/commands/analyze_plugins.py | 38 +++++++++++++++++++++++++++++++ tools/run_command.py | 11 ++++++++- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/analyze.yml create mode 100644 tools/commands/analyze_plugins.py diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml new file mode 100644 index 000000000..2f115bf04 --- /dev/null +++ b/.github/workflows/analyze.yml @@ -0,0 +1,28 @@ +name: Analyze + +on: [push, pull_request] + +jobs: + dart: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - name: Find changed packages + run: | + CHANGED_PACKAGES=$(python3 tools/run_command.py plugins --run-on-changed-packages --base-sha $(git rev-parse HEAD^)) + if [[ ! -z $CHANGED_PACKAGES ]]; then + echo $CHANGED_PACKAGES + echo "HAS_CHANGED_PACKAGES=true" >> "$GITHUB_ENV" + fi + - name: Install flutter-tizen + if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }} + run: | + git clone https://github.com/flutter-tizen/flutter-tizen.git + - name: Analyze changed packages + if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }} + run: | + ROOT_DIR=`pwd` + export PATH=$PATH:`pwd`/flutter-tizen/bin + python3 tools/run_command.py analyze --run-on-changed-packages --base-sha $(git rev-parse HEAD^) diff --git a/tools/commands/analyze_plugins.py b/tools/commands/analyze_plugins.py new file mode 100644 index 000000000..afb419905 --- /dev/null +++ b/tools/commands/analyze_plugins.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import subprocess +import sys +import os +import commands.command_utils as command_utils + + +def parse_args(args): + parser = command_utils.get_options_parser( + plugins=True, exclude=True, run_on_changed_packages=True, base_sha=True, command='analyze') + return parser.parse_args(args) + + +def _run_analyze_plugins(plugin): + subprocess.run('flutter-tizen pub get', shell=True, cwd=plugin) + completed_process = subprocess.run('flutter-tizen analyze', shell=True, cwd=plugin) + if completed_process.returncode == 0: + return True + else: + return False + + +def run_analyze_plugins(argv): + args = parse_args(argv) + packages_dir = command_utils.get_package_dir() + target_plugins, _ = command_utils.get_target_plugins( + packages_dir, plugins=args.plugins, exclude=args.exclude, run_on_changed_packages=args.run_on_changed_packages, + base_sha=args.base_sha) + results = [] + for plugin in target_plugins: + result = _run_analyze_plugins(os.path.join(packages_dir, plugin)) + results.append(result) + + if False not in results: + exit(0) + else: + exit(1) diff --git a/tools/run_command.py b/tools/run_command.py index c893268ca..c0e4c1b25 100755 --- a/tools/run_command.py +++ b/tools/run_command.py @@ -6,9 +6,11 @@ from commands import integration_test from commands import build_example from commands import print_plugins - +from commands import analyze_plugins # Check tidy + + def run_check_tidy(argv): check_tidy.run_check_tidy(argv) @@ -27,12 +29,19 @@ def run_build_examples(argv): def run_print_plugins(arv): print_plugins.run_print_plugins(arv) +# Analyze plugin packages + + +def run_analyze_plugins(arv): + analyze_plugins.run_analyze_plugins(arv) + commands = {} commands['tidy'] = {'func': run_check_tidy, 'info': 'Check and update format for C++ files'} commands['test'] = {'func': run_integration_test, 'info': 'Run integration test'} commands['build'] = {'func': run_build_examples, 'info': 'Build examples of plugin'} commands['plugins'] = {'func': run_print_plugins, 'info': 'Print plugins list'} +commands['analyze'] = {'func': run_analyze_plugins, 'info': 'Analyze plugins for Dart files'} def print_usage():