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

pre-commit #11

Merged
merged 11 commits into from
Nov 3, 2023
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
39 changes: 39 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,43 @@ strict_env
direnv_version '2.32.3'


COLOR_MAGENTA="\033[1;35m"

FORMAT_BOLD="\033[1m"
FORMAT_NONE="\033[0m"

MSG_INFO="${FORMAT_BOLD}${COLOR_MAGENTA}info:${FORMAT_NONE}"

msg_info()
{
printf '%b %s\n' "$MSG_INFO" "$1"
}


use flake


export VIRTUAL_ENV=$(expand_path .venv)

if [ ! -d "$VIRTUAL_ENV" ]; then
msg_info "creating \`$VIRTUAL_ENV\` because it doesn't seem to exist"

python -m venv "$VIRTUAL_ENV"
fi

if [ -n "${FISH_VERISON-}" ]; then
. "$VIRTUAL_ENV/bin/activate.fish"
else
. "$VIRTUAL_ENV/bin/activate"
fi

if [ ! -f "$VIRTUAL_ENV/.requirements-installed" ]; then
msg_info 'installing python requirements since they seem to be missing'

pip install -r 'requirements.txt'

touch "$VIRTUAL_ENV/.requirements-installed"
fi


pre-commit install
21 changes: 21 additions & 0 deletions .github/actions/checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

name: checkout ember

runs:
using: composite

steps:
- uses: actions/[email protected]
with:
key: dependencies
path: |
.venv

- uses: DeterminateSystems/nix-installer-action@v6

- uses: DeterminateSystems/magic-nix-cache-action@v2

- uses: HatsuneMiku3939/[email protected]
with:
direnvVersion: 2.32.3
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

name: pre-commit

# yamllint disable-line rule:truthy
on:
- pull_request
- push

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Checkout `ember`
uses: ./.github/actions/checkout

- name: Run `pre-commit` hooks
run: pre-commit run --show-diff-on-failure --color=always
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.egg-info
.direnv
.venv
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# See https://pre-commit.com for more information

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
args:
- --wrap
- '72'
exclude: LICENSE\.md
additional_dependencies:
- mdformat-gfm

- repo: https://github.com/nix-community/nixpkgs-fmt
rev: v1.3.0
hooks:
- id: nixpkgs-fmt

- repo: https://github.com/lyz-code/yamlfix
rev: 1.13.0
hooks:
- id: yamlfix

- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
hooks:
- id: yamllint
6 changes: 6 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

extends: default

ignore-from-file:
- .gitignore
1 change: 0 additions & 1 deletion ember-bltools/ember_bltools.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
bool ember_bltools_set_boot_partition_to_factory();

#endif

1 change: 0 additions & 1 deletion ember-tasking/ember_tasking.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ void ember_tasking_begin(void) {
void ember_tasking_set_1sec_watchdog(void) {
set_up_rtc_watchdog(1000);
}

2 changes: 1 addition & 1 deletion ember-tasking/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ void set_up_rtc_watchdog_final()
void set_up_rtc_watchdog_1sec()
{
set_up_rtc_watchdog(FW_UPDATE_TIMEOUT_MS);
}
}
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
inherit system;
};

python = pkgs.python311;

in
{
devShells.default = pkgs.mkShell {
packages = [
pkgs.act
pkgs.nixpkgs-fmt
python
];
};
}
Expand Down
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ['setuptools']
build-backend = 'setuptools.build_meta'

[project]
name = 'ember'
description = 'simple rate-based multitasking and core libraries for microcontrollers'
version = '0.0.0'

authors = [
{name = 'Ember Developers'},
]
license = {'text' = 'GPL-3.0-only'}

requires-python = '>=3.11'
dependencies = [
'mdformat-gfm',
'pip-tools',
'pre-commit',
'yamlfix',
'yamllint',
]

[project.urls]
repo = 'https://github.com/CooperUnion/ember'

[tool.pip-tools]
allow-unsafe = true
generate-hashes = true
strip-extras = false
upgrade = true
verbose = true

[tool.setuptools.packages.find]
exclude = ['*']

[tool.yamlfix]
none_representation = '~'
section_whitelines = 1
sequence_style = 'block_style'
whitelines = 1
Loading