Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Jul 4, 2022
0 parents commit 03188e1
Show file tree
Hide file tree
Showing 15 changed files with 2,426 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
# line length is intentionally set to 80 here because we use flake8-bugbear
# See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length for more details
max-line-length = 80
select = B,C,E,F,W,B950
extend-ignore = E203, E501
58 changes: 58 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CD

on:
push:
tags:
- v*

permissions:
contents: read

env:
FORCE_COLOR: "1" # Make tools pretty.
PYTHON_LATEST: "3.10"

jobs:
ci:
uses: ./.github/workflows/ci.yml

deploy-pypi:
needs: [ci]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_LATEST }}

- run: python -m pip install build twine
- run: python -m build --sdist --wheel .

- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

deploy-ghcr:
needs: [ci]
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: |
ghcr.io/roche/foxops:latest
ghcr.io/roche/foxops:${{ github.ref_name }}
200 changes: 200 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
workflow_call:

env:
FORCE_COLOR: "1" # Make tools pretty.
PYTHON_LATEST: "3.10"
POETRY_VIRTUALENVS_CREATE: false


jobs:
linting:
name: Linting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_LATEST }}

- name: Install dependencies
run: |
python -VV
python -m site
python -m pip install --upgrade pip poetry poetry-dynamic-versioning
# NOTE: we are unable to solely rely on pip because poetry doesn't export the dev dependencies
# as extras nor is it able to install ONLY the dev dependencies ...
python -m poetry install
- name: black
run: python -m black --check --diff .

- name: flake8
run: python -m flake8 .

- name: isort
run: python -m isort --check-only -v --profile black .

typing:
name: Typing
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_LATEST }}

- name: Install dependencies
run: |
python -VV
python -m site
python -m pip install --upgrade pip poetry poetry-dynamic-versioning
# NOTE: we are unable to solely rely on pip because poetry doesn't export the dev dependencies
# as extras nor is it able to install ONLY the dev dependencies ...
python -m poetry install
- name: mypy
run: python -m mypy .


tests:
name: pytest on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -VV
python -m site
python -m pip install --upgrade pip poetry poetry-dynamic-versioning
# NOTE: we are unable to solely rely on pip because poetry doesn't export the dev dependencies
# as extras nor is it able to install ONLY the dev dependencies ...
python -m poetry install
- run: python -m pytest
env:
COVERAGE_FILE: .coverage.${{ matrix.python-version }}

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore


coverage:
name: Combine & check coverage
runs-on: ubuntu-latest
needs: tests

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
# Use latest Python, so it understands all syntax.
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install --upgrade coverage[toml]
- uses: actions/download-artifact@v3
with:
name: coverage-data
- name: Combine coverage & fail if it's <70%.
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=70
- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov


package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_LATEST }}

- run: python -m pip install build twine check-wheel-contents
- run: python -m build --sdist --wheel .
- run: ls -l dist
- run: check-wheel-contents dist/*.whl
- name: Check long_description
run: python -m twine check dist/*

container:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: false
tags: |
ghcr.io/Roche/foxops:latest
ghcr.io/Roche/foxops:${{ github.ref_name }}
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_LATEST }}

- run: python -m pip install poetry poetry-dynamic-versioning
- run: python -m poetry install
- run: make -C docs html

- uses: actions/upload-artifact@v1
with:
name: DocumentationHTML
path: docs/build/html/


install-dev:
name: Verify dev env
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_LATEST }}
- run: python -m pip install -e .
- run: python -c 'import foxops; print(foxops.__version__)'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.python-version
__pycache__/
dist/
.coverage*
docs/build/
24 changes: 24 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.10"
jobs:
pre_create_environment:
- asdf plugin add poetry
- asdf install poetry latest
- asdf global poetry latest
- poetry config virtualenvs.create false
post_install:
- poetry install

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM python:3.10-alpine

RUN echo "Hello"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# foxops

coming soon, stay tuned! 🦊
23 changes: 23 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help live Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

live:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)"
Loading

0 comments on commit 03188e1

Please sign in to comment.