Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Boram Bae <[email protected]>
  • Loading branch information
bbrto21 committed Sep 13, 2021
1 parent f691594 commit 73a0e45
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -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^)
38 changes: 38 additions & 0 deletions tools/commands/analyze_plugins.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 10 additions & 1 deletion tools/run_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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():
Expand Down

0 comments on commit 73a0e45

Please sign in to comment.