From d80451fc7ac552d5dca423d5d544fdeb8267c47f Mon Sep 17 00:00:00 2001 From: "T. von Dein" Date: Sat, 6 Dec 2025 20:25:43 +0100 Subject: [PATCH] move to codeberg (#1) --- .github/workflows/ci.yaml | 47 ---------------------------- .goreleaser.yaml | 65 +++++++++++++++++++++++++++++++++++++++ .woodpecker/build.yaml | 36 ++++++++++++++++++++++ .woodpecker/release.yaml | 15 +++++++++ Makefile.dist | 18 +++++++++++ README.md | 27 ++++++++-------- example/test.go | 8 +++-- go.mod | 4 +-- lib_test.go | 9 ++++-- 9 files changed, 164 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 .goreleaser.yaml create mode 100644 .woodpecker/build.yaml create mode 100644 .woodpecker/release.yaml create mode 100644 Makefile.dist diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index a9d06f8..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: build-and-test -on: [push, pull_request] -jobs: - build: - strategy: - matrix: - version: ['1.22'] - os: [ubuntu-latest, windows-latest, macos-latest] - name: Build - runs-on: ${{ matrix.os }} - steps: - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '${{ matrix.version }}' - id: go - - - name: checkout - uses: actions/checkout@v3 - - - name: build - run: go build - - - name: test - run: make test - - - name: Update coverage report - uses: ncruces/go-coverage-report@main - with: - report: true - chart: true - amend: true - if: | - matrix.os == 'ubuntu-latest' && - github.event_name == 'push' - continue-on-error: true - - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.22 - - uses: actions/checkout@v3 - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..654c898 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,65 @@ +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + - go mod tidy + +gitea_urls: + api: https://codeberg.org/api/v1 + download: https://codeberg.org + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - freebsd + +archives: + - formats: [tar.gz] + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }}_{{ .Tag }} + # use zip for windows archives + format_overrides: + - goos: windows + formats: [zip] + - goos: linux + formats: [tar.gz,binary] + files: + - src: "*.md" + strip_parent: true + - src: Makefile.dist + dst: Makefile + wrap_in_directory: true + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + groups: + - title: Improved + regexp: '^.*?(feat|add|new)(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: Fixed + regexp: '^.*?(bug|fix)(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: Changed + order: 999 + +release: + header: "# Release Notes" + footer: >- + + --- + + Full Changelog: [{{ .PreviousTag }}...{{ .Tag }}](https://codeberg.org/scip/valpass/compare/{{ .PreviousTag }}...{{ .Tag }}) diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..e20cc6f --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,36 @@ +matrix: + platform: + - linux/amd64 + goversion: + - 1.24 + +labels: + platform: ${platform} + +steps: + build: + when: + event: [push] + image: golang:${goversion} + commands: + - go get + - go build + + linter: + when: + event: [push] + image: golang:${goversion} + commands: + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0 + - golangci-lint --version + - golangci-lint run ./... + depends_on: [build] + + test: + when: + event: [push] + image: golang:${goversion} + commands: + - go get + - go test -v -cover + depends_on: [build,linter] diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml new file mode 100644 index 0000000..916c008 --- /dev/null +++ b/.woodpecker/release.yaml @@ -0,0 +1,15 @@ +# build release + +labels: + platform: linux/amd64 + +steps: + goreleaser: + image: goreleaser/goreleaser + when: + event: [tag] + environment: + GITEA_TOKEN: + from_secret: DEPLOY_TOKEN + commands: + - goreleaser release --clean --verbose diff --git a/Makefile.dist b/Makefile.dist new file mode 100644 index 0000000..55d2f38 --- /dev/null +++ b/Makefile.dist @@ -0,0 +1,18 @@ +# -*-make-*- + +.PHONY: install all + +tool = rpn +PREFIX = /usr/local +UID = root +GID = 0 + +all: + @echo "Type 'sudo make install' to install the tool." + @echo "To change prefix, type 'sudo make install PREFIX=/opt'" + +install: + install -d -o $(UID) -g $(GID) $(PREFIX)/bin + install -d -o $(UID) -g $(GID) $(PREFIX)/share/doc + install -o $(UID) -g $(GID) -m 555 $(tool) $(PREFIX)/sbin/ + install -o $(UID) -g $(GID) -m 444 *.md $(PREFIX)/share/doc/ diff --git a/README.md b/README.md index 9629a0e..ee8b700 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -[![Go Report Card](https://goreportcard.com/badge/github.com/tlinden/valpass)](https://goreportcard.com/report/github.com/tlinden/valpass) -[![Actions](https://github.com/tlinden/valpass/actions/workflows/ci.yaml/badge.svg)](https://github.com/tlinden/valpass/actions) -[![Go Coverage](https://github.com/tlinden/valpass/wiki/coverage.svg)](https://raw.githack.com/wiki/tlinden/valpass/coverage.html) -![GitHub License](https://img.shields.io/github/license/tlinden/valpass) -[![GoDoc](https://godoc.org/github.com/tlinden/valpass?status.svg)](https://godoc.org/github.com/tlinden/valpass) +[![status-badge](https://ci.codeberg.org/api/badges/15685/status.svg)](https://ci.codeberg.org/repos/15685) +[![Go Report Card](https://goreportcard.com/badge/codeberg.org/scip/valpass)](https://goreportcard.com/report/codeberg.org/scip/valpass) +[![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://codeberg.org/scip/valpass/raw/branch/main/LICENSE) +[![GoDoc](https://godoc.org/codeberg.org/scip/valpass?status.svg)](https://godoc.org/codeberg.org/scip/valpass) # valpass - a small golang module to verify passwords @@ -13,7 +12,7 @@ just for fun and to learn more about cryptography. During development I wrote a little helper tool which I could use to verify some quality metrics of my algorithm: -[analyze.c](https://github.com/TLINDEN/twenty4/blob/master/analyze/analyze.c). +[analyze.c](https://codeberg.org/scip/twenty4/blob/master/analyze/analyze.c). This module is a re-implementation of this code with go as a reusable module. @@ -108,10 +107,14 @@ you can tune the quality thresholds as needed. ## Usage -Usage is pretty simple: +Usage is pretty simple. First, import the module: + +```default +go get codeberg.org/scip/valpass/v2 +``` ```go -import "github.com/tlinden/valpass" +import "codeberg.org/scip/valpass/v2" [..] res, err := valpass.Validate("password"); if err != nil { @@ -140,8 +143,8 @@ type Options struct { To turn off a test, just set the tunable to zero. Please take a look at [the -example](https://github.com/TLINDEN/valpass/blob/main/example/test.go) -or at [the unit tests](https://github.com/TLINDEN/valpass/blob/main/lib_test.go). +example](https://codeberg.org/scip/valpass/raw/branch/main/example/test.go) +or at [the unit tests](https://codeberg.org/scip/valpass/raw/branch/main/lib_test.go). ## Performance @@ -151,7 +154,7 @@ Benchmark results of version 0.0.1: % go test -bench=. -count 5 goos: linux goarch: amd64 -pkg: github.com/tlinden/valpass +pkg: codeberg.org/scip/valpass cpu: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz BenchmarkValidateEntropy-8 98703 12402 ns/op BenchmarkValidateEntropy-8 92745 12258 ns/op @@ -184,7 +187,7 @@ BenchmarkValidateAllwDict-8 404 3022698 ns/op BenchmarkValidateAllwDict-8 393 3075163 ns/op BenchmarkValidateAllwDict-8 381 3112361 ns/op PASS -ok github.com/tlinden/valpass 54.017s +ok codeberg.org/scip/valpass 54.017s ``` ## License diff --git a/example/test.go b/example/test.go index 926f5f5..df16b9a 100644 --- a/example/test.go +++ b/example/test.go @@ -6,7 +6,7 @@ import ( "log" "os" - "github.com/tlinden/valpass" + "codeberg.org/scip/valpass/v2" ) const template string = ` @@ -58,7 +58,11 @@ func ReadDict(path string) []string { if err != nil { panic(err) } - defer file.Close() + defer func() { + if err := file.Close(); err != nil { + log.Fatal(err) + } + }() var lines []string scanner := bufio.NewScanner(file) diff --git a/go.mod b/go.mod index 13516ab..c28a584 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module github.com/tlinden/valpass +module codeberg.org/scip/valpass/v2 -go 1.22 +go 1.24 require github.com/alecthomas/repr v0.4.0 // indirect diff --git a/lib_test.go b/lib_test.go index d991e60..04c3228 100644 --- a/lib_test.go +++ b/lib_test.go @@ -3,12 +3,13 @@ package valpass_test import ( "bufio" "fmt" + "log" "os" "os/exec" "strings" "testing" - "github.com/tlinden/valpass" + "codeberg.org/scip/valpass/v2" ) type Passwordlist [][]string @@ -372,7 +373,11 @@ func ReadDict(path string) []string { if err != nil { panic(err) } - defer file.Close() + defer func() { + if err := file.Close(); err != nil { + log.Fatal(err) + } + }() var lines []string scanner := bufio.NewScanner(file)