Skip to content

Commit

Permalink
change(default): no longer set a default random generator
Browse files Browse the repository at this point in the history
rewritten entire logic and skip setting a default.
several new rng source implementations included
  • Loading branch information
Tieske committed Oct 9, 2024
1 parent b46f021 commit 5e4d578
Show file tree
Hide file tree
Showing 24 changed files with 2,361 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .busted
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
return {
default = {
verbose = true,
coverage = false,
coverage = true,
output = "gtest",
},
}
11 changes: 5 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ indent_size = 2

[*.rockspec]
indent_style = space
indent_size = 3
indent_size = 2

[*.c]
indent_style = tab
[*.md]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab

[*.md]
indent_style = space
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 }}
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +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

26 changes: 14 additions & 12 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
std = "ngx_lua"
unused_args = false
redefined = false
max_line_length = false


globals = {
-- "ngx",
}


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


ignore = {
--"6.", -- ignore whitespace warnings
include_files = {
"**/*.lua",
"**/*.rockspec",
".busted",
".luacheckrc",
}

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

exclude_files = {
--"spec/fixtures/invalid-module.lua",
--"spec-old-api/fixtures/invalid-module.lua",
-- The Github Actions Lua Environment
".lua",
".luarocks",
".install",
}


files["spec/**/*.lua"] = {
std = "ngx_lua+busted",
}
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
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

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

0 comments on commit 5e4d578

Please sign in to comment.