Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Feb 14, 2024
0 parents commit 8c56bb0
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
insert_final_newline = true
max_line_length = 160
tab_width = 4
trim_trailing_whitespace = true

[Makefile]
indent_style = space

[*.feature]
indent_style = space

[{.github/**/*.yaml,.github/**/*.yml}]
indent_size = 2
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
36 changes: 36 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: lint

on:
push:
branches:
- master
pull_request:

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- name: Setup Environment
run: |
make "$GITHUB_ENV"
- name: Setup
uses: nhatthm/gh-actions/find-go-version@master

- name: Install Go
uses: nhatthm/gh-actions/setup-go@master
with:
go-version: ${{ env.GO_LATEST_VERSION }}

- name: Install Python
uses: nhatthm/gh-actions/setup-python@master
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Lint
uses: nhatthm/gh-actions/golangci-lint@master
78 changes: 78 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: test

on:
push:
branches:
- master
pull_request:

env:
GO111MODULE: "on"

jobs:
setup:
runs-on: ubuntu-latest
outputs:
go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }}
go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }}
steps:
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- id: find-go-version
name: Find Go version
uses: nhatthm/gh-actions/find-go-version@master

test:
strategy:
fail-fast: false
matrix:
go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }}
runs-on: ubuntu-latest
needs: [setup]
env:
GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }}
steps:
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- name: Setup Environment
run: |
make "$GITHUB_ENV"
- name: Install Go
uses: nhatthm/gh-actions/setup-go@master
with:
go-version: ${{ matrix.go-version }}

- name: Install Python
uses: nhatthm/gh-actions/setup-python@master
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-dev python3-fontforge
ls -la /usr/lib/python3/dist-packages/
ln -s /usr/lib/python3/dist-packages/fontforge.cpython-${${PYTHON_VERSION%.*}//.}-x86_64-linux-gnu.so /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/fontforge.so \
ln -s /usr/lib/python3/dist-packages/psMat.cpython-${${PYTHON_VERSION%.*}//.}-x86_64-linux-gnu.so /usr/local/lib/python${PYTHON_VERSION%.*}/site-packages/psMat.so \
- name: Test
run: |
make test
- name: Upload code coverage (unit)
if: matrix.go-version == env.GO_LATEST_VERSION
uses: nhatthm/gh-actions/codecov@master
with:
files: ./unit.coverprofile
flags: unittests-${{ runner.os }}

#- name: Upload code coverage (features)
# if: matrix.go-version == env.GO_LATEST_VERSION
# uses: nhatthm/gh-actions/codecov@master
# with:
# file: ./features.coverprofile
# flags: featurestests-${{ runner.os }}
22 changes: 22 additions & 0 deletions .github/workflows/update-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: 'update-registry'

on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- name: Notify registries
uses: nhatthm/gh-actions/notify-go-registries@master
with:
token: ${{ secrets.REGISTRY_TOKEN }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
/vendor

*.coverprofile
61 changes: 61 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
run:
tests: true

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 20
dupl:
threshold: 100
misspell:
locale: US
unused:
check-exported: false
unparam:
check-exported: true

linters:
enable-all: true
disable:
- deadcode
- depguard
- exhaustivestruct
- exhaustruct
- forbidigo
- forcetypeassert
- gci
- gochecknoglobals
- golint
- gomnd
- ifshort
- interfacer
- ireturn
- lll
- maligned
- nonamedreturns
- nosnakecase
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- paralleltest
- scopelint
- structcheck
- tagliatelle
- testpackage
- varcheck
- varnamelen
- wrapcheck

issues:
max-same-issues: 20
exclude-use-default: false
exclude-rules:
- linters:
- dupl
- funlen
- goconst
- goerr113
- gomnd
- noctx
path: "_test.go"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Nhat

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.
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
MODULE_NAME=psmat

VENDOR_DIR = vendor

PYTHON_VERSION ?= 3.11
GOLANGCI_LINT_VERSION ?= v1.55.2

GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)

.PHONY: $(VENDOR_DIR)
$(VENDOR_DIR):
@mkdir -p $(VENDOR_DIR)
@$(GO) mod vendor
@$(GO) mod tidy

.PHONY: lint
lint:
@$(GOLANGCI_LINT) run

.PHONY: test
test: test-unit

## Run unit tests
.PHONY: test-unit
test-unit:
@echo ">> unit test"
@$(GO) test -gcflags=-l -coverprofile=unit.coverprofile -covermode=atomic -race ./...

#.PHONY: test-integration
#test-integration:
# @echo ">> integration test"
# @$(GO) test ./features/... -gcflags=-l -coverprofile=features.coverprofile -coverpkg ./... -race --godog

.PHONY: $(GITHUB_OUTPUT)
$(GITHUB_OUTPUT):
@echo "MODULE_NAME=$(MODULE_NAME)" >>"$@"
@echo "PYTHON_VERSION=$(PYTHON_VERSION)" >>"$@"
@echo "GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION)" >>"$@"

.PHONY: $(GITHUB_ENV)
$(GITHUB_ENV):
@echo "MODULE_NAME=$(MODULE_NAME)" >>"$@"
@echo "PYTHON_VERSION=$(PYTHON_VERSION)" >>"$@"
@echo "GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION)" >>"$@"

$(GOLANGCI_LINT):
@echo "$(OK_COLOR)==> Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(NO_COLOR)"; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin "$(GOLANGCI_LINT_VERSION)"
@mv ./bin/golangci-lint $(GOLANGCI_LINT)
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Go bindings for the Python psMat module

[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/go-psMat)](https://github.com/nhatthm/go-psMat/releases/latest)
[![Build Status](https://github.com/nhatthm/go-psMat/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/go-psMat/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/nhatthm/go-psMat/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/go-psMat)
[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/psmat)](https://goreportcard.com/report/go.nhat.io/psmat)
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/psmat)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

> [!IMPORTANT]
> **Currently supports python-3.11 only.**
## Prerequisites

- `Go >= 1.22`

## Install

```bash
go get go.nhat.io/psmat
```

## Usage

TBD

## Examples

TBA

## Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

### Paypal donation

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

       or scan this

<img src="https://user-images.githubusercontent.com/1154587/113494222-ad8cb200-94e6-11eb-9ef3-eb883ada222a.png" width="147px" />
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "features/**/*"
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package psmat provides quick access to some useful transformations expressed as PostScript matrices
package psmat
17 changes: 17 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module go.nhat.io/psmat

go 1.22

require (
github.com/stretchr/testify v1.8.4
go.nhat.io/ligaturizer v0.0.0-20240211085235-fbb6834f56e6
go.nhat.io/python3 v0.0.0-20240214125738-12c51604fa60
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.nhat.io/cpy3 v0.0.0-20240211052030-bde1bc76d495 // indirect
go.nhat.io/once v0.2.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 8c56bb0

Please sign in to comment.