Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosNasayo committed Dec 11, 2023
0 parents commit 4671066
Show file tree
Hide file tree
Showing 12 changed files with 656 additions and 0 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/test_pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Devops OrmAClimate

on:
push:
branches: [ "stage" ]
tags:
- 'v*'


permissions:
contents: read

jobs:

# ------- START ORM PROCCESS -------- #

TestModels:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Create environment
run: |
python -m venv env
- name: Active environment
run: |
source env/bin/activate
- name: Install dependencies
run: |
pip install -r ./requirements.txt
- name: Run Tests
run: |
python -m unittest discover -s ./src/tests/ -p 'test_*.py'
# ------- END ORM PROCCESS -------- #

# ------- START MERGE PROCCESS -------- #

MergeMainModels:
needs: [TestModels]
name: Merge Stage with Main
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Merge stage -> main
uses: devmasx/merge-branch@master
with:
type: now
head_to_merge: ${{ github.ref }}
target_branch: main
github_token: ${{ github.token }}

# ------- END MERGE PROCCESS -------- #

# ------- START RELEASE PROCCESS -------- #

PostRelease:
needs: MergeMainModels
name: Create Release
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
# API Zip
- name: Zip artifact for deployment
run: zip releaseORM.zip ./src/* -r
# Upload Artifacts
- name: Upload Model artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: ORM
path: releaseORM.zip
# Generate Tagname
- name: Generate Tagname for release
id: taggerDryRun
uses: anothrNick/github-tag-action@1.61.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DRY_RUN: true
DEFAULT_BUMP: patch
RELEASE_BRANCHES : stage,main
BRANCH_HISTORY: last
# Create release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ steps.taggerDryRun.outputs.new_tag }}
release_name: Release ${{ steps.taggerDryRun.outputs.new_tag }}
#body_path: ./body.md
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
# Upload Assets to release
- name: Upload Release Asset Model
id: upload-orm-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./releaseORM.zip
asset_name: releaseORM.zip
asset_content_type: application/zip
# update version setup.py
- name: Checkout code
uses: actions/checkout@v3
with:
ref: main
- name: Update version
run: |
sed -i "s/version='.*'/version='${{ steps.taggerDryRun.outputs.new_tag }}'/" setup.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update version to ${{ steps.taggerDryRun.outputs.new_tag }}"

# ------- END RELEASE PROCCESS -------- #
169 changes: 169 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
#
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
env
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

src/unittests.py

# Folder to test
data/
env
#data/*.*
#!data/readme.md
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# ORM ACLIMATE

![GitHub release (latest by date)](https://img.shields.io/github/v/release/CIAT-DAPA/aclimate_orm) ![](https://img.shields.io/github/v/tag/CIAT-DAPA/aclimate_orm)

## Features

- Built using Mongoengine for MongoDB
- Supports Python 3.x

## Getting Started

To use this Models, it is necessary to have an instance of MongoDB running.

### Prerequisites

- Python 3.x
- MongoDB

## Usage

This ORM can be used as a library in other Python projects. The models are located in the my_orm/models folder, and can be imported like any other Python module. To install this orm as a library you need to execute the following command:

````bash
pip install git+https://github.com/CIAT-DAPA/aclimate_orm
````

If you want to download a specific version of orm you can do so by indicating the version tag (@v0.0.0) at the end of the install command

````bash
pip install git+https://github.com/CIAT-DAPA/aclimate_orm@v0.2.0
````

## Test
````bash
python -m unittest discover -s ./src/tests/ -p 'test_*.py'
````

## Models

### Users

Represents a User in the database.

Attributes:

- id: `ObjectId` - Id of the user.
- Username: `str` - User's username.
- NormalizedUserName: `str` - Normalized username.
- Email: `str` - User's email address.
- NormalizedEmail: `str` - Normalized email address.
- EmailConfirmed: `bool` - Indicates whether the user's email has been confirmed. Default is False.
- PasswordHash: `str` - Hashed password for the user.
- SecurityStamp: `str` - A random value that should change whenever a user's credentials have changed.
- ConcurrencyStamp: `str` - A value used for optimistic concurrency, ensuring updates are not based on stale data.
- PhoneNumber: `str` - User's phone number.
- PhoneNumberConfirmed: `bool` - Indicates whether the user's phone number has been confirmed. Default is False.
- TwoFactorEnabled: `bool` - Indicates whether two-factor authentication is enabled for the user. Default is False.
- LockoutEnd: `str` - Date and time in string format when the user's lockout period will end.
- LockoutEnabled: `bool` - Indicates whether lockout is enabled for the user. Default is True.
- AccessFailedCount: `int` - Number of failed access attempts.
- AuthenticatorKey: `str` - Key used for two-factor authentication.
- Roles: `List` - List of roles assigned to the user.
- Claims: `List` - List of claims associated with the user.
- Logins: `List` - List of external logins linked to the user.
- Tokens: `List` - List of tokens associated with the user.
- RecoveryCodes: `List` - List of recovery codes for two-factor authentication recovery.

Methods:

- `save()`: Saves the User object to the database.
- `delete()`: Deletes the User object from the database.

### Roles

Represents a Rol entry in the database.

Attributes:
- _id: `StringField` - Id of the user. (Primary Key)
- Name: `StringField` - User's name. (Required)
- NormalizedName: `StringField` - Normalized name.
- ConcurrencyStamp: `StringField` - A value used for optimistic concurrency, ensuring updates are not based on stale data. (Required)

Methods:

- `save()`: Saves the Rol object to the database.
- `delete()`: Deletes the Rol object from the database.

Loading

0 comments on commit 4671066

Please sign in to comment.