-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Phillip Wenig <phillip.wenig@frequenz.com>
- Loading branch information
1 parent
105813d
commit 3aaedba
Showing
17 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Rust CI | ||
|
||
on: | ||
push: | ||
branches: [ v0.x.x ] | ||
pull_request: | ||
merge_group: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Fetch sources | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Run tests | ||
uses: frequenz-floss/gh-action-cargo-test@v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Based on https://github.com/hyperledger/besu/pull/5207/files | ||
name: DCO | ||
on: | ||
merge_group: | ||
|
||
jobs: | ||
DCO: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
steps: | ||
- run: echo "This DCO job runs on merge_queue event and doesn't check PR contents" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Release Notes Check | ||
|
||
on: | ||
merge_group: | ||
pull_request: | ||
types: | ||
# On by default if you specify no types. | ||
- "opened" | ||
- "reopened" | ||
- "synchronize" | ||
# For `skip-label` only. | ||
- "labeled" | ||
- "unlabeled" | ||
|
||
|
||
jobs: | ||
check-release-notes: | ||
name: Check release notes are updated | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
steps: | ||
- name: Check for a release notes update | ||
if: github.event_name == 'pull_request' | ||
uses: brettcannon/check-for-changed-files@871d7b8b5917a4f6f06662e2262e8ffc51dff6d1 # v1.2.1 | ||
with: | ||
file-pattern: "RELEASE_NOTES.md" | ||
prereq-pattern: "src/**" | ||
skip-label: "cmd:skip-release-notes" | ||
failure-message: "Missing a release notes update. Please add one or apply the ${skip-label} label to the pull request" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.python-version | ||
|
||
|
||
# Added by cargo | ||
|
||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "frequenz-{{project_name}}" | ||
description = "{{project_description}}" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Frequenz Energy-as-a-Service GmbH"] | ||
{% if open_source %} | ||
license = "MIT" | ||
{% else %} | ||
license = "proprietary" | ||
{% endif %} | ||
|
||
{% if project_type == "lib" %} | ||
[lib] | ||
name = "frequenz_{{project_name | replace("-", "_")}}" | ||
path = "src/lib.rs" | ||
{% if python %} | ||
crate-type = ["cdylib", "rlib"] | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% if python %} | ||
[features] | ||
python = ["pyo3"] | ||
{% endif %} | ||
|
||
[dependencies] | ||
{% if python %} | ||
pyo3 = { version = "0.22", features = ["extension-module"], optional = true } | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% if open_source %} | ||
MIT License | ||
|
||
Copyright (c) 2024 Frequenz Open Source | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
{% else %} | ||
Proprietary License | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
# frequenz-copier-rs | ||
|
||
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier) | ||
|
||
An opinionated Copier template to create Frequenz rust projects | ||
|
||
## How to copy this template | ||
|
||
1. Install [Copier](https://copier.readthedocs.io/en/stable/#installation) | ||
2. Run `copier copy https://github.com/frequenz-floss/frequenz-copier-rs.git path/to/destination` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Frequenz {{project_name | replace("-", " ")}} | ||
|
||
{{project_description}} | ||
|
||
{% if python %} | ||
## Python Bindings | ||
|
||
The [Makefile](./Makefile) contains targets to build and install Python wheels | ||
in the currently active Python environment. | ||
|
||
### Building | ||
|
||
To build the wheels, run: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
This will install the required dependencies from | ||
[requirements.txt](./requirements.txt), build the wheel, | ||
and store it in the [./wheels](./wheels) directory. | ||
|
||
### Installing | ||
|
||
To install the project directly to the currently active Python environment, run: | ||
|
||
```bash | ||
make install | ||
``` | ||
|
||
This will build the wheel and then install it using `pip`. | ||
|
||
### Deploying | ||
|
||
To deploy the wheels to a PyPI repository, run: | ||
|
||
```bash | ||
make deploy | ||
``` | ||
|
||
This will upload the wheels in the [./wheels](./wheels) directory to the PyPI | ||
repository. | ||
|
||
### Cleaning | ||
|
||
To clean the project directory, run: | ||
|
||
```bash | ||
make clean | ||
``` | ||
|
||
This will remove the [./wheels](./wheels) directory and any build artifacts. | ||
Additionally, it will uninstall the project and its dependencies from the currently active Python | ||
environment. | ||
|
||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
project_name: | ||
type: str | ||
help: What is your project name? | ||
|
||
project_description: | ||
type: str | ||
help: What is your project description? | ||
|
||
open_source: | ||
type: bool | ||
default: false | ||
help: Is your project open source? | ||
|
||
project_type: | ||
type: str | ||
help: What type of project are you creating? | ||
choices: | ||
- lib | ||
- bin | ||
|
||
python: | ||
type: bool | ||
when: "{% if project_type == 'lib' %}true{% endif %}" | ||
default: false | ||
help: Do you want to create Python bindings for your project? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// License: MIT | ||
// Copyright © 2024 Frequenz Energy-as-a-Service GmbH | ||
|
||
fn main() { | ||
println!("Hello, world from {{project_name}}!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// License: MIT | ||
// Copyright © 2024 Frequenz Energy-as-a-Service GmbH | ||
|
||
{% if python %} | ||
#[cfg(feature="python")] | ||
mod python; | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// License: MIT | ||
// Copyright © 2024 Frequenz Energy-as-a-Service GmbH | ||
|
||
use pyo3::prelude::*; | ||
|
||
|
||
#[pyfunction] | ||
fn hello_world() -> PyResult<String> { | ||
Ok("Hello world!".to_string()) | ||
} | ||
|
||
|
||
#[pymodule] | ||
fn frequenz_{{project_name | replace("-", "_")}}(m: &Bound<'_, PyModule>) -> PyResult<()> { | ||
m.add_function(wrap_pyfunction!(hello_world, m)?)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// License: MIT | ||
// Copyright © 2024 Frequenz Energy-as-a-Service GmbH | ||
|
||
#[test] | ||
fn test_fails() { | ||
assert_eq!(1, 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: help | ||
help: ## Generate list of targets with descriptions | ||
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | ||
| sed -n 's/^\(.*\): \(.*\)##\(.*\)/\1~\3/p' \ | ||
| column -t -s "~" | ||
|
||
.PHONY: install | ||
install: build ## Build and install frequenz_{{project_name | replace("-", "_")}} to the current Python environment | ||
cd wheels && pip install --force-reinstall -U frequenz_{{project_name | replace("-", "_")}}-*.whl && cd .. | ||
|
||
.PHONY: build | ||
build: ## Build frequenz_{{project_name | replace("-", "_")}} Python package | ||
@pip install -r requirements.txt | ||
@maturin build --release --features python -o wheels -i $$(which python) | ||
|
||
.PHONY: clean | ||
clean: ## Uninstall frequenz_{{project_name | replace("-", "_")}} and its requirements and delete wheels | ||
pip uninstall -y frequenz_{{project_name | replace("-", "_")}} | ||
pip uninstall -y -r requirements.txt | ||
rm -r ./wheels | ||
|
||
.PHONY: deploy | ||
deploy: ## Upload frequenz_{{project_name | replace("-", "_")}} wheels to PYPI | ||
maturin upload ./wheels/frequenz_{{project_name | replace("-", "_")}}-*.whl |
1 change: 1 addition & 0 deletions
1
{% if python %}frequenz_{{project_name | replace("-", "_")}}{% endif %}/__init__.py.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .frequenz_{{project_name | replace("-", "_")}} import hello_world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
maturin==1.7.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Changes here will be overwritten by Copier | ||
{{ _copier_answers|to_nice_yaml -}} |