Skip to content

Commit

Permalink
feat: polish ci (#3)
Browse files Browse the repository at this point in the history
* feat: ci fixes

---------

Co-authored-by: A.Shpak <aleksander.shpak.als@gmail.com>
  • Loading branch information
shpaker and A.Shpak authored Mar 4, 2024
1 parent e9bfb98 commit 43f85bd
Show file tree
Hide file tree
Showing 16 changed files with 372 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# maturin generate-ci github
#
name: CI
name: BUILD

on:
push:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: TESTS

on:
pull_request:
branches:
- main
- master

jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/checkout@v3
- run: |
python -m pip install poetry~=1.8.2
poetry install --no-root --no-ansi --with tests
poetry run maturin develop
- run:
poetry run pytest -v test_xid.py
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.5.0'
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: detect-private-key
- id: check-json
- id: check-toml
# - id: check-yaml
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: ^.+(\.md)$
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[package]
name = "epyxid"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2015 Olivier Poitrey <https://github.com/rs/xid>
Copyright (c) 2020 kazk

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.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pip install epyxid
## Usage

```python
from epyxid import XID
from epyxid import XID, xid_create

xid = XID.create()
xid: XID = xid_create()
print(xid)
# cnisffq7qo0qnbtbu5gg
print(bytes(xid))
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ fn macos_link_search_path() -> Option<String> {

println!("failed to determine link search path, continuing without it");
None
}
}
38 changes: 19 additions & 19 deletions epyxid.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,9 @@ from datetime import datetime

class XID:
"""
Globally unique sortable id generator.
Globally unique sortable id.
"""

@staticmethod
def create() -> 'XID':
"""
Generate a new globally unique id.
"""

@staticmethod
def from_str(s: str) -> 'XID':
"""
Create an id from its string representation.
"""

@staticmethod
def from_bytes(b: bytes) -> 'XID':
"""
Create an id from bytes.
"""

def as_bytes(self) -> bytes:
"""
The binary representation of the id.
Expand Down Expand Up @@ -75,3 +57,21 @@ class XID:
def __gt__(self, object: 'XID') -> bool: ...

def __ge__(self, object: 'XID') -> bool: ...


def xid_create() -> XID:
"""
Generate a new globally unique id.
"""


def xid_from_str(s: str) -> XID:
"""
Create an id from its string representation.
"""


def xid_from_bytes(b: bytes) -> XID:
"""
Create an id from bytes.
"""
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env just --justfile
#export PYO3_PRINT_CONFIG:="1"

build:
maturin build \
Expand Down
Loading

0 comments on commit 43f85bd

Please sign in to comment.