From f7fcbbcc014686ac597b783a8dcb38b43024b9d6 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 4 Aug 2023 09:28:29 +0300 Subject: Initialise the repository. --- .gitignore | 1 + .guix/modules/guix-package.scm | 71 ++++++++++++++++++++++++++++++++++++++++++ README.md | 4 +++ guix.scm | 1 + setup.cfg | 4 +++ setup.py | 44 ++++++++++++++++++++++++++ setup_commands/__init__.py | 3 ++ setup_commands/run_tests.py | 40 ++++++++++++++++++++++++ 8 files changed, 168 insertions(+) create mode 100644 .gitignore create mode 100644 .guix/modules/guix-package.scm create mode 100644 README.md create mode 120000 guix.scm create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 setup_commands/__init__.py create mode 100644 setup_commands/run_tests.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..565bfbc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/**/*~ \ No newline at end of file diff --git a/.guix/modules/guix-package.scm b/.guix/modules/guix-package.scm new file mode 100644 index 0000000..bda9204 --- /dev/null +++ b/.guix/modules/guix-package.scm @@ -0,0 +1,71 @@ +(define-module (genenetwork-auth) + #:use-module (guix) + #:use-module (guix git-download) + #:use-module (guix build-system python) + #:use-module ((guix licenses) #:prefix license:) + + #:use-module (git oid) + #:use-module (git bindings) + #:use-module (git reference) + #:use-module (git repository) + + + ;; Packages from guix + #:use-module (gnu packages check) + + #:use-module (gnu packages python-web) + #:use-module (gnu packages python-xyz) + #:use-module (gnu packages python-crypto) + + #:use-module (gnu packages databases) + + + ;; Packages from guix-bioinformatics + #:use-module (gn packages python-web)) + +(define %source-dir (dirname (dirname (dirname (current-filename))))) + +(define (get-commit) + "Retrieve the commit if the source directory is a repository." + (if (git-predicate %source-dir) + (begin (let ((commit #f)) + (libgit2-init!) + (set! commit (oid->string + (reference-target + (repository-head (repository-open %source-dir))))) + (libgit2-shutdown!) + commit)) + "NOTAREPOSITORY")) + +(define (get-latest-version) + "Get latest version tag from repository." + ;; TODO: Implement + "v0.0.0") + +(define vcs-file? + (or (git-predicate %source-dir) + (const #t))) + +(package + (name "genenetwork-auth") + (version (string-append (get-latest-version) + "-git-" + (substring (get-commit) 0 9))) + (source (local-file %source-dir "genenetwork-auth-checkout" + #:recursive? #t + #:select? vcs-file?)) + (build-system python-build-system) + ;; (inputs (list)) + (native-inputs + (list python-pytest + python-pylint)) + (propagated-inputs + (list python-flask + python-authlib + yoyo-migrations + python-argon2-cffi + python-email-validator)) + (home-page "https://github.com/genenetwork/gn-auth") + (synopsis "Authentication and Authorisation server for GeneNetwork services.") + (description "Authentication and Authorisation server for GeneNetwork services.") + (license license:agpl3+)) diff --git a/README.md b/README.md new file mode 100644 index 0000000..7bf6f9c --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# GeneNetwork Auth + +This project is for the GeneNetwork Authentication/Authorisation server to be +used across the entire suite of the GeneNetwork services. diff --git a/guix.scm b/guix.scm new file mode 120000 index 0000000..869bf3d --- /dev/null +++ b/guix.scm @@ -0,0 +1 @@ +.guix/modules/guix-package.scm \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..41d118e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,4 @@ +[aliases] +run_unit_tests = run_tests --type=unit +run_integration_tests = run_tests --type=integration +run_performance_tests = run_tests --type=performance diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..52a928e --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +"""Setup script for GeneNetwork Auth package.""" +from setuptools import setup +from setup_commands import RunTests + +long_description = """ +GeneNetwork-Auth project is the authentication/authorisation server to be used +across all GeneNetwork services. +""" + +setup(author="Frederick M. Muriithi", + author_email="fredmanglis@gmail.com", + description=( + "Authentication/Authorisation server for GeneNetwork Services."), + install_requires=[ + "argon2-cffi>=20.1.0" + "click" + "Flask==1.1.2" + "mypy==0.790" + "mypy-extensions==0.4.3" + "mysqlclient==2.0.1" + "pylint==2.5.3" + "pymonad" + "redis==3.5.3" + "requests==2.25.1" + "flask-cors==3.0.9" + "xapian-bindings" + ], + scripts=[], + license="AGPLV3", + long_description=long_description, + long_description_content_type="text/markdown", + name="GeneNetwork-Auth", + packages=[ + "gn_auth", + "gn_auth.auth", + "tests" + ], + url="https://github.com/genenetwork/gn-auth", + version="0.0.0", + tests_require=["pytest", "hypothesis"], + cmdclass={ + "run_tests": RunTests ## testing + }) diff --git a/setup_commands/__init__.py b/setup_commands/__init__.py new file mode 100644 index 0000000..967bb11 --- /dev/null +++ b/setup_commands/__init__.py @@ -0,0 +1,3 @@ +"""Module for custom setup commands.""" + +from .run_tests import RunTests diff --git a/setup_commands/run_tests.py b/setup_commands/run_tests.py new file mode 100644 index 0000000..1bb5dab --- /dev/null +++ b/setup_commands/run_tests.py @@ -0,0 +1,40 @@ +import os +import sys +from distutils.core import Command + +class RunTests(Command): + """ + A custom command to run tests. + """ + description = "Run the tests" + test_types = ( + "all", "unit", "integration", "performance") + user_options = [ + ("type=", None, + f"""Specify the type of tests to run. + Valid types are {tuple(test_types)}. + Default is `all`.""")] + + def __init__(self, dist): + """Initialise the command.""" + super().__init__(dist) + self.command = "pytest" + + def initialize_options(self): + """Initialise the default values of all the options.""" + self.type = "all" + + def finalize_options(self): + """Set final value of all the options once they are processed.""" + if self.type not in RunTests.test_types: + raise Exception(f""" + Invalid test type (self.type) requested! + Valid types are + {tuple(RunTests.test_types)}""") + + if self.type != "all": + self.command = f"pytest -m {self.type}_test" + def run(self): + """Run the chosen tests""" + print(f"Running {self.type} tests") + os.system(self.command) -- cgit v1.2.3