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

Basic project infrastructure #1

Merged
merged 5 commits into from
Mar 24, 2021
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
Empty file added .github/ISSUE_TEMPLATE.md
Empty file.
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?

-----
24 changes: 24 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
categories:
- title: "New Features"
labels:
- "enhancement"
- title: "Maintenance"
labels:
- "maintenance"
- title: "Bug Fixes"
labels:
- "bug"
- title: "Specifications and Documentation"
label:
- "specification"
- "doc"
- title: "Tooling"
label:
- "tooling"
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
Special thanks to the contributors that made this release happen: $CONTRIBUTORS

## Full list of changes

$CHANGES
21 changes: 21 additions & 0 deletions .github/workflows/cla-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: cla-check
on: [pull_request]

jobs:
cla-check:
runs-on: ubuntu-18.04
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install python3-launchpadlib git
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
# ensure we pull PR /head, not autogenerated /merge commit
ref: ${{ github.event.pull_request.head.sha }}
- name: Fetching base ref ${{ github.base_ref }}
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Perform CLA check
run: ./tools/cla-check.py "${{ github.base_ref }}..HEAD"
66 changes: 66 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Tests

on:
pull_request:
push:
branches:
- main
jobs:
tests:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Add local bin to PATH
run: |
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Install python package and dependencies
run: |
sudo apt install -y python3-pip python3-venv libapt-pkg-dev
python3 -m venv ${HOME}/.venv
source ${HOME}/.venv/bin/activate
pip install -U pip wheel setuptools
pip install -U -r requirements.txt -r requirements-dev.txt
pip install -e .
- name: Run black
run: |
source ${HOME}/.venv/bin/activate
make test-black
- name: Run codespell
run: |
source ${HOME}/.venv/bin/activate
make test-codespell
- name: Run flake8
run: |
source ${HOME}/.venv/bin/activate
make test-flake8
- name: Run isort
run: |
source ${HOME}/.venv/bin/activate
make test-isort
- name: Run mypy
run: |
source ${HOME}/.venv/bin/activate
make test-mypy
- name: Run pydocstyle
run: |
source ${HOME}/.venv/bin/activate
make test-pydocstyle
- name: Run pyright
run: |
sudo apt install -y npm
sudo npm install -g pyright
source ${HOME}/.venv/bin/activate
make test-pyright
- name: Run unit tests
run: |
source ${HOME}/.venv/bin/activate
make test-units
- name: Run integration tests
run: |
source ${HOME}/.venv/bin/activate
make test-integrations
- name: Upload code coverage
uses: codecov/codecov-action@v1
114 changes: 114 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# 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/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# IDE settings
.vscode/

# direnv
.direnv
.envrc

# Lifecycle
parts/
stage/
prime/
105 changes: 105 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
.PHONY: help
help: ## Show this help.
@printf "%-30s %s\n" "Target" "Description"
@printf "%-30s %s\n" "------" "-----------"
@fgrep " ## " $(MAKEFILE_LIST) | fgrep -v grep | awk -F ': .*## ' '{$$1 = sprintf("%-30s", $$1)} 1'

.PHONY: autoformat
autoformat: ## Run automatic code formatters.
isort .
autoflake --remove-all-unused-imports --ignore-init-module-imports -ri .
black .

.PHONY: clean
clean: ## Clean artifacts from building, testing, etc.
rm -rf build/
rm -rf dist/
rm -rf .eggs/
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -f {} +
rm -rf docs/_build/
rm -f docs/craft_parts.*
rm -f docs/modules.rst
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
rm -rf .tox/
rm -f .coverage
rm -rf htmlcov/
rm -rf .pytest_cache

.PHONY: coverage
coverage: ## Run pytest with coverage report.
coverage run --source craft_parts -m pytest
coverage report -m
coverage html

.PHONY: docs
docs: ## Generate documentation.
rm -f docs/craft_parts.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ craft_parts --no-toc --ext-githubpages
$(MAKE) -C docs clean
$(MAKE) -C docs html

.PHONY: dist
dist: clean ## Build python package.
python setup.py sdist
python setup.py bdist_wheel
ls -l dist

.PHONY: install
install: clean ## Install python package.
python setup.py install

.PHONY: lint
lint: test-black test-codespell test-flake8 test-isort test-mypy test-pydocstyle test-pyright test-pylint ## Run all linting tests

.PHONY: release
release: dist ## Release with twine.
twine upload dist/*

.PHONY: test-black
test-black:
black --check --diff .

.PHONY: test-codespell
test-codespell:
codespell .

.PHONY: test-flake8
test-flake8:
flake8 .

.PHONY: test-integrations
test-integrations: ## Run integration tests.
pytest tests/integration

.PHONY: test-isort
test-isort:
isort --check craft_parts tests

.PHONY: test-mypy
test-mypy:
mypy craft_parts tests

.PHONY: test-pydocstyle
test-pydocstyle:
pydocstyle craft_parts

.PHONY: test-pylint
test-pylint:
pylint --fail-under=9.0 craft_parts
pylint tests --fail-under=9.0 --disable=invalid-name,missing-module-docstring,missing-function-docstring,redefined-outer-name,no-self-use,duplicate-code,protected-access,too-few-public-methods

.PHONY: test-pyright
test-pyright:
pyright .

.PHONY: test-units
test-units: ## Run unit tests.
pytest tests/unit

.PHONY: tests
tests: lint test-units test-integrations ## Run all tests.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Craft Parts

Craft-parts provides a mechanism to obtain data from different sources,
process it in various ways, and prepare a filesystem subtree suitable for
deployment. The components used in its project specification are called
*parts*, which can be independently downloaded, built and installed, and
also depend on each other in order to assemble the subtree containing the
final artifacts.
19 changes: 19 additions & 0 deletions craft_parts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright 2021 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Craft a project from several parts."""

__version__ = "0.0.1" # noqa: F401
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
craft_parts.rst
craft_parts.*.rst
modules.rst
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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 = .
BUILDDIR = _build

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

.PHONY: help 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)
Loading