Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics Database and Build Time Processor #594

Merged
merged 7 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/analytics_migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check Analytics Migrations

on:
pull_request:
paths:
- "analytics/**"

jobs:
check-migrations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install requirements
run: pip install -r ./analytics/requirements.txt

- name: Provide default env vars for django
run: cat ./analytics/dev/.env.docker-compose >> $GITHUB_ENV

# This runs on pull requests and blocks until any necessary migrations have been created
# *Note*: This will display a warning about not being able to connect to a database. This can be ignored.
- name: Check for Migrations
run: ./analytics/manage.py makemigrations --check --noinput
36 changes: 20 additions & 16 deletions .github/workflows/custom_docker_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,38 @@ jobs:
fail-fast: false
matrix:
include:
- docker-image: gh-gl-sync
- docker-image: ./images/gh-gl-sync
image-tags: ghcr.io/spack/ci-bridge:0.0.37
- docker-image: gitlab-api-scrape
- docker-image: ./images/gitlab-api-scrape
image-tags: ghcr.io/spack/gitlab-api-scrape:0.0.2
- docker-image: ci-key-rotate
- docker-image: ./images/ci-key-rotate
image-tags: ghcr.io/spack/ci-key-rotate:0.0.4
- docker-image: ci-key-clear
- docker-image: ./images/ci-key-clear
image-tags: ghcr.io/spack/ci-key-clear:0.0.1
- docker-image: gitlab-stuckpods
- docker-image: ./images/gitlab-stuckpods
image-tags: ghcr.io/spack/stuckpods:0.0.1
- docker-image: gitlab-clear-pipelines
- docker-image: ./images/gitlab-clear-pipelines
image-tags: ghcr.io/spack/gitlab-clear-pipelines:0.0.1
- docker-image: gitlab-skipped-pipelines
- docker-image: ./images/gitlab-skipped-pipelines
image-tags: ghcr.io/spack/gitlab-skipped-pipelines:0.0.1
- docker-image: notary
- docker-image: ./images/notary
image-tags: ghcr.io/spack/notary:latest
- docker-image: python-aws-bash
- docker-image: ./images/python-aws-bash
image-tags: ghcr.io/spack/python-aws-bash:0.0.1
- docker-image: opensearch-index-build-logs
- docker-image: ./images/opensearch-index-build-logs
image-tags: ghcr.io/spack/opensearch-index-build-logs:0.0.4
- docker-image: gitlab-error-processor
- docker-image: ./images/gitlab-error-processor
image-tags: ghcr.io/spack/gitlab-error-processor:0.0.1
- docker-image: upload-gitlab-failure-logs
- docker-image: ./images/upload-gitlab-failure-logs
image-tags: ghcr.io/spack/upload-gitlab-failure-logs:0.0.1
- docker-image: snapshot-release-tags
- docker-image: ./images/snapshot-release-tags
image-tags: ghcr.io/spack/snapshot-release-tags:0.0.2
- docker-image: cache-indexer
- docker-image: ./images/cache-indexer
image-tags: ghcr.io/spack/cache-indexer:0.0.1
- docker-image: ./images/build-timing-processor
image-tags: ghcr.io/spack/build-timing-processor:0.0.1
- docker-image: ./analytics
image-tags: ghcr.io/spack/upload-build-timings:0.0.1
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -57,8 +61,8 @@ jobs:
id: docker-build-push
uses: docker/build-push-action@67af6dc1d38f334ae6935c94587e8a5b45a81a0e
with:
context: ./images/${{ matrix.docker-image }}
file: ./images/${{ matrix.docker-image }}/Dockerfile
context: ${{ matrix.docker-image }}
file: ${{ matrix.docker-image }}/Dockerfile
push: true
tags: ${{ matrix.image-tags }}

Expand Down
126 changes: 126 additions & 0 deletions analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
staticfiles/

# Created by https://www.gitignore.io/api/django
# Edit at https://www.gitignore.io/?templates=django

### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
media

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/

### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
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
.hypothesis/
.pytest_cache/

# Translations
*.mo

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# pyenv
.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

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

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

# Pyre type checker
.pyre/

# End of https://www.gitignore.io/api/django

# Editor settings
.vscode
12 changes: 12 additions & 0 deletions analytics/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt /app/requirements.txt

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY . .

CMD [ "./manage.py", "upload_build_timings" ]
48 changes: 48 additions & 0 deletions analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Django Analytics App

This is the Django app responsible for managing the analytics postgres database. This database contains any information that we'd like to keep track of in a relational way, but separate from the production gitlab database, as to not interfere with anything.


# Local Setup

To get a local version of the database, simply run the command:
```
docker-compose up
```

Then follow the "Applying Migrations" step to initially setup the database.


## Creating migrations

After modifying the models (db tables), you must create migrations, so that the changes can be applied to the actual database. To do this, run the command:
```
./manage.py makemigrations analytics
```

## Applying migrations

To apply the migrations to the database, run the command:
```
./manage.py migrate
```

**NOTE:** This is done as a part of CI, and so shouldn't normally be run against the production database.


## Accessing Data

To access and/or modify any data within the database, the django shell can be used as follows:
```
./manage.py shell_plus
```

This command will drop you into a Python shell with Django pre-loaded, so that models and data can be viewed, created, deleted, etc.
jjnesbitt marked this conversation as resolved.
Show resolved Hide resolved


If you'd like to access postgres more directly, that can be done with the following command:
```
./manage.py dbshell
```

This command will drop you into a psql shell, in the correct database.
Empty file added analytics/analytics/__init__.py
Empty file.
Loading