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

Update Repo Structure #17

Merged
merged 10 commits into from
Jun 24, 2024
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
97 changes: 97 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Docker publish

on:
workflow_dispatch:
push:
branches:
- next
- qa
- main

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io

jobs:
build:

runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
- name: Install requirements
run: |
# --quiet should turn off progress bars to make logs more readable
conda env create

- name: Create tag version
id: tag
run: |
conda activate livedata
echo "tag=$(versioningit)" >> $GITHUB_OUTPUT

- name: Create latest tag version
id: latest_tag
run: |
case ${{ github.ref }} in

refs/heads/next)
echo "latest_tag=latest-dev" >> $GITHUB_OUTPUT
;;

refs/heads/qa)
echo "latest_tag=latest-test" >> $GITHUB_OUTPUT
;;

refs/heads/main)
echo "latest_tag=latest-prod" >> $GITHUB_OUTPUT
;;

*)
exit 1
;;

esac

- name: Check tag names
run: |
echo ${{ steps.latest_tag.outputs.latest_tag }}
echo ${{ steps.tag.outputs.tag }}

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ${{ env.REGISTRY }}/${{ github.repository }}/live_data_server:${{ steps.latest_tag.outputs.latest_tag }}
push: true

- name: Push version tag only for main branch
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ${{ env.REGISTRY }}/${{ github.repository }}/live_data_server:${{ steps.tag.outputs.tag }}
push: true
29 changes: 25 additions & 4 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
pull_request:
push:
branches: main
branches: [next, qa, main]
tags: ['v*']

jobs:
Expand All @@ -22,9 +22,10 @@ jobs:
LIVE_PLOT_SECRET_KEY: "1234_live_data_server"
DJANGO_SUPERUSER_USERNAME: livedatauser
DJANGO_SUPERUSER_PASSWORD: livedatapass
COVERAGE_RUN: coverage run -m
jmborr marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge,defaults
Expand All @@ -35,8 +36,28 @@ jobs:
- name: Start docker containers
run: |
cp ./config/docker-compose.envlocal.yml docker-compose.yml
docker compose up --build -d
docker-compose up --build -d
- name: Sleep, wait for containers to start up
run: sleep 30
- name: Run unit tests
run: python -m pytest tests/
- name: Stop the coverage process
# Stopping the coverage process allows the code coverage to be written to disk
run: docker exec live_data_server_livedata_1 /bin/bash -c "pkill coverage"
- name: Copy code coverage out of docker container
run: docker cp live_data_server_livedata_1:/var/www/livedata/app /tmp/
- name: Combine and show code coverage
shell: bash -l {0}
run: |
cd /tmp/app
coverage combine
coverage xml
cp coverage.xml $OLDPWD
coverage report
- name: Bring down docker containers completely now
# This will completely remove the containers
run: docker-compose down
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: [--maxkb=8192]
- id: check-merge-conflict
- id: check-yaml
args: [--allow-multiple-documents]
exclude: "conda.recipe/meta.yaml"
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /var/www/livedata

COPY docker-entrypoint.sh /usr/bin/

COPY live_data_server app
COPY src/live_data_server app
RUN mkdir ./static

RUN chmod +x /usr/bin/docker-entrypoint.sh
Expand Down
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BSD 3-Clause License

Copyright (c) 2024, OAK RIDGE NATIONAL LABORATORY

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Developer documentation at https://livedata-ornl.readthedocs.io/en/latest/

## Contributing

Create a conda environment `livedata`, containing all the dependencies
Create a conda environment `livedata`, containing all the dependencies
```python
conda env create -f environment.yml
conda activate livedata
Expand Down Expand Up @@ -66,4 +66,4 @@ run the following command from within directory `docs/`:
make html
```
The documentation will be built in the `docs/_build/html` directory. To view the documentation,
open the `docs/_build/html/index.html` file in a web browser.
open the `docs/_build/html/index.html` file in a web browser.
3 changes: 2 additions & 1 deletion config/docker-compose.envlocal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
DATABASE_HOST: ${DATABASE_HOST}
DATABASE_PORT: ${DATABASE_PORT}
LIVE_PLOT_SECRET_KEY: ${LIVE_PLOT_SECRET_KEY}
COVERAGE_RUN: ${COVERAGE_RUN}
command: /usr/bin/docker-entrypoint.sh
volumes:
- web-static:/var/www/livedata/static
Expand Down Expand Up @@ -61,4 +62,4 @@ services:

volumes:
web-static:
db-data:
db-data:
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ python manage.py createcachetable webcache
python manage.py ensure_adminuser --username=${DJANGO_SUPERUSER_USERNAME} --email='workflow@example.com' --password=${DJANGO_SUPERUSER_PASSWORD}

# run application
gunicorn live_data_server.wsgi:application -w 2 -b :8000 --reload
${COVERAGE_RUN} gunicorn live_data_server.wsgi:application -w 2 -b :8000 --reload
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "LIVE DATA SERVER"
copyright = "2023, SAE@ORNL"
copyright = "2023, SAE@ORNL" # noqa A001
author = "SAE@ORNL"

# The version info for the project you're documenting, acts as replacement for
Expand Down
4 changes: 2 additions & 2 deletions docs/developer/config_for_local_use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Changing it to a wildcard lets us ping it as local host and not get a 400 error.


You should now be able to interact with the api on `localhost:9999` but there's a little more.
You need to add a user that you can use for your post requests,
You need to add a user that you can use for your post requests,

.. code-block:: bash

Expand All @@ -53,7 +53,7 @@ You need to add a user that you can use for your post requests,
I personally recommend using `Postman <https://www.postman.com/>`_ when interacting with the api.
If you do, set the request body to `form-data`!

Some relevant form-data field keys:
Some relevant form-data field keys:

#. file
#. username
Expand Down
3 changes: 0 additions & 3 deletions docs/developer/service_through_apache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@ Apache HTTP Server.
The `Apache configuration file <https://github.com/neutrons/live_data_server/blob/78ef6ad9b237274ac63c69b99d334657ac373633/apache/apache_django_wsgi.conf>`_
is located at ``/etc/httpd/conf.d/apache_django_wsgi.conf``, and the application is located in
``/var/www/livedata/app``.



2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Indices and tables
* :ref:`genindex`
* :ref:`search`

.. uncomment this once we include the API in the docs * :ref:`modindex`
.. uncomment this once we include the API in the docs * :ref:`modindex`
10 changes: 8 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ name: livedata
channels:
- conda-forge
dependencies:
- python=3.6
- python=3.7
- pip
- postgresql=9.5.3
- sphinx
- sphinx_rtd_theme
- django=2.0
- django=2.1
- django-cors-headers
- psycopg2
- gunicorn
- pytest
- build
- versioningit
- toml
- requests<2.31 # can remove this condition once we allow newer versions of openssl
- pre-commit
- coverage
1 change: 0 additions & 1 deletion live_data_server/live_data_server/__init__.py

This file was deleted.

49 changes: 0 additions & 49 deletions live_data_server/plots/migrations/0001_initial.py

This file was deleted.

3 changes: 0 additions & 3 deletions live_data_server/plots/tests.py

This file was deleted.

18 changes: 0 additions & 18 deletions live_data_server/plots/urls.py

This file was deleted.

Loading
Loading