Commit 39d3f304 authored by Nicolas Mérigot's avatar Nicolas Mérigot

Initial commit

image: python:3.6
- test
- release
stage: test
- echo 'Make your tests here !'
- master
- sib
stage: release
- git config "${GITLAB_USER_NAME}"
- git config "${GITLAB_USER_EMAIL}"
- git remote set-url origin "https://gitlab-ci-token:${GL_TOKEN}${CI_PROJECT_PATH}.git"
- pip install git+
- pip install sib-commit-parser
- semantic-release publish
- do_not_publish
- sib
# Django LDP example
## Step by step quickstart
1. Installation
- `git clone /path/to/myawesomepackage`
- `git remote set-url origin the_repository_url`
- rename djangoldp_example directory to djangoldp_myawesomepackage
- replace /path/to/myawesomepackage with the local path of your package.
- replace the_repository_url with the git url of your package (example:
- replace djangoldp_myawesomepackage with your package name. Please respect the naming convention (singular word, starting by `djangoldp_`)
2. Developpement environnement
In order to test and developp your package, you need to put the package src directory at the same level of a working django ldp app. By exemple, you can clone the sib app data server
`git clone server /path/to/app`
- The classical way :
`ln -s /path/to/myawesomepackage/djangoldp_myawesomepackage /path/to/app/djangoldp_myawesomepackage`
- The docker way : in the *volumes* section, add a line in docker-compose.override.yml. Example
- ./:/app
- /path/to/myawesomepackage/djangoldp_myawesomepackage:/app/djangoldp_myawesomepackage
Add your package in of the app. Now, you can test if your package is imported propefully by doing a
`python shell` then
from djangoldp_myawesomepackage.models import ExampleModel
If, no error, it's working.
3. Customization
- `setup.cfg` : please, fill the name, version, url, author_email, description
- `djangoldp_example/`: fill the name, don't touch the version number !
- everything under the djangoldp_example is part of your package, you probably would replace "example" by your package name.
4. Push on the repository you've created
## Notes
### CICD
When you're ready to publish your app :
1. Add the `sib-deploy` user as a `maintainer` to the project (`Settings > Members`)
2. Configure `pipeline strategy` to `clone` (`Settings > CI/CD > Pipelines`)
3. Protect the `master` branch allowing only `maintainers` to push (`Settings > Repository > Protected branches`)
4. Configure CI/CD variables to authenticate on
Variable | Value | Protection
`GL_TOKEN` | `sib-deploy-token` | protected
`PYPI_PASSWORD` | `pypi-password` | protected
`PYPI_USERNAME` | startinblox | protected
5. Replace the "do_not_publish" by "master" in the .gitlab-ci.yml
### Factories
If you dont need factory, you can remove the mock_example command, the factories files and the extras_require section in setup.cfg
Provide a factory is a good pratice in order to simplify the mocking of data on a server / in a test pipeline.
__version__ = '0.0.0'
name = "djangoldp_example"
from django.contrib import admin
from .models import ExampleModel
from django.apps import AppConfig
class DjangoldpExampleConfig(AppConfig):
name = 'djangoldp_example'
import factory
import hashlib
from .models import ExampleModel
from django.db.models.signals import post_save
class ExampleFactory(factory.django.DjangoModelFactory):
class Meta:
model = ExampleModel
# Please refer to Factory boy documentation
from import BaseCommand, CommandError
from djangoldp_example.factories import ExampleFactory
class Command(BaseCommand):
help = 'Mock data'
def add_arguments(self, parser):
parser.add_argument('--size', type=int, default=0, help='Number of example to create')
def handle(self, *args, **options):
ExampleFactory.create_batch(options['size'], thread=thread)
self.stdout.write('Successful data mock install'))
from django.db import models
class ExampleModel(models.Model):
# Please refer to Django documentation
"""djangoldp project URL Configuration"""
from django.conf.urls import url
from djangoldp.views import LDPViewSet
from .models import ExampleModel
urlpatterns = [
url(r'^examples/', LDPViewSet.urls(model=ExampleModel)),
name = djangoldp_example
version = attr: djangoldp_example.__version__
url =
author = Startin'blox
author_email =
description = djangoldp example package
license = MIT
packages = find:
install_requires =
dev =
version_source = tag
version_variable = djangoldp_example/
commit_parser = commit_parser.parse
#!/usr/bin/env python
from setuptools import setup
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment