aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-04 09:28:29 +0300
committerFrederick Muriuki Muriithi2023-08-04 10:20:09 +0300
commitf7fcbbcc014686ac597b783a8dcb38b43024b9d6 (patch)
treefcd69ffe3113c95f1dffa4a26dd5a65f9689caf9
downloadgn-auth-f7fcbbcc014686ac597b783a8dcb38b43024b9d6.tar.gz
Initialise the repository.
-rw-r--r--.gitignore1
-rw-r--r--.guix/modules/guix-package.scm71
-rw-r--r--README.md4
l---------guix.scm1
-rw-r--r--setup.cfg4
-rw-r--r--setup.py44
-rw-r--r--setup_commands/__init__.py3
-rw-r--r--setup_commands/run_tests.py40
8 files changed, 168 insertions, 0 deletions
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)