Skip to content

Commit

Permalink
Merge pull request frappe#1337 from gavindsouza/ci-fixes-2022-001
Browse files Browse the repository at this point in the history
build: pyproject.toml > setup.py + requirements.txt
  • Loading branch information
gavindsouza committed Jul 28, 2022
2 parents e66fe9c + 203f41e commit 60569ba
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 86 deletions.
38 changes: 13 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ sudo: true
git:
depth: 1

cache:
- pip
- npm
- yarn

addons:
mariadb: '10.3'

Expand All @@ -30,18 +25,18 @@ matrix:
env: TEST=bench
script: python bench/tests/test_init.py TestBenchInit.basic

- name: "Python 3.7 Production Setup"
python: 3.7
- name: "Python 3.10 Basic Setup"
python: "3.10"
env: TEST=bench
script: python bench/tests/test_setup_production.py TestSetupProduction.production
script: python bench/tests/test_init.py TestBenchInit.basic

- name: "Python 3.8 Production Setup"
python: 3.8
- name: "Python 3.7 Production Setup"
python: 3.7
env: TEST=bench
script: python bench/tests/test_setup_production.py TestSetupProduction.production

- name: "Python 3.9 Production Setup"
python: 3.9
- name: "Python 3.10 Production Setup"
python: "3.10"
env: TEST=bench
script: python bench/tests/test_setup_production.py TestSetupProduction.production

Expand All @@ -50,31 +45,24 @@ matrix:
env: TEST=bench
script: python -m unittest -v bench.tests.test_utils && python -m unittest -v bench.tests.test_init

- name: "Python 3.8 Tests"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_utils && python -m unittest -v bench.tests.test_init

- name: "Python 3.9 Tests"
python: 3.9
- name: "Python 3.10 Tests"
python: "3.10"
env: TEST=bench
script: python -m unittest -v bench.tests.test_utils && python -m unittest -v bench.tests.test_init

install:
- pip3 install urllib3 pyOpenSSL ndg-httpsclient pyasn1
- python -m pip install -U --no-cache-dir --force-reinstall urllib3 pyOpenSSL ndg-httpsclient pyasn1 wheel setuptools pip

- if [ $TEST == "bench" ];then
wget -q -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz;
tar -xf /tmp/wkhtmltox.tar.xz -C /tmp;
sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf;
sudo chmod o+x /usr/local/bin/wkhtmltopdf;
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb;
sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb;

nvm install 14;
nvm use 14;

mkdir -p ~/.bench;
cp -r $TRAVIS_BUILD_DIR/* ~/.bench;
pip3 install -q -U -e ~/.bench;
python -m pip install -U -e ~/.bench;

mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'";
mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'";
Expand Down
9 changes: 4 additions & 5 deletions bench/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

FRAPPE_BRANCH = "version-12"
if PYTHON_VER.major == 3:
if PYTHON_VER.minor in [6, 7]:
FRAPPE_BRANCH = "version-13"
else:
if PYTHON_VER.minor >= 10:
FRAPPE_BRANCH = "develop"
if 7 >= PYTHON_VER.minor >= 9:
FRAPPE_BRANCH = "version-13"


class TestBenchBase(unittest.TestCase):
Expand Down Expand Up @@ -134,5 +134,4 @@ def file_exists(self, path):
def get_traceback(self):
exc_type, exc_value, exc_tb = sys.exc_info()
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
body = "".join(str(t) for t in trace_list)
return body
return "".join(str(t) for t in trace_list)
5 changes: 3 additions & 2 deletions bench/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_get_app(self):
).decode("utf8")
self.assertTrue(app_installed_in_env)

@unittest.skipIf(FRAPPE_BRANCH != "develop", "only for develop branch")
def test_get_app_resolve_deps(self):
FRAPPE_APP = "healthcare"
self.init_bench("test-bench")
Expand Down Expand Up @@ -184,15 +185,15 @@ def test_switch_to_branch(self):
successful_switch = not exec_cmd(
f"bench switch-to-branch {prevoius_branch} frappe --upgrade", cwd=bench_path
)
app_branch_after_switch = str(git.Repo(path=app_path).active_branch)
if successful_switch:
app_branch_after_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual(prevoius_branch, app_branch_after_switch)

successful_switch = not exec_cmd(
f"bench switch-to-branch {FRAPPE_BRANCH} frappe --upgrade", cwd=bench_path
)
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
if successful_switch:
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual(FRAPPE_BRANCH, app_branch_after_second_switch)


Expand Down
5 changes: 2 additions & 3 deletions bench/tests/test_setup_production.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# imports - standard imports
import getpass
import os
import pathlib
import re
import subprocess
import time
Expand Down Expand Up @@ -76,9 +77,7 @@ def assert_sudoers(self, user):
if os.environ.get("CI"):
sudoers = subprocess.check_output(["sudo", "cat", sudoers_file]).decode("utf-8")
else:
with open(sudoers_file) as f:
sudoers = f.read()

sudoers = pathlib.Path(sudoers_file).read_text()
self.assertTrue(f"{user} ALL = (root) NOPASSWD: {service} nginx *" in sudoers)
self.assertTrue(f"{user} ALL = (root) NOPASSWD: {nginx}" in sudoers)

Expand Down
57 changes: 57 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[project]
name = "frappe-bench"
description = "CLI to manage Multi-tenant deployments for Frappe apps"
readme = "README.md"
license = "GPL-3.0-only"
requires-python = ">=3.7"
authors = [
{ name = "Frappe Technologies Pvt Ltd", email = "developers@frappe.io" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Natural Language :: English",
"Operating System :: MacOS",
"Operating System :: OS Independent",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: User Interfaces",
"Topic :: System :: Installation/Setup",
]
dependencies = [
"Click>=7.0",
"GitPython~=2.1.15",
"honcho",
"Jinja2~=3.0.3",
"python-crontab~=2.6.0",
"requests",
"semantic-version~=2.8.2",
"setuptools>40.9.0",
"tomli;python_version<'3.11'",
]
dynamic = [
"version",
]

[project.scripts]
bench = "bench.cli:cli"

[project.urls]
Changelog = "https://github.com/frappe/bench/releases"
Documentation = "https://frappeframework.com/docs/user/en/bench"
Homepage = "https://frappe.io/bench"
Source = "https://github.com/frappe/bench"

[build-system]
requires = [
"hatchling>=1.6.0",
]
build-backend = "hatchling.build"

[tool.hatch.version]
path = "bench/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/bench",
]
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

0 comments on commit 60569ba

Please sign in to comment.