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

change(default): no longer set a default random generator #17

Closed
wants to merge 9 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return {
default = {
verbose = true,
coverage = true,
output = "gtest",
},
}
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.lua]
indent_style = space
indent_size = 2

[*.rockspec]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab
indent_size = 4
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint

concurrency:
# for PR's cancel the running task, if another commit is pushed
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
# build on PR and push-to-main. This works for short-lived branches, and saves
# CPU cycles on duplicated tests.
# For long-lived branches that diverge, you'll want to run on all pushes, not
# just on push-to-main.
pull_request: {}
push:
branches:
- main


jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.4"

- uses: leafo/gh-actions-luarocks@v4

- name: dependencies
run: |
make dev

- name: lint
run: |
make lint
52 changes: 52 additions & 0 deletions .github/workflows/unix_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Unix build"

concurrency:
# for PR's cancel the running task, if another commit is pushed
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
# build on PR and push-to-main. This works for short-lived branches, and saves
# CPU cycles on duplicated tests.
# For long-lived branches that diverge, you'll want to run on all pushes, not
# just on push-to-main.
pull_request: {}
push:
branches:
- main


jobs:
test:
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
luaVersion: ["5.1", "5.2", "5.3", "5.4", "luajit-2.1.0-beta3", "luajit-openresty"]

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: leafo/gh-actions-lua@v10
with:
luaVersion: ${{ matrix.luaVersion }}

- uses: leafo/gh-actions-luarocks@v4

- name: dependencies
run: |
make dev
luarocks install luacov-coveralls

- name: test
run: |
make testinst BUSTED='--coverage --Xoutput "--color"'

- name: Report test coverage
if: success()
continue-on-error: true
run: luacov-coveralls
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Compiled Lua sources
luac.out

# LuaCov files
*.report.out
*.stats.out

# luarocks build files
*.rock
*.zip
*.tar.gz

# Object files
*.o
*.os
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

32 changes: 32 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
unused_args = false
redefined = false
max_line_length = false

globals = {
-- "ngx",
}

not_globals = {
-- deprecated Lua 5.0 functions
"string.len",
"table.getn",
}

include_files = {
"**/*.lua",
"**/*.rockspec",
".busted",
".luacheckrc",
}

files["spec/**/*.lua"] = {
std = "+busted",
}

exclude_files = {
-- The Github Actions Lua Environment
".lua",
".luarocks",
".install",
}

5 changes: 5 additions & 0 deletions .luacov
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
modules = {
["uuid.*"] = "src"
}

runreport = true
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# CHANGELOG

## Versioning

This library is versioned based on Semantic Versioning ([SemVer](https://semver.org/)).

#### Version scoping

The scope of what is covered by the version number excludes:

- error messages; the text of the messages can change, unless specifically documented.

#### Releasing new versions

- create a release branch
- update the changelog below
- update version and copyright-years in `./LICENSE.md` (bottom) and `./src/uuid.lua` (in
doc-comments header)
- create a new rockspec and update the version inside the new rockspec:<br/>
`cp uuid-dev-1.rockspec ./rockspecs/uuid-X.Y.Z-1.rockspec`
- test: run `make test` and `make lint`
- clean and render the docs: run `make clean` and `make docs`
- commit the changes as `release X.Y.Z`
- push the commit, and create a release PR
- after merging tag the release commit with `X.Y.Z`
- upload to LuaRocks:<br/>
`luarocks upload ./rockspecs/uuid-X.Y.Z-1.rockspec --api-key=ABCDEFGH`
- test the newly created rock:<br/>
`luarocks install uuid`

## Version history

### Version 1.0.0, unreleased

- BREAKING: no default rng will be picked anymore, one must be set explicitly, see `set_rng`
- BREAKING: calling on the module table `uuid()` will now call `v4()` instead of `new()`
which means it no longer supports the `hwaddr` parameter
- Change: `new` function with the `hwaddr` parameter is deprecated, will be removed later
- Change: `randomseed` has moved to `rng.math_randomseed`, alias will be removed later
- Change: `seed` has moved to `rng.seed`, alias will be removed later
- Feat: new `rng` module with multiple `rng`s available
- Feat: new `set_rng` function to set the `rng` to use
- Feat: the `rng.seed` function has a new parameter `userinput` that allows the user to specify
additional input for seeding the Lua rng (eg. pass in a mac address).
- Feat: new `rng.luasystem` rng that uses LuaSystem for random number generation (Posix + Windows)
- Feat: new `rng.urandom` rng that uses /dev/urandom for random number generation (Posix, no Windows)
- Feat: new `rng.math_random` rng that replaces the old rng used, based on Lua's `math.random` function.
- Feat: improved seeding, using LuaSystem, or /dev/urandom if available. If not, the fallback now uses
more inputs (including a user provided one, eg. a mac address) and calculates a SHA1 used as seed.
Also support for the Lua 5.4

### Version 0.3, released 11-Jul-2021

- Fix: set proper type for UUIDv4 type
- Feat: improve seeding for OpenResty
- Doc: fix link in readme

### Version 0.2, released 09-May-2013

- Bugfix; 0-hex was displayed as "" instead of "00", making some uuids too short
- Bugfix; math.randomseed() overflow caused bad seeding

### Version 0.1, released 28-Apr-2013

- initial version
Loading