Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
build(poetry): Add a changelog and commit automation library
Browse files Browse the repository at this point in the history
* build(poetry): Add commitizen for commit and changelog automation

* docs: Update CONTRIBUTING and examples documenets

* docs: Add a CHANGELOG document

* Remove precommit

* Move proposals to fdrs folder

* Update related documentation

* Update the changelist document

* Add a runbooks folder. Add change and release documents

* Update README

* Release: 0.1.0a4 → 0.1.0 [skip-ci]

* Update the changelog docu

* Commit docs

* Bump the version
  • Loading branch information
Piotr Katolik authored Mar 6, 2022
1 parent 3c06743 commit f214310
Show file tree
Hide file tree
Showing 22 changed files with 273 additions and 112 deletions.
88 changes: 45 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
hooks:
- id: forbid-crlf
- id: remove-crlf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-added-large-files
- id: check-case-conflict
- id: check-yaml
args: [--unsafe]
- id: debug-statements
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.3
hooks:
- id: isort
args: ['--filter-files']
- repo: https://github.com/ambv/black
rev: 21.9b0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
# Uncomment if you don't want to fail on flake8 validation
args: [--max-line-length, '120']
# verbose: true
additional_dependencies: [flake8-typing-imports==1.11.0]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy
exclude: tests/
additional_dependencies:
- types-toml
# - types-click
default_language_version:
python: python3.9
python: python3.9
repos:
- hooks:
- id: forbid-crlf
- id: remove-crlf
repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
- hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-added-large-files
- id: check-case-conflict
- args:
- --unsafe
id: check-yaml
- id: debug-statements
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
- hooks:
- args:
- --filter-files
id: isort
repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.3
- hooks:
- id: black
repo: https://github.com/ambv/black
rev: 21.9b0
- hooks:
- additional_dependencies:
- flake8-typing-imports==1.11.0
args:
- --max-line-length
- '120'
id: flake8
repo: https://github.com/pycqa/flake8
rev: 4.0.1
- hooks:
- additional_dependencies:
- types-toml
exclude: tests/
id: mypy
repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2022-03-06

### Added

* [Local]: Generate new template function directories for starting new functions. Two types GCP `http`/`pubsub`.
* [Local]: Add an existing **function** to the function registry to be run and deployed as functions native to the package.
* [Local]: Build pre-generated, validated and **locally** existing functions using Docker.
* [Local]: Operate (`deploy`/`remove`) Google Cloud Platform functions from a local machine.
* [Local]: Store information about the built, run and deployed functions locally for reference and configuration.
* [Local]: Print out information about functions and their statuses (Build/Deployed/Running) using the [list](**link to api document**) command.
* [Local]: Log function history using a log file stored on your local device.
* [GCP]: Deploy locally existing functions as cloud functions. Limited to two types - `http` and `pubsub`.
* [GCP]: Delete functions deployed to GCP using this package.

[Unreleased]: https://github.com/katolus/functions/compare/v1.0.0...HEAD
[0.1.0]: https://github.com/katolus/functions/releases/tag/v0.1.0
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ where

Example - `159-gracefully-handle-not-implemented-errors`

## Commits

We are trailing the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#specification), so please adhear to these rules so we can automated our release and changelog processes.

Summary of the rules:

- fix: A bug fix. Correlates with PATCH in SemVer
- feat: A new feature. Correlates with MINOR in SemVer
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing or correcting existing tests
- build: Changes that affect the build system or external dependencies (example - scopes: pip, docker, npm)
- ci: Changes to our CI configuration files and scripts (example scopes: GitLabCI)

## Main branch

Please keep track that we use `development` as our main branch and therefore all contribution should be done towards that branch.

## Pull Request Process

