This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
132 changed files
with
8,327 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# General | ||
# ------------------------------------------------------------------------------ | ||
USE_DOCKER=yes | ||
IPYTHONDIR=/app/.ipython | ||
|
||
# Redis | ||
# ------------------------------------------------------------------------------ | ||
REDIS_URL=redis://localhost:6379/0 | ||
|
||
# Celery | ||
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672/ | ||
CELERY_RESULT_BACKEND=redis://localhost:6379/2 | ||
# Flower | ||
CELERY_FLOWER_USER=debug | ||
CELERY_FLOWER_PASSWORD=debug |
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,7 @@ | ||
# PostgreSQL | ||
# ------------------------------------------------------------------------------ | ||
POSTGRES_HOST=db | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB=inspire | ||
POSTGRES_USER=inspire | ||
POSTGRES_PASSWORD=inspire |
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,15 @@ | ||
# General | ||
# ------------------------------------------------------------------------------ | ||
USE_DOCKER=yes | ||
IPYTHONDIR=/app/.ipython | ||
|
||
# Redis | ||
# ------------------------------------------------------------------------------ | ||
REDIS_URL=redis://localhost:6379/0 | ||
|
||
# Celery | ||
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672/ | ||
CELERY_RESULT_BACKEND=redis://localhost:6379/2 | ||
# Flower | ||
CELERY_FLOWER_USER=debug | ||
CELERY_FLOWER_PASSWORD=debug |
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,7 @@ | ||
# PostgreSQL | ||
# ------------------------------------------------------------------------------ | ||
POSTGRES_HOST=localhost | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB=inspire | ||
POSTGRES_USER=inspire | ||
POSTGRES_PASSWORD=inspire |
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,13 @@ | ||
# Config for Dependabot updates. See Documentation here: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # pip supports also poetry https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
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,52 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to build | ||
type: string | ||
required: true | ||
image: | ||
description: The name of the image to build | ||
type: string | ||
required: true | ||
context: | ||
description: The context used to build the image | ||
type: string | ||
required: true | ||
dockerfile: | ||
description: The path to the Dockerfile | ||
type: string | ||
required: false | ||
outputs: | ||
image-id: | ||
description: The ID of image that has been built | ||
value: ${{ jobs.build.outputs.image-id }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image-id: ${{ steps.build.outputs.image-id }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- id: build | ||
name: Build and push | ||
uses: cern-sis/gh-workflows/.github/actions/[email protected] | ||
with: | ||
image: ${{ inputs.image }} | ||
context: ${{ inputs.context }} | ||
dockerfile: ${{ inputs.dockerfile }} | ||
registry: registry.cern.ch | ||
cache: false | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=ref,event=tag | ||
username: ${{ secrets.HARBOR_USERNAME }} | ||
password: ${{ secrets.HARBOR_SECRET }} |
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,59 @@ | ||
name: Integration tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to test | ||
type: string | ||
required: true | ||
image: | ||
description: The name of the image to test | ||
type: string | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
services: | ||
rabbitmq: | ||
image: rabbitmq:3-management | ||
ports: | ||
- 5672:5672 | ||
redis: | ||
image: redis:6 | ||
ports: | ||
- 6379:6379 | ||
db: | ||
image: postgres:14.1 | ||
env: | ||
POSTGRES_DB: inspire | ||
POSTGRES_USER: inspire | ||
POSTGRES_PASSWORD: inspire | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
- name: Test | ||
run: > | ||
docker run | ||
--pull always | ||
--network=host | ||
--entrypoint poetry | ||
--env DJANGO_SETTINGS_MODULE=config.settings.test | ||
--env DISABLE_SECURITY_PLUGIN=true | ||
--env POSTGRES_DB=inspire | ||
--env POSTGRES_USER=inspire | ||
--env POSTGRES_PASSWORD=inspire | ||
--env POSTGRES_HOST=127.0.0.1 | ||
--env OPENSEARCH_HOST=127.0.0.1:9200 | ||
${{ inputs.image }} | ||
run pytest |
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,33 @@ | ||
name: Lint | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to build | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: black | ||
uses: psf/black@stable | ||
with: | ||
options: '--verbose' | ||
|
||
- name: run flake8 | ||
uses: julianwachholz/flake8-action@v2 | ||
with: | ||
checkName: 'flake8' |
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,21 @@ | ||
name: Push main | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
ref: ${{ github.ref }} | ||
secrets: inherit | ||
test: | ||
uses: ./.github/workflows/tests.yml | ||
with: | ||
ref: ${{ github.ref }} | ||
secrets: inherit |
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,24 @@ | ||
name: Pull request main | ||
|
||
on: | ||
pull_request_target: | ||
branches: [main] | ||
paths-ignore: [ "docs/**" ] | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
ref: ${{ github.ref }} | ||
secrets: inherit | ||
test: | ||
uses: ./.github/workflows/tests.yml | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
secrets: inherit | ||
|
||
pre-commit: | ||
uses: ./.github/workflows/pre-commit.yml | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
secrets: inherit |
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,32 @@ | ||
name: Tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: The reference to build | ||
type: string | ||
required: true | ||
outputs: | ||
image-id: | ||
description: The ID of image that has been buit | ||
value: ${{ jobs.build.outputs.image-id }} | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
ref: ${{ inputs.ref }} | ||
image: cern-sis/inspire/backoffice | ||
context: . | ||
dockerfile: ./compose/production/django/Dockerfile | ||
secrets: inherit | ||
|
||
test: | ||
needs: build | ||
strategy: | ||
fail-fast: false | ||
uses: ./.github/workflows/integration-tests.yml | ||
with: | ||
ref: ${{ inputs.ref }} | ||
image: "registry.cern.ch/cern-sis/inspire/backoffice@${{ needs.build.outputs.image-id }}" |
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 @@ | ||
3.11 |
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 @@ | ||
Daniel Roy Greenfeld |
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,88 @@ | ||
# backoffice | ||
|
||
Behold My Awesome Project! | ||
|
||
[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter)](https://github.com/cookiecutter/cookiecutter-django/) | ||
[![Black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) | ||
|
||
License: MIT | ||
|
||
## Settings | ||
|
||
Moved to [settings](http://cookiecutter-django.readthedocs.io/en/latest/settings.html). | ||
|
||
## Basic Commands | ||
|
||
### Setting Up Your Users | ||
|
||
- To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go. | ||
|
||
- To create a **superuser account**, use this command: | ||
|
||
$ python manage.py createsuperuser | ||
|
||
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users. | ||
|
||
### Type checks | ||
|
||
Running type checks with mypy: | ||
|
||
$ mypy backoffice | ||
|
||
### Test coverage | ||
|
||
To run the tests, check your test coverage, and generate an HTML coverage report: | ||
|
||
$ coverage run -m pytest | ||
$ coverage html | ||
$ open htmlcov/index.html | ||
|
||
#### Running tests with pytest | ||
|
||
$ pytest | ||
|
||
### Live reloading and Sass CSS compilation | ||
|
||
Moved to [Live reloading and SASS compilation](https://cookiecutter-django.readthedocs.io/en/latest/developing-locally.html#sass-compilation-live-reloading). | ||
|
||
### Celery | ||
|
||
This app comes with Celery. | ||
|
||
To run a celery worker: | ||
|
||
```bash | ||
cd backoffice | ||
celery -A config.celery_app worker -l info | ||
``` | ||
|
||
Please note: For Celery's import magic to work, it is important _where_ the celery commands are run. If you are in the same folder with _manage.py_, you should be right. | ||
|
||
To run [periodic tasks](https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html), you'll need to start the celery beat scheduler service. You can start it as a standalone process: | ||
|
||
```bash | ||
cd backoffice | ||
celery -A config.celery_app beat | ||
``` | ||
|
||
or you can embed the beat service inside a worker with the `-B` option (not recommended for production use): | ||
|
||
```bash | ||
cd backoffice | ||
celery -A config.celery_app worker -B -l info | ||
``` | ||
|
||
### Sentry | ||
|
||
Sentry is an error logging aggregator service. You can sign up for a free account at <https://sentry.io/signup/?code=cookiecutter> or download and host it yourself. | ||
The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application. | ||
|
||
You must set the DSN url in production. | ||
|
||
## Deployment | ||
|
||
The following details how to deploy this application. | ||
|
||
### Docker | ||
|
||
See detailed [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html). |
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,2 @@ | ||
__version__ = "0.1.0" | ||
__version_info__ = tuple(int(num) if num.isdigit() else num for num in __version__.replace("-", ".", 1).split(".")) |
Oops, something went wrong.