Skip to content

Commit

Permalink
fixes for pip-build, lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Jan 17, 2024
1 parent db436ca commit 1592dfd
Show file tree
Hide file tree
Showing 60 changed files with 180 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:

- name: Install dependencies
run: |
pip install -r requirements_lint.txt
pip install -r requirements.txt
pip install -r requirements_lint.txt >/dev/null
pip install -r requirements.txt >/dev/null
shell: bash

- name: Running PyLint
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@ jobs:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements_build.txt
run: pip install -r requirements_build.txt >/dev/null
shell: bash

- name: Extract tag name
id: version
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3 | cut -c 2-)

- name: Update version in setup.py
run: >-
sed -i 's/version=.*/version="${{ steps.version.outputs.TAG_NAME }}",/g' setup.py
sed -i 's/VERSION =.*/VERSION = "${{ steps.version.outputs.TAG_NAME }}"/g' ansible-webui/aw/config/hardcoded.py
- name: Building
run: python3 -m build
run: |
echo "${{ steps.version.outputs.TAG_NAME }}" > VERSION
python3 -m build
shell: bash

- name: Publish to PyPI
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:

- name: Install dependencies
run: |
pip install -r requirements_test.txt
pip install -r requirements_build.txt
pip install -r requirements.txt
pip install -r requirements_test.txt >/dev/null
pip install -r requirements_build.txt >/dev/null
pip install -r requirements.txt >/dev/null
shell: bash

- name: Testing DB migrations for errors & warnings
Expand All @@ -46,12 +46,12 @@ jobs:
m2=$(python3 manage.py migrate 2>&1)
if echo "$m2" | grep -q 'WARNING'; then exit 1;fi
shell: bash
working-directory: ansible-webui/
working-directory: src/ansible-webui/

- name: Testing to start Ansible-WebUI
run: |
set +e
timeout 2 python3 ansible-webui
timeout 2 python3 src/ansible-webui
ec="$?"
if [[ "$ec" != "124" ]]
then
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ venv/
ansible_webui.egg-info/
__pychache__.py
**/aw.db
**/aw.dev.db
**/aw.dev.db
VERSION
14 changes: 11 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[MASTER]
init-hook='import sys; sys.path.append("src/ansible-webui/")'

[MAIN]