Once you are ready to contribute your changes to the main stream, follow GitHub's [instructions](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) and created a pull request.
Expand Down
60 changes: 25 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,23 @@
[![DeepSource](https://deepsource.io/gh/Katolus/functions.svg/?label=active+issues&show_trend=true&token=NaMzVnONrQ-lLiofAWpYLilG)](https://deepsource.io/gh/Katolus/functions/?ref=repository-badge) [![wakatime](https://wakatime.com/badge/user/cd96c43c-7bc3-4dd9-bc18-9fc894fa15aa/project/99319134-337b-4b51-903b-4c0c3b15084e.svg)](https://wakatime.com/badge/user/cd96c43c-7bc3-4dd9-bc18-9fc894fa15aa/project/99319134-337b-4b51-903b-4c0c3b15084e)

| ! | This package is not ready for `production` use. The API is unstabble as it hasn't been released in any major or minor versions of it yet and is constant development. Use it at your own risk and pleasure. <br><br> **Please read the documentation carefully so there are not surprises to state of this project.** |
| :---: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

<!-- ![Logo]() -->

**Outstanding items before the first release can be viewed under [this](https://github.com/users/Katolus/projects/1) project.**

<!-- * Documentation: <https://Katolus.github.io/functions> -->
* Documentation: <https://katolus.github.io/functions/>
* GitHub: <https://github.com/Katolus/functions>
* PyPI: <https://pypi.org/project/functions-cli/>
* License: [MIT](https://github.com/Katolus/functions/blob/development/LICENSE)

`functions` is a utility package written in Python. It is built to help the developer run, test and deploy FaaS (Function as a Service) resources. Our goal is to combine and simplify efforts required for local and cloud development.
`functions` is a utility package written in Python. It is built to help a developer run, test and deploy FaaS (Function as a Service) resources. Our goal is to combine and simplify efforts required for local and cloud development of serverless resources.

We are using `docker` as a primary technology to build and orchestrate the functions locally.

To deploy them to a cloud provider you need to have relevant software pre-installed.

## Features

The project is still under deep development, and there is still a lot of work to be done even to reach the base quality.
Nonetheless, we believe there is value in using it as it is if it fits your needs and requirements (Python + Linux).
The project is still under deep development, and there is still a lot of work to be done. Nonetheless this project will provide value to people looking to help out or use it while knowing associate risks.

Feedback, issues and request are more than welcome. See how you can [contribute](CONTRIBUTING.md).

Expand All @@ -39,9 +34,9 @@ Here is a list of functionalities that the package is capable of.
* Add an existing function to the function registry to be run and deployed as functions native to the package - [tutorial](docs/examples/add_existing_function.md).
* Build pre-generated, validated and **locally** existing functions using Docker **link to api document**.
* Operate (`deploy`/`remove`) Google Cloud Platform functions from a local machine - [tutorial](docs/examples/http_function.md).
* Store information about the built, run and deployed functions locally for reference and configuration - [proposal](docs/proposals/function_registry.md).
* Store information about the built, run and deployed functions locally for reference and configuration - [proposal](docs/fdrs/function_registry.md).
* Print out information about functions and their statuses (Build/Deployed/Running) using the [list](**link to api document**) command.
* Log function history using a log file stored on your local device - [proposal](docs/proposals/logging.md).
* Log function history using a log file stored on your local device - [proposal](docs/fdrs/logging.md).

### GCP

Expand All @@ -58,13 +53,8 @@ The package is a utility one and it requires underlying software for specific fu

Minimum:

* Python >= `3.8` - for the functioning of the package.
* Python >= `3.9` - as a minimum Python version.
* `docker` - for running any of the functions locally, you will need to [install docker](https://docs.docker.com/engine/install/).

```bash
sudo chmod 666 /var/run/docker.sock
```

* [`poetry`](https://python-poetry.org/docs/#installation) - for running the source code locally and code development you need to have this package in the scope.

For GCP:
Expand All @@ -82,7 +72,7 @@ If you plan of developing or adjust the code or underlying structures make sure

Since it is a regular Python package, available in the main `pypi` repository you can start using it simply by installing the package in your Python environment by running

```bash
```console
pip install functions-cli
```

Expand All @@ -96,16 +86,16 @@ Check out the [local development document](docs/local_development.md) for instru

Regardless if you installed the package from the *pypi* repository or from source code, you should be able to invoke the `functions` tool from your command line. The tool has many different commands that should help you building your serverless functions (surprise, otherwise it would be useless...).

Here are a few core ones to get you started. For a full and a comprehensive description of the `CLI` please refer to the [cli document](docs/cli.md).
Here are a few core ones to get you started. For a full and a comprehensive description of the `CLI` please refer to our [cli documentation]([docs/cli.md](https://katolus.github.io/functions/cli/)).

Keep in mind that the package is in development and all of its structure is a subject to change.
Keep in mind that the package is evolving and all of its structure is a subject to change.

## Creating a new FaaS

The tool allows you to quickly generate a template of a function that you can the modify to quicken your efforts in producing code.

```bash
functions new http {name_of_the_function}
```console
> functions new http {name_of_the_function}
```

will generate you a new `http` like template for your FaaS function in your current directory.
Expand All @@ -114,16 +104,16 @@ will generate you a new `http` like template for your FaaS function in your curr

Before you start working with a function you need make sure it is built and available as a docker image. To do so, run

```bash
functions build {name_of_the_function}
```console
> functions build {name_of_the_function}
```

## Running a function locally

It is great to see what we have created before deploying it to the world. Running...

```bash
functions run {name_of_the_function}
```console
> functions run {name_of_the_function}
```

will start a docker container and expose the function to your locally network on a available port.
Expand All @@ -132,8 +122,8 @@ will start a docker container and expose the function to your locally network on

Please remember that the container will run as long as you leave it for, so make sure to take it down once you have done all your testing. Running...

```bash
functions stop {name_of_the_function}
```console
> functions stop {name_of_the_function}
```

should do the job.
Expand All @@ -146,8 +136,8 @@ Depending what configuration you had set up, you will be able to deploy your pro

For example to deploy a function quickly to GCP as a cloud function you want to run...

```bash
functions gcp deploy {path_to_the_function}
```console
> functions gcp deploy {path_to_the_function}
```

With the correct setup and permissions this should allow you to the deploy a function to the GCP directly from the `functions` cli.
Expand All @@ -156,16 +146,16 @@ With the correct setup and permissions this should allow you to the deploy a fun

This command will remove a function from the local storage, but will not remove the code from the disk.

```bash
functions remove {name_of_the_function}
```console
> functions remove {name_of_the_function}
```

## Installing autocompletion

Core CLI functionality is built on top of [`Typer`](https://github.com/tiangolo/typer) which means that if you want autocompletion in your scripts follow the instructions derived from there.

```bash
functions --install-completion bash
```console
> functions --install-completion bash
```

With respect to the version of shell you are using.
Expand All @@ -174,8 +164,8 @@ With respect to the version of shell you are using.

The tool is built on brilliant software of others. One of them being `typer`. Thanks to the work of others, you can query the CLI for any useful information by adding `--help` to any of your commands.

```bash
functions run --help
```console
> functions run --help
```

If you stumble in to any major issue that is not described in the documentation, send a message or create an issue. We will try to help you as soon as it is possible.
Expand Down
2 changes: 1 addition & 1 deletion docs/adrs/0001_initial_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The code wasn't necessarily clearly contained within a container like the `confi

## List of components

* [`function registry`](../proposals/function_registry.md)
* [`function registry`](../fdrs/function_registry.md)
* `docker`
* `cloud` (GCP, AWS, ...)

Expand Down
12 changes: 6 additions & 6 deletions docs/adrs/0004_architecture_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ It is a tool built using the [typer] library. `functions` wrap existing API and

### Config

We store some additional files on disk in the `config` module for configuration purposes. See related [fdr](../proposals/config.md).
We store some additional files on disk in the `config` module for configuration purposes. See related [fdr](../fdrs/config.md).

### Internal state

Withing the config module, we store:

* configuration for the current use of `functions`.
* [function registry](../proposals/function_registry.md) data.
* [function registry](../fdrs/function_registry.md) data.
* log files.

### Function configuration
Expand All @@ -159,7 +159,7 @@ A source directory for a function is stored in an image built, so if the files a

### Component management

As a modularity attempt, we introduced a concept of [components](../proposals/components_subcommands.md).
As a modularity attempt, we introduced a concept of [components](../fdrs/components_subcommands.md).

There are 2 main components for now

Expand All @@ -170,11 +170,11 @@ Both of them can be accessed via the available `components` command.

### Logging

`functions` produce simple logs for you to view if needed. More info in a related [fdr](../proposals/logging.md) document.
`functions` produce simple logs for you to view if needed. More info in a related [fdr](../fdrs/logging.md) document.

### Exceptions

We created a custom error pattern to manage critical execution cases and handle them unified and funnelled. More info in the exceptions [fdr](../proposals/exceptions.md).
We created a custom error pattern to manage critical execution cases and handle them unified and funnelled. More info in the exceptions [fdr](../fdrs/exceptions.md).

### Docker items

Expand Down Expand Up @@ -216,7 +216,7 @@ We support autocompletion of resources for all the cool users, so they can doubl

### Flows and Actions

In the spirit of avoiding repetition and context focus, we added the concepts of [flows and actions](../proposals/flows_and_actions.md). A pattern for grouping user interactions and unique flows into separate scripts, so other parts of the code use it more easily.
In the spirit of avoiding repetition and context focus, we added the concepts of [flows and actions](../fdrs/flows_and_actions.md). A pattern for grouping user interactions and unique flows into separate scripts, so other parts of the code use it more easily.

This should enhance uniformity and provide a stable interaction experience to a user.

Expand Down
9 changes: 0 additions & 9 deletions docs/change_checklist.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Here are the examples you might use to your use case.

* [Simple `http` function locally](examples/http_function.md).
* [Simple `pubsub` function locally](examples/pubsub_locally.md).
* [Add an existing function to the registry](examples/add_existing_function.md).
* [Deploying a function to GCP](examples/deploying_to_gcp.md).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f214310

Please sign in to comment.