Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
* feat: setup repo

* feat: add missing files to repo

* chore: some cleanup

* ci: initial commit

* ci: update to ubuntu github hosted

* chore: add convential commit hook

* fix(ci): missing dollar

* fix(pre-commit): invalid values in hooks

* fix(ci): missing python version cache key for deps

* fix: minimum python version in pyproject

* chore: poetry lock

* chore(ci): do not install dev dependencies

* test(ci): remove python 3.8

* test(ci): remove alpine containers

* test(ci): experiment with junit report

* fix(ci): fix bad names

* fix(ci): missing install python

* chore: update README

* chore: clean up gitignore

* docs: use README from serverless go

* docs: add contributing from serverless go

* docs: update contributing

* docs: readme remove duplicated sections

* docs: update readme

* refactor: apply review suggestions

* chore: delete docs folder
  • Loading branch information
cyclimse authored Feb 28, 2023
1 parent c53004c commit 721e276
Show file tree
Hide file tree
Showing 20 changed files with 1,586 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
per-file-ignores =
**/__init__.py: F401
extend-ignore =
# See: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html
E203,
# Commented Black formatted code
max-line-length = 89
76 changes: 76 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
82 changes: 82 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Contribute to `serverless-functions-python`

## Topics

- [Contribute to `serverless-functions-python`](#contribute-to-serverless-functions-python)
- [Topics](#topics)
- [Reporting security issues](#reporting-security-issues)
- [Reporting issues](#reporting-issues)
- [Suggesting a feature](#suggesting-a-feature)
- [Contributing code](#contributing-code)
- [Submit code](#submit-code)
- [Pull Request Guidelines](#pull-request-guidelines)
- [Community Guidelines](#community-guidelines)

## Reporting security issues

At Scaleway we take security seriously. If you have any issues regarding security,
please notify us by sending an email to [email protected].

Please DO NOT create a GitHub issue.

We will follow up with you promptly with more information and a remediation plan.
We currently do not offer a paid security bounty program, but we would love to send some
Scaleway swag your way along with our deepest gratitude for your assistance in making
Scaleway a more secure Cloud ecosystem.

## Reporting issues

A great way to contribute to the project is to send a detailed report when you encounter a bug.
We always appreciate a well-written, thorough bug report, and will thank you for it!
Before opening a new issue, we appreciate you reviewing open issues to see if there are any similar requests.
If there is a match, thumbs up the issue with a 👍 and leave a comment if you have additional information.

When reporting an issue, please include the PyPI version number of `scaleway-functions-python` that you are using.

## Suggesting a feature

When requesting a feature, some of the questions we want to answer are:

- What value does this feature bring to end users?
- How urgent is the need (nice to have feature or need to have)?
- Does this align with the goals of this library?

## Contributing code

### Submit code

To submit code:

- Create a fork of the project
- Create a topic branch from where you want to base your work (usually main)
- Add tests to cover contributed code
- Push your commit(s) to your topic branch on your fork
- Open a pull request against `serverless-functions-python` `main` branch that follows [PR guidelines](#pull-request-guidelines)

The maintainers of `serverless-functions-python` use a "Let's Get This Merged" (LGTM) message in the pull request to note that the commits are ready to merge.
After one or more maintainer states LGTM, we will merge.
If you have questions or comments on your code, feel free to correct these in your branch through new commits.

### Pull Request Guidelines

The goal of the following guidelines is to have Pull Requests (PRs) that are fairly easy to review and comprehend, and code that is easy to maintain in the future.

- **Pull Request title should respect [conventional commits](https://www.conventionalcommits.org/en/v1.0.0) specifications** and be clear on what is being changed.
- A fix for local testing will be titled `fix(local-testing): ...`
- A fix for http requests will be titled `fix(http): ...`

- **Keep it readable for human reviewers** and prefer a subset of functionality (code) with tests and documentation over delivering them separately

- **Notify Work In Progress PRs** by prefixing the title with `[WIP]`
- **Please, keep us updated.**
We will try our best to merge your PR, but please notice that PRs may be closed after 30 days of inactivity.

Your pull request should be rebased against the `main` branch.

Keep in mind only the **pull request title** will be used as the commit message as we stash all commits on merge.

## Community Guidelines

See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).

Thank you for reading through all of this, if you have any questions feel free to [reach us](../README.md#💜-reach-us)!
37 changes: 37 additions & 0 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Set up poetry
description: Install poetry and python dependencies
inputs:
groups:
description: "Poetry dependencies groups."
required: true
python-version:
description: "Python version."
required: true
runs:
using: "composite"
steps:
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ inputs.python-version }}-v1

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
if: steps.cached-poetry.outputs.cache-hit != 'true'

- name: Cache Poetry dependencies
id: cache-poetry-deps
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ inputs.groups }}

- name: Install Poetry dependencies
shell: bash
run: poetry install --no-interaction --no-root --only main,${{ inputs.groups }}
if: steps.cache-deps.outputs.cache-hit != 'true'
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: 2
updates:
- package-ecosystem: github-actions
# Workflow files stored in the default location of `.github/workflows`
directory: /
schedule:
interval: weekly
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
52 changes: 52 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: pytest

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
test:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
uses: ./.github/actions/setup-poetry
with:
groups: test
python-version: ${{ matrix.python-version }}

- name: Print versions
run: |
python --version
poetry --version
- name: Test with pytest
working-directory: tests
run: poetry run pytest --junitxml=junit/test-results-${{ matrix.python-version
}}.xml

- name: Upload pytest report
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.python-version }}
path: tests/junit/test-results-${{ matrix.python-version }}.xml
retention-days: 3
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
34 changes: 34 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---

name: python-publish

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up python 3.11
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Set up Poetry
uses: ./.github/actions/setup-poetry
with:
groups: '' # will only install the main group
python-version: '3.11'

- name: Publish package
run: poetry publish --build
env:
POETRY_HTTP_BASIC_PYPI_USERNAME: __token__
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: report

on:
workflow_run:
workflows: [pytest]
types: [completed]

permissions:
checks: write

jobs:
checks:
runs-on: ubuntu-22.04
steps:
- name: Download Test Report
uses: dawidd6/action-download-artifact@v2
with:
name: junit-test-results
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
with:
commit: ${{github.event.workflow_run.head_sha}}
report_paths: tests/junit/test-results-*.xml
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Reference: https://github.com/github/gitignore/blob/main/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/

# Distribution / packaging
dist/

# Unit test / coverage reports
.coverage
.cache
.pytest_cache/

# mypy
.mypy_cache/
Loading

0 comments on commit 721e276

Please sign in to comment.