Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Dec 23, 2022
0 parents commit 6ddc082
Show file tree
Hide file tree
Showing 18 changed files with 739 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/scripts/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

DT=${2:-${RETRY_TIME:-5m}}
MAX=${3:-${MAX_RETRIES:-3}}

for N in `seq 1 $MAX`; do
echo "Attempt $N/$MAX: $1"
eval $1;
RESULT=$?
if [[ $RESULT -eq 0 ]]; then
exit 0
fi
if [[ $N -lt $MAX ]]; then
echo "Failed attempt $N/$MAX. Waiting $DT"
sleep $DT
else
echo "Failed attempt $N/$MAX."
exit $RESULT
fi
done
46 changes: 46 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: check
on:
push:
branches:
- main
- master
- develop
- 'feature/**'
env:
PROJECT_NAME: my_project
WORKFLOW: check
jobs:
run-unit-tests:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
runs-on: ${{ matrix.os }}
name: Run tests on Python ${{ matrix.python-version }}, on ${{ matrix.os }}
timeout-minutes: 45
concurrency:
group: ${{ github.workflow }}-run-unit-tests-${{ matrix.python-version }}-${{ matrix.os }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Checkout code
uses: actions/checkout@v3

- name: Restore Python dependencies
run: |
pip install -r requirements.txt
- name: Test
run: python -m unittest discover -s test -t .
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: deploy
on:
workflow_run:
workflows:
- check
types:
- completed
branches:
- master
- main
- develop
env:
PROJECT_NAME: my_project
WORKFLOW: deploy
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Deploy on PyPI and create release
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # all history

- name: Get All Tags
run: git fetch --tags -f

- name: Get Python Version
id: get-python-version
run: echo ::set-output name=version::$(cat .python-version)

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ steps.get-python-version.outputs.version }}

- name: Restore Python dependencies
run: pip install -r requirements.txt

- name: Change default logging level
run: sed -i -e 's/DEBUG/WARN/g' my_project/__init__.py

- name: Pack
run: python -m build

- name: Archive Dist Artifacts
if: failure() || success()
uses: actions/upload-artifact@v2
with:
name: dist
path: './dist'

- name: Upload
run: python -m twine upload dist/*
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

- name: Get Version
id: get-version
run: echo ::set-output name=version::$(python setup.py get_project_version | tail -n 1)

- name: Release Assets
id: upload-release-assets
run: |
set -x
ASSETS=()
for A in dist/*; do
ASSETS+=("-a" "$A")
echo "Releasing $A"
done
RELEASE_TAG='${{ steps.get-version.outputs.version }}'
hub release create "${ASSETS[@]}" -m "$RELEASE_TAG" "$RELEASE_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/dockerify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: dockerify
on:
workflow_run:
workflows:
- deploy
types:
- completed
branches:
- main
- master
- develop
env:
PROJECT_NAME: my_project
WORKFLOW: dockerify
RETRY_TIME: 5m
MAX_RETRIES: 3
jobs:
dockerify:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Dockerify with Jupyter support
steps:
- name: Docker Login
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # all history
submodules: recursive

- name: Get All Tags
run: git fetch --tags -f

- name: Get Version
id: get-version
run: echo ::set-output name=version::$(python setup.py get_project_version | tail -n 1)

- name: Create Docker Image
run: ./.github/scripts/retry.sh "docker build -t aequitas-aod/$PROJECT_NAME:$VERSION --build-arg VERSION=$VERSION ."
shell: bash
env:
VERSION: '${{ steps.get-version.outputs.version }}'

- name: Push Image on Docker Hub
run: docker push pikalab/$PROJECT_NAME:${{ steps.get-version.outputs.version }}
16 changes: 16 additions & 0 deletions .github/workflows/todos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "TODOs finder"
on:
push:
branches-ignore:
- 'autodelivery**'
- 'bump-**'
- 'renovate/**'
- 'dependabot/**'
jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@master"
- name: "TODO to Issue"
uses: "alstr/[email protected]"
id: "todo"
142 changes: 142 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
VERSION

tmp/
.idea/
.vscode/
.DS_Store
*.data
demo/

*~
*.jar

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.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
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# 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

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

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

# Pyre type checker
.pyre/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.1
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:latest
ARG VERSION
EXPOSE 8888
RUN apt update; apt install -y -q openjdk-17-jdk
RUN pip install jupyter
RUN pip install my_project==$VERSION
RUN mkdir -p /root/.jupyter
ENV JUPYTER_CONF_FILE /root/.jupyter/jupyter_notebook_config.py
RUN echo "c.NotebookApp.allow_origin = '*'" > $JUPYTER_CONF_FILE
RUN echo "c.NotebookApp.ip = '0.0.0.0'" >> $JUPYTER_CONF_FILE
RUN mkdir -p /notebook
WORKDIR /notebook
CMD jupyter notebook --allow-root --no-browser
Loading

0 comments on commit 6ddc082

Please sign in to comment.