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

chore: add semantic-release action and conventional commit hook #28

Merged
merged 1 commit into from
Jan 29, 2024
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
23 changes: 21 additions & 2 deletions .github/workflows/docs.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/snok/install-poetry
# https://jacobian.org/til/github-actions-poetry/

name: Publish Docs
name: Release Version

on:
push:
Expand Down Expand Up @@ -51,4 +51,23 @@ jobs:
LAKERA_GUARD_API_KEY: ${{ secrets.LAKERA_GUARD_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
poetry run mkdocs gh-deploy --quiet --force
poetry run mkdocs gh-deploy --quiet --force

release:
needs: [publish]
runs-on: ubuntu-latest
concurrency: release

permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Python Semantic Release
uses: python-semantic-release/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 12 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ repos:
name: No mixed line endings (LF and CRLF)
stages: [commit]
- id: no-commit-to-branch
name: Not committing to master
args: [--branch, master]
name: Not committing to main
args: [--branch, main]
stages: [commit]

- repo: https://github.com/psf/black
Expand Down Expand Up @@ -47,3 +47,13 @@ repos:
types: [python]
pass_filenames: false
verbose: true

# conventional commits
- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.6.0
hooks:
- id: conventional-precommit-linter
stages: [commit-msg]
args:
- --types=chore,feat,fix,ci,docs,refactor,revert,test
- --allow-breaking
52 changes: 38 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,67 @@
# Introduction
# Contributing to Lakera Chainguard

Welcome, dear contributor. We are glad you are here. This document will guide you through the process of contributing to this project.

# Project Overview
The package **lakera_chainguard** allows you to secure Large Language Model (LLM) applications and agents built with [LangChain](https://www.langchain.com/) from [prompt injection and jailbreaks](https://platform.lakera.ai/docs/prompt_injection) (and [other risks](https://platform.lakera.ai/docs/api)) with [Lakera Guard](https://www.lakera.ai/).
## Project Overview

The package `lakera_chainguard` allows you to secure Large Language Model (LLM) applications and agents built with [LangChain](https://www.langchain.com/) from [prompt injection and jailbreaks](https://platform.lakera.ai/docs/prompt_injection) (and [other risks](https://platform.lakera.ai/docs/api)) with [Lakera Guard](https://www.lakera.ai/).

## How to Contribute

# How to Contribute
## Guidelines
This project is open to contributions from anyone. We welcome contributions of all kinds. If you want to give feedback, report a bug or request a feature, please open an [issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue). If you want to contribute code or documentation, please submit a pull request on the [GitHub repository](https://github.com/lakeraai/lakera_langchain_integration). We will review your contribution and merge it if it is in line with our goals for the package.

## Style Guide
### Style Guide
We follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide. We use [Black](https://github.com/psf/black) to automatically format our code. We perform static type checking with [mypy](http://mypy-lang.org/).

These requirements are all enforced by our pre-commit hooks. Make sure to follow the instructions below to set them up.

# Contribution Process
### Contribution Process
When contributing, we use the [fork and pull request](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project) procedure.
## Forking the Repository
Fork the GitHub repository of the project.

## Project Setup
### Python
The Python environment management is done via [poetry](https://python-poetry.org/). Any Python-related command must therefore be run using `poetry run <command>`. This will ensure that the correct environment is used. If the environment is not set up, the command will take care of installing all required dependencies, so you don't need to worry about that.

### Documentation
We use [MkDocs](https://www.mkdocs.org/) and [mkdocstrings](https://mkdocstrings.github.io/) to automatically generate a documentation based on the docstrings in the source code. Therefore, it is important to always update the source code's docstrings according to your code changes. To check the updated docs, run `poetry run mkdocs serve` which will serve the documentation on your localhost.
We use [MkDocs](https://www.mkdocs.org/) and [mkdocstrings](https://mkdocstrings.github.io/) to automatically generate documentation based on the docstrings in the source code. Therefore, it is important to always update the source code's docstrings according to your code changes. To check the updated docs, run `poetry run mkdocs serve` which will serve the documentation on your localhost.

We followed [this guide](https://realpython.com/python-project-documentation-with-mkdocs/) to set up the automatic documentation, so look there for inspiration if you want to contribute to the documentation.

### Pre-Commit Hooks
We use [pre-commit](https://pre-commit.com/) to run a series of checks on the code before it is committed. This ensures that the code is formatted correctly, that the tests pass, and that the code is properly typed. To set up the pre-commit/pre-push hooks, run `poetry run pre-commit install` in the root of the repository.

## Submitting a Pull Request
### Commiting Changes

After you've made your changes and updated any necessary tests, you can commit your changes using the following steps:

1. Create a branch from `main` with the `feature/` prefix
```sh
git checkout -b feature/<your-branch-name>
```
2. Make your changes
3. Stage your changes
```sh
git add .
```
4. Commit your changes with a commit message that follows the [Conventional Commits](https://www.conventionalcommits.org/) spec
Here's an example of a valid commit message:

```sh
git commit -m "feat(endpoints): renamed classifiers to endpoints"
```

**Note**: This repo uses `pre-commit` hooks to run [`ruff`](https://github.com/astral-sh/ruff), [`black`](https://github.com/psf/black), and [`isort`](https://github.com/PyCQA/isort) on your code before committing. If any of these checks fail, your commit will be rejected and you will need to stage the changes again and commit them again.
5. Push your `feature/*` branch to your fork
6. Open a [Pull Request](https://github.com/lakeraai/guard-python-sdk/pulls) to the `main` branch from your `feature/*` branch

### Submitting a Pull Request

When you submit a Pull Request, please make sure to include a detailed description of the changes you made, and to reference any issues that are related to the Pull Request. We will review your Pull Request and merge it if it is in line with our goals for the project.

All submitted code must pass our pre-commit hooks and CI pipelines, and must be properly tested. If you are unsure about how to write tests, please ask for help.

# Conclusion
## Acknowledgments
Thanks to all the people who have contributed to this project, and to the people who have inspired us to create it. In particular, thanks to the team at Lakera AI for their positive feedback and support.

## Contact Information
Any questions or comments can be directed to fv (at) lakera (dot) ai.

Open an [Issue](https://github.com/lakeraai/chainguard/issues) or get in touch with `opensource` (at) `lakera.ai`.
Loading