# Analyse import fallback blocks. This can be used to support both Python 2 and
Expand Down Expand Up @@ -52,7 +55,8 @@ ignore=CVS
# ignore-list. The regex matches against paths and can be in Posix or Windows
# format. Because '\\' represents the directory delimiter on Windows systems,
# it can't be used as an escape character.
ignore-paths=venv/*
ignore-paths=venv/*,
src/ansible-webui/aw/migrations/*

# Files or directories matching the regular expression patterns are skipped.
# The regex matches against base names, not paths. The default value ignores
Expand Down Expand Up @@ -279,16 +283,17 @@ valid-metaclass-classmethod-first-arg=mcs
# List of regular expressions of class ancestor names to ignore when counting
# public methods (see R0903)
exclude-too-few-public-methods=
# todo: exclude models

# List of qualified class names to ignore when counting class parents (see
# R0901)
ignored-parents=

# Maximum number of arguments for function / method.
max-args=5
max-args=7

# Maximum number of attributes for a class (see R0902).
max-attributes=7
max-attributes=10

# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
Expand Down Expand Up @@ -424,6 +429,9 @@ confidence=HIGH,
disable=C0114, C0115, C0116, # no inline docs
C0103, # var-naming..
W0511, # todo comments
W0707, # has reasons
R0903, # todo: exclude models
E0401

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
20 changes: 0 additions & 20 deletions ansible-webui/aw/permission.py

This file was deleted.

56 changes: 0 additions & 56 deletions ansible-webui/main.py

This file was deleted.

31 changes: 29 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
[build-system]
requires = ['setuptools>=42']
build-backend = 'setuptools.build_meta'
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "ansible-webui"
authors = [
{name = "AnsibleGuy", email = "[email protected]"},
]
description = "Basic WebUI for using Ansible"
readme = "README.md"
requires-python = ">=3.5"
keywords = ["ansible", "webui", "automation", "iac"]
license = {file = "LICENSE.txt"}
classifiers = [
'Programming Language :: Python :: 3',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Framework :: Django',
]
dynamic = ["dependencies", "version"]

[project.urls]
Homepage = "https://github.com/ansibleguy/ansible-webui"
Documentation = "https://ansible-webui.readthedocs.io/"
Repository = "https://github.com/ansibleguy/ansible-webui.git"
Issues = "https://github.com/ansibleguy/issues"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
version = {file = ["VERSION"]}
2 changes: 1 addition & 1 deletion scripts/migrate_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ then
git ls-files . --exclude-standard --others | grep 'migrations' | xargs --no-run-if-empty rm
fi

cd "$(pwd)/ansible-webui/"
cd "$(pwd)/src/ansible-webui/"

echo ''
echo 'Creating migrations'
Expand Down
3 changes: 3 additions & 0 deletions scripts/run_pip_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ echo ''
echo 'Building & Installing Module using PIP'
echo ''

bash ./scripts/update_version.sh

python3 -m pip install -e "$path_repo" >/dev/null

echo ''
echo 'Starting app'
echo ''

cd /tmp
python3 -m ansible-webui

echo ''
Expand Down
11 changes: 8 additions & 3 deletions scripts/run_shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function log() {
}

cd "$(pwd)/.."
TEST_DB="$(pwd)/ansible-webui/aw.${AW_ENV}.db"
TEST_DB="$(pwd)/src/ansible-webui/aw.${AW_ENV}.db"
TEST_MIGRATE=''

if [ -f "$TEST_DB" ] && [[ "$TEST_QUIET" != "1" ]]
Expand Down Expand Up @@ -38,11 +38,16 @@ then
python3 -m pip install --upgrade -r ../requirements.txt >/dev/null
fi

log 'SETTING VERSION'
bash ./scripts/update_version.sh
version="$(cat './VERSION')"
export AW_VERSION="$version"

log 'INITIALIZING DATABASE SCHEMA'
bash ./scripts/migrate_db.sh "$TEST_MIGRATE"

log 'CREATING USERS'
python3 ansible-webui/manage.py createsuperuser --noinput || true
python3 ./src/ansible-webui/manage.py createsuperuser --noinput || true

log 'STARTING APP'
python3 ansible-webui
python3 ./src/ansible-webui
9 changes: 9 additions & 0 deletions scripts/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

#last_tag="$(git describe --exact-match --abbrev=0)"
last_tag="0.0.1"
echo "${last_tag}.dev" > "$(dirname "$0")/../VERSION"
29 changes: 0 additions & 29 deletions setup.py

This file was deleted.

File renamed without changes.
3 changes: 2 additions & 1 deletion ansible-webui/__main__.py → src/ansible-webui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
sys_path.append(os_path.dirname(os_path.abspath(__file__)))
from main import main

from aw.config.hardcoded import VERSION
from aw.config.main import VERSION

if len(sys_argv) > 1:
if sys_argv[1] == 'version':
print(VERSION)
sys_exit(0)

print(f'Ansible-WebUI Version {VERSION}')
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
VERSION = "0.0.1"

ENV_KEY_DEPLOYMENT = 'AW_ENV'
ENV_KEY_SERVE_STATIC = 'AW_STATIC'
ENV_KEY_DB = 'AW_DB'
Expand All @@ -11,9 +9,3 @@
LOGOUT_PATH = '/o/'
LOG_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z'
RUNNER_TMP_DIR_TIME_FORMAT = '%Y-%m-%d_%H-%M-%S'

PERMISSIONS = dict(
access='AW_ACCESS',
write='AW_WRITE',
exec='AW_EXEC',
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from os import environ
from importlib.metadata import version

from pytz import all_timezones

from aw.config.environment import ENVIRON_FALLBACK


VERSION = environ['AW_VERSION'] if 'AW_VERSION' in environ else version('ansible-webui')


def init_globals():
# pylint: disable=W0601
global config
config = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
'login': False,
},
'LO': {
'element': '<i class="fas fa-sign-out-alt fa-2x aw-nav-right-icon aw-nav-right-icon-logout" title="Logout"></i>',
'element': '<i class="fas fa-sign-out-alt fa-2x aw-nav-right-icon aw-nav-right-icon-logout" '
'title="Logout"></i>',
'url': LOGOUT_PATH,
'login': True,
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _runner_options(job: Job, execution: JobExecution) -> dict:
}


def runner_prep(job: Job, execution: (JobExecution, None)):
def runner_prep(job: Job, execution: (JobExecution, None)) -> dict:
if execution is None:
execution = JobExecution(user=None, job=job, comment='Scheduled')

Expand Down Expand Up @@ -106,6 +106,8 @@ def runner_prep(job: Job, execution: (JobExecution, None)):

_update_execution_status(execution, status='Running')

return opts


def runner_cleanup(opts: dict):
rmtree(opts['private_data_dir'])
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1592dfd

Please sign in to comment.