Skip to content

Commit

Permalink
feat: exporting projects information (#142) (#143)
Browse files Browse the repository at this point in the history
- Added celery
- Added hpc admin flag to user creation in django admin interface
- Added dotenv
- Transferred requirements to Pipfile
- Fixed bug with ag name creation when there is no full name available
  • Loading branch information
stolpeo authored Jan 23, 2024
1 parent 5a2e1bb commit 1d6d4c8
Show file tree
Hide file tree
Showing 49 changed files with 2,403 additions and 314 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/ci.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow is run as part of CI to test that they run through.
#
# The images are pushed to `ghcr.io` for each PR and branch. The ones for
# the releases are pushed in `release-please.yml`.
name: Docker Build

on:
- push
- pull_request

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Write VERSION file for Python package
run: |
git describe --all | tee VERSION
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: utils/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions .github/workflows/docker-cleanup-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Cleanup PR Images

on:
pull_request:
types:
- closed

jobs:
purge-image:
name: Delete PR images
runs-on: ubuntu-latest
steps:
- uses: bots-house/[email protected]
with:
owner: bihealth
name: hpc-access
token: ${{ secrets.GITHUB_TOKEN }}
tag: pr-${{github.event.pull_request.number}}
continue-on-error: true
18 changes: 18 additions & 0 deletions .github/workflows/docker-cleanup-untagged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Cleanup Untagged Images

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * SUN"

jobs:
delete-untagged-images:
name: Delete untagged images
runs-on: ubuntu-latest
steps:
- uses: bots-house/[email protected]
with:
owner: bihealth
name: hpc-access
token: ${{ secrets.GITHUB_TOKEN }}
untagged-keep-latest: 3
118 changes: 118 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI

on:
- push
- pull_request

jobs:
Python-Test:
runs-on: ubuntu-latest
services:
redis:
image: redis:latest
ports:
- 6379:6379

postgres:
image: postgres:14
env:
POSTGRES_DB: hpcaccess
POSTGRES_USER: hpcaccess
POSTGRES_PASSWORD: hpcaccess
DATABASE_URL: postgres://hpcaccess:hpcaccess@postgres/hpcaccess
CELERY_BROKER_URL: redis://redis:6379/0
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432

env:
CELERY_BROKER_URL: redis://0.0.0.0:6379/0
DATABASE_URL: 'postgres://hpcaccess:[email protected]/hpcaccess'
POSTGRES_HOST: 0.0.0.0
POSTGRES_PORT: 5432

steps:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential zlib1g-dev libtiff5-dev libjpeg8-dev \
libfreetype6-dev liblcms2-dev libwebp-dev libpq-dev graphviz-dev \
libldap2-dev libsasl2-dev
- name: Checkout repository
uses: actions/checkout@v3
with:
lfs: true

- name: Install Python
uses: actions/setup-python@v4
with:
# We need to fix the patch version here otherwise, snapshot tests
# with randomness will / may fail.
python-version: "3.10.13"

- name: Install pip and Pipenv
run: |
pip install -U pip pipenv
- name: Install project dependencies with pipenv
run: |
pipenv install --verbose --categories=packages,dev-packages,ldap-packages
- name: Download icons
run: pipenv run python manage.py geticons

- name: Run collectstatic
run: pipenv run python manage.py collectstatic --noinput

- name: Run tests
run: |
pipenv run coverage run --rcfile=.coveragerc manage.py test -v 2 --settings=config.settings.test
pipenv run coverage xml
pipenv run coverage report
# Important: use shell that was initialized by micromamba.
# shell: bash -el {0}

Python-Lint:
runs-on: ubuntu-latest
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Checkout repository
uses: actions/checkout@v3
with:
lfs: true

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install pip and Pipenv
run: |
pip install pip pipenv
- name: Install project dependencies with pipenv
run: |
pipenv install --categories=packages,dev-packages
- name: Check import order with isort
run: |
rm -rf src
pipenv run isort --force-sort-within-sections --profile=black --check .
- name: Check style with black
run: |
pipenv run black --check --line-length 100 .
- name: Run linting
run: |
pipenv run flake8
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ arg =
serve:
$(manage) runserver

celery:
celery -A config.celery_app worker -l info --beat


.PHONY: lack
black:
Expand Down
60 changes: 60 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
python-dotenv = "*"
pytz = "~=2022.1"
python-slugify = "~=6.1.1"
Pillow = "~=9.1.0"
argon2-cffi = "~=21.3.0"
redis = "~=5.0"
celery = "*"
hiredis = "~=2.0.0"
django = "~=4.2.0"
django-environ = "~=0.8.1"
django-model-utils = "~=4.2.0"
django-allauth = "~=0.50.0"
django-crispy-forms = "~=1.14.0"
crispy-bootstrap5 = "~=0.6"
django-redis = "~=5.2.0"
django-celery-beat = "~=2.0"
sentry-sdk = "~=1.5.11"
rules = "~=3.3"
ldap3 = "~=2.9.1"
packages = "*"

[dev-packages]
Werkzeug = "*"
ipdb = "*"
psycopg2 = "*"
mypy = "*"
django-stubs = "*"
pytest = "*"
pytest-sugar = "*"
django-test-plus = "*"
sphinx = "*"
sphinx-autobuild = "*"
flake8 = "*"
coverage = "*"
black = "*"
pylint-django = "*"
pre-commit = "*"
factory-boy = "*"
django-debug-toolbar = "*"
django-extensions = "*"
django-coverage-plugin = "*"
pytest-django = "*"

[ldap-packages]
django-auth-ldap = "~=4.0.0"
python-ldap = "~=3.4.0"

[prod-packages]
gunicorn = "*"
psycopg2 = "*"
whitenoise = "*"

[requires]
python_version = "3.10"
Loading

0 comments on commit 1d6d4c8

Please sign in to comment.