-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement build_number_manager with django
- Loading branch information
Showing
22 changed files
with
1,175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
# backend-services | ||
|
||
Scripts used to power the Mumble public infrastructure backend (e.g. public server list) | ||
|
||
|
||
## Development | ||
|
||
Enter the Django project folder ``mumble_backend``. Call ``source setup`` | ||
to create a new venv which automatically installs Django and activates it. | ||
|
||
Create the database tables with: | ||
``` | ||
python manage.py migrate | ||
``` | ||
|
||
Start the development server with: | ||
``` | ||
python manage.py runserver | ||
``` | ||
|
||
Run tests with: | ||
``` | ||
python manage.py test | ||
``` | ||
|
||
Create an admin account for the admin interface with: | ||
``` | ||
python manage.py createsuperuser | ||
``` | ||
|
||
Auto format code with: | ||
``` | ||
black . | ||
``` | ||
|
||
## Production | ||
|
||
TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
### Build Number Manager | ||
|
||
#### API v1: | ||
|
||
Endpoint: ``/build-number/v1/<series>/<commit>?token=<token>`` | ||
| HTTP <br> Method| Parameters | Response | | ||
| :-----: | ----- | ---- | | ||
| ``POST`` | ``<series>``: The Mumble series e.g. ``1.4`` <br> ``<commit>``: The commit hash <br> ``<token>``: An authorized password | ``201``: New build number created <br> ``400``: Invalid parameters <br> ``409``: Commit already exists in series <br> ``422``: New build number exceeds 2 bytes | | ||
| ``GET`` | ``<series>``: The Mumble series e.g. ``1.4`` <br> ``<commit>``: The commit hash <br> ``<token>``: An authorized password | ``200``: Found <br> ``400``: Invalid parameters <br> ``404``: Series or build not found | | ||
|
||
Returned JSON: | ||
``` | ||
{ | ||
"commit_hash": <The commit hash>, | ||
"series": <The Mumble version series e.g. "1.4.x">, | ||
"series_id": <The series DB id>, | ||
"build_number": <The new build number>, | ||
"series_created": <Series creation datetime>, | ||
"build_created": <Build number creation datetime> | ||
} | ||
``` | ||
|
||
--- | ||
|
||
Endpoint: ``/build-number/v1/<series>?token=<token>`` | ||
| HTTP <br> Method| Parameters | Response | | ||
| :-----: | ----- | ---- | | ||
| ``GET`` | ``<series>``: The Mumble series e.g. ``1.4`` <br> ``<token>``: An authorized password | ``200``: Found <br> ``400``: Invalid parameters <br> ``404``: Series not found | | ||
|
||
Returned JSON: | ||
``` | ||
{ | ||
"series": <The Mumble version series e.g. "1.4.x">, | ||
"series_id": <The series DB id>, | ||
"series_created": <Series creation datetime>, | ||
"builds": <List of all builds> | ||
} | ||
``` | ||
Build object: | ||
``` | ||
{ | ||
"commit_hash": <The commit hash>, | ||
"build_number": <The build number>, | ||
"build_created": <Build number creation datetime> | ||
} | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Series, Build | ||
|
||
admin.site.register(Series) | ||
admin.site.register(Build) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BuildNumberManagerConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "build_number_manager" |
70 changes: 70 additions & 0 deletions
70
mumble_backend/build_number_manager/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Generated by Django 4.1.7 on 2023-04-13 14:44 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Build", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("commit_hash", models.CharField(max_length=128)), | ||
("build_number", models.PositiveIntegerField()), | ||
("created_on", models.DateTimeField(auto_now_add=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="Series", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("major", models.PositiveIntegerField()), | ||
("minor", models.PositiveIntegerField()), | ||
("created_on", models.DateTimeField(auto_now_add=True)), | ||
], | ||
options={ | ||
"verbose_name_plural": "series", | ||
}, | ||
), | ||
migrations.AddConstraint( | ||
model_name="series", | ||
constraint=models.UniqueConstraint( | ||
fields=("major", "minor"), name="major_minor_unique" | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="build", | ||
name="series", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.PROTECT, | ||
to="build_number_manager.series", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="build", | ||
constraint=models.UniqueConstraint( | ||
fields=("series", "commit_hash"), name="commit_unique_in_series" | ||
), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from django.db import models | ||
|
||
|
||
class Series(models.Model): | ||
major = models.PositiveIntegerField() | ||
minor = models.PositiveIntegerField() | ||
created_on = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return "%i.%i.x" % (self.major, self.minor) # e.g. 1.4.x | ||
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint( | ||
fields=["major", "minor"], name="major_minor_unique" | ||
) | ||
] | ||
verbose_name_plural = "series" | ||
|
||
|
||
class Build(models.Model): | ||
series = models.ForeignKey(Series, on_delete=models.PROTECT) | ||
commit_hash = models.CharField(max_length=128) | ||
build_number = models.PositiveIntegerField() | ||
created_on = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return "%i.%i.%i" % ( | ||
self.series.major, | ||
self.series.minor, | ||
self.build_number, | ||
) # e.g. 1.4.142 | ||
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint( | ||
fields=["series", "commit_hash"], name="commit_unique_in_series" | ||
) | ||
] |
Oops, something went wrong.