Skip to content

Commit

Permalink
Docker Build (#25)
Browse files Browse the repository at this point in the history
* made it build

* Added Dockerfile and surrounding things

* Update inotify_script.sh

* forgot a bracket

* Cron Folder was wrong, added some protection for sim processing

* added logging and fixed a script typo

* added docker builder

* autopep8 action fixes

* Added Tests back in, and audio file (#27)

* Added Tests back in, and audio file

* autopep8 action fixes

* changed test code

* autopep8 action fixes

* run, not command

Co-authored-by: Emersont1 <[email protected]>

* moved to bash for a painless redirect

* Removed egg-info
fixed #25 (comment)

* Added to poetry file

* autopep8 action fixes (#30)

Co-authored-by: Emersont1 <[email protected]>

Co-authored-by: Emersont1 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 9, 2022
1 parent a6c5e9d commit 99bf7ee
Show file tree
Hide file tree
Showing 27 changed files with 369 additions and 70 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: ci

on:
schedule:
- cron: '0 10 * * *' # everyday at 10am
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/urn/hstp
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Test
on: [push]
jobs:
Expand All @@ -7,6 +8,8 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Test
uses: onichandame/python-test-action@master
python-version: '3.8'
- name: install hstp
run: pip install .
- name: test
run: python -m unittest
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
venv
__pycache__
__ignore__
__ignore__
build
dist
*.egg-info
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.8-alpine

RUN apk add inotify-tools bash

COPY /docker/cron_script.sh /docker/inotify_script.sh /bin/
COPY /docker/build.crontab /etc/crontabs/root

COPY . /build

RUN pip install /build

CMD ["/bin/inotify_script.sh"]
5 changes: 4 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ This repository contains both the specification for the HSTP format and a refere
+ **Any** Changes to the specification file (excluding spelling or wording), should require an increase in the version number
+ Releases of the reference implementation, these should be tagged in the github
+ The Major release should correspond with the standard
+ The Minor release should be the patch number
+ The Minor release should be the patch number

## 3rd party content
+ `tests/data/audio.mp3` is "Danse Macabre" by Kevin MacLeod (incompetech.com). Licensed under Creative Commons: Attribution 4.0 License http://creativecommons.org/licenses/by/4.0/
22 changes: 0 additions & 22 deletions audioboom/downloader/__main__.py

This file was deleted.

8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.0'
services:
build-files:
build: .
volumes:
- ./input:/input
- ./out:/output
- ./log:/log
1 change: 1 addition & 0 deletions docker/build.crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/10 * * * * /bin/cron_script.sh
13 changes: 13 additions & 0 deletions docker/cron_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash

if [ -e /changed ]; then
timeSinceMod=$(($(date +%s) - $(date +%s -r /changed)))
if [ $timeSinceMod -gt 600 ]; then
if [ ! -e /active ]; then
touch /active
date >> /log
python -m hstp -i /input -o /output &>> /log
rm /changed /active
fi
fi
fi
8 changes: 8 additions & 0 deletions docker/inotify_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/sh

crond

inotifywait -m /input -r |
while read directory action file; do
touch /changed
done
35 changes: 0 additions & 35 deletions hstp/__main__.py

This file was deleted.

156 changes: 156 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tool.poetry]
name = "hstp"
version = "2.0.0"
description = "hstp build"
authors = ["University Radio Nottingham <[email protected]>"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.8"
lxml = "4.6.4"
mutagen = "1.45.1"
pep8 = "1.7.1"
pycodestyle = "2.7.0"
python-dateutil = "2.8.2"
simple-colors = "0.1.5"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.plugins."console_scripts"]
"hstp" = "hstp.__main__:main"
"audioboom-download" = "audioboom.downloader.__main__:main"
Loading

0 comments on commit 99bf7ee

Please sign in to comment.