Skip to content

Commit

Permalink
Merge pull request #555 from JrGoodle/symlink-source-warning
Browse files Browse the repository at this point in the history
Relax rules for when command can run
  • Loading branch information
JrGoodle committed May 31, 2020
2 parents 1c89c39 + c3cf192 commit e883187
Show file tree
Hide file tree
Showing 39 changed files with 1,988 additions and 377 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci-cats-clowder-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'CI - cats clowder repo configurations'

on:
push:
branches:
- master
paths-ignore:
- 'docs/**'
pull_request:
branches:
- master
paths-ignore:
- 'docs/**'

defaults:
run:
shell: bash

jobs:
cats_clowder_repo:
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
CLOWDER_DEBUG: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest] # TODO: windows-latest
python-version: ['3.6', '3.7', '3.8']
exclude:
- os: macos-latest
python-version: '3.6'
- os: macos-latest
python-version: '3.8'
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup git config
run:
git config --global user.email "joe@polka.cat";
git config --global user.name "GitHub Actions Workflow"
- name: Install clowder requirements
run: pip3 install -r src/requirements.txt
- name: CI before script
run: script/ci_before
- name: Install clowder
run: script/update
- name: Install clowder test
run: script/test
- name: Test commands for various clowder repo and clowder yaml configurations
run: clowder-test -c cats clowder-repo
- name: CI after script
run: script/ci_after
19 changes: 18 additions & 1 deletion clowder_test/clowder_test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# -*- coding: utf-8 -*-
"""clowder_test module __init__
.. codeauthor:: Joe Decapo <joe@polka.cat>
"""

import os
from pathlib import Path

ROOT_DIR = os.getcwd()
if 'CLOWDER_PROJECT_PATH' in os.environ:
ROOT_DIR = Path(os.environ['CLOWDER_PROJECT_PATH'])
else:
path = Path.cwd()
while str(path) != path.root:
clowder_test_dir = path / 'clowder_test'
if clowder_test_dir.is_dir():
ROOT_DIR = path
break
path = path.parent
6 changes: 6 additions & 0 deletions clowder_test/clowder_test/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
"""clowder_test cli module __init__
.. codeauthor:: Joe Decapo <joe@polka.cat>
"""
28 changes: 10 additions & 18 deletions clowder_test/clowder_test/cli/base_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"""

import os

from cement.ext.ext_argparse import ArgparseController, expose

from clowder_test.execute import execute_test_command
Expand All @@ -19,7 +17,7 @@
class BaseController(ArgparseController):
"""Clowder app base controller"""

path = os.path.join(ROOT_DIR, 'test', 'scripts')
path = ROOT_DIR / 'test' / 'scripts'

class Meta:
"""Clowder app base Meta configuration"""
Expand Down Expand Up @@ -50,8 +48,7 @@ def all(self) -> None:
parallel=self.app.pargs.parallel,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)

self.offline()
self.parallel()
Expand All @@ -66,21 +63,19 @@ def config_yaml_validation(self) -> None:
parallel=True,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)

@expose(
help='Run offline tests'
)
def offline(self) -> None:
"""clowder offline tests"""

execute_test_command('./offline.sh', os.path.join(self.path, 'cats'),
execute_test_command('./offline.sh', self.path / 'cats',
parallel=self.app.pargs.parallel,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)

@expose(
help='Run parallel tests'
Expand All @@ -92,8 +87,7 @@ def parallel(self) -> None:
parallel=True,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)

# @expose(
# help='Run unit tests'
Expand All @@ -117,21 +111,19 @@ def write(self) -> None:

cats_scripts = ['./write_herd.sh', './write_prune.sh', './write_repo.sh', './write_start.sh']
for script in cats_scripts:
execute_test_command(script, os.path.join(self.path, 'cats'),
execute_test_command(script, self.path / 'cats',
parallel=self.app.pargs.parallel,
write=True,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)

misc_scripts = ['./write_forks.sh']
for script in misc_scripts:
execute_test_command(script, os.path.join(self.path, 'misc'),
execute_test_command(script, self.path / 'misc',
parallel=self.app.pargs.parallel,
write=True,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)

# execute_test_command('./write_configure_remotes.sh', os.path.join(self.path, 'swift'),
# parallel=self.app.pargs.parallel,
Expand Down
21 changes: 14 additions & 7 deletions clowder_test/clowder_test/cli/cats_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import os
from pathlib import Path

from cement.ext.ext_argparse import ArgparseController, expose

Expand All @@ -16,7 +16,7 @@
class CatsController(ArgparseController):
"""Clowder test command cats controller"""

path = os.path.join(ROOT_DIR, 'test', 'scripts', 'cats')
path = ROOT_DIR / 'test' / 'scripts' / 'cats'

class Meta:
"""Clowder test cats Meta configuration"""
Expand All @@ -32,7 +32,7 @@ class Meta:
def all(self) -> None:
"""clowder cats tests"""

self._execute_command('./test_example_cats.sh', os.path.join(ROOT_DIR, 'test', 'scripts'))
self._execute_command('./test_example_cats.sh', ROOT_DIR / 'test' / 'scripts')

@expose(
help='Run cats branch tests'
Expand All @@ -58,6 +58,14 @@ def clean(self) -> None:

self._execute_command('./clean.sh', self.path)

@expose(
help='Run cats clowder-repo tests'
)
def clowder_repo(self) -> None:
"""clowder cats clowder-repo tests"""

self._execute_command('./clowder-repo.sh', self.path)

@expose(
help='Run cats config tests'
)
Expand Down Expand Up @@ -242,16 +250,15 @@ def yaml_validation(self) -> None:

self._execute_command('./yaml_validation.sh', self.path)

def _execute_command(self, command: str, path: str) -> None:
def _execute_command(self, command: str, path: Path) -> None:
"""Private execute command
:param str command: Command to run
:param str path: Path to set as ``cwd``
:param Path path: Path to set as ``cwd``
"""

execute_test_command(command, path,
parallel=self.app.pargs.parallel,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)
13 changes: 6 additions & 7 deletions clowder_test/clowder_test/cli/misc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import os
from pathlib import Path

from cement.ext.ext_argparse import ArgparseController, expose

Expand All @@ -16,7 +16,7 @@
class MiscController(ArgparseController):
"""Clowder test command misc controller"""

path = os.path.join(ROOT_DIR, 'test', 'scripts', 'misc')
path = ROOT_DIR / 'test' / 'scripts' / 'misc'

class Meta:
"""Clowder test misc Meta configuration"""
Expand All @@ -32,7 +32,7 @@ class Meta:
def all(self) -> None:
"""clowder misc tests"""

self._execute_command('./test_example_misc.sh', os.path.join(ROOT_DIR, 'test', 'scripts'))
self._execute_command('./test_example_misc.sh', ROOT_DIR / 'test' / 'scripts')

@expose(
help='Run misc forks tests'
Expand All @@ -50,16 +50,15 @@ def sources(self) -> None:

self._execute_command('./sources.sh', self.path)

def _execute_command(self, command: str, path: str) -> None:
def _execute_command(self, command: str, path: Path) -> None:
"""Private execute command
:param str command: Command to run
:param str path: Path to set as ``cwd``
:param Path path: Path to set as ``cwd``
"""

execute_test_command(command, path,
parallel=self.app.pargs.parallel,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)
13 changes: 6 additions & 7 deletions clowder_test/clowder_test/cli/swift_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import os
from pathlib import Path

from cement.ext.ext_argparse import ArgparseController, expose

Expand All @@ -16,7 +16,7 @@
class SwiftController(ArgparseController):
"""Clowder test command swift controller"""

path = os.path.join(ROOT_DIR, 'test', 'scripts', 'swift')
path = ROOT_DIR / 'test' / 'scripts' / 'swift'

class Meta:
"""Clowder test swift Meta configuration"""
Expand All @@ -32,7 +32,7 @@ class Meta:
def all(self) -> None:
"""clowder swift tests"""

self._execute_command('./test_example_swift.sh', os.path.join(ROOT_DIR, 'test', 'scripts'))
self._execute_command('./test_example_swift.sh', ROOT_DIR / 'test' / 'scripts')

@expose(
help='Run swift config versions tests'
Expand All @@ -58,16 +58,15 @@ def reset(self) -> None:

self._execute_command('./reset.sh', self.path)

def _execute_command(self, command: str, path: str) -> None:
def _execute_command(self, command: str, path: Path) -> None:
"""Private execute command
:param str command: Command to run
:param str path: Path to set as ``cwd``
:param Path path: Path to set as ``cwd``
"""

execute_test_command(command, path,
parallel=self.app.pargs.parallel,
write=self.app.pargs.write,
coverage=self.app.pargs.coverage,
debug=self.app.debug,
quiet=self.app.pargs.silent)
debug=self.app.debug)
19 changes: 15 additions & 4 deletions clowder_test/clowder_test/clowder_test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import os
from subprocess import CalledProcessError

import colorama
from cement import App
Expand All @@ -19,7 +19,7 @@


def post_argument_parsing_hook(app): # noqa
execute_command('./setup_local_test_directory.sh', os.path.join(ROOT_DIR, 'test', 'scripts'))
execute_command('./setup_local_test_directory.sh', ROOT_DIR / 'test' / 'scripts')


class ClowderTestApp(App):
Expand All @@ -45,8 +45,19 @@ def main():
"""Clowder command CLI main function"""

print()
with ClowderTestApp() as app:
app.run()
try:
with ClowderTestApp() as app:
app.run()
except CalledProcessError as err:
print('CLOWDER_TEST: CalledProcessError')
print(f"CLOWDER_TEST: {err}")
print()
exit(err.returncode)
except Exception as err:
print('CLOWDER_TEST: Exception')
print(f"CLOWDER_TEST: {err}")
print()
exit(1)


if __name__ == '__main__':
Expand Down

0 comments on commit e883187

Please sign in to comment.