From 8e1b3383826446d81b82ed365899e780830254ce Mon Sep 17 00:00:00 2001 From: Patryk Kalinowski Date: Fri, 16 Feb 2024 17:21:22 +0100 Subject: [PATCH] Test GH actions workflow (#21) * go mod vendor * update build and version to 1.0.0-rc.2 * add Test workflow for every push to the repo --- .github/workflows/test.yml | 36 +++++++++++++++++++ Dockerfile | 2 +- Makefile | 13 ++----- .../0xsequence/go-sequence/message.go | 20 +++++++++++ version.go | 2 +- 5 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 vendor/github.com/0xsequence/go-sequence/message.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..431ca2c1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test + +on: + push: + branches: + - "**" + pull_request: + branches: + - "**" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ '1.21.x' ] + + env: + CGO_ENABLED: 0 + + steps: + - uses: actions/checkout@v3 + + - name: Setup Go ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Vet + run: go vet + + - name: Build + run: go build -v ./cmd/waas-auth + + - name: Test + run: go test -v ./... diff --git a/Dockerfile b/Dockerfile index b735059f..dc9da962 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ ENV CONFIG=./etc/waas-auth.conf CMD ["make", "run"] -FROM ghcr.io/0xsequence/eiffel:v0.2.0@sha256:b696e86ce1b42c14503973a7dc2893b08dc44ce5cbf41242b8afe6abe3b12077 +FROM ghcr.io/0xsequence/eiffel:v0.3.0@sha256:d4aa946d7eb587e0554123efc3eaa5830a1428b0325ea239fe489e372f573dfe ARG ENV_ARG=dev2 diff --git a/Makefile b/Makefile index 5b31397f..065712a4 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,7 @@ TOP := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) SHELL = bash -o pipefail TEST_FLAGS ?= -v -GITTAG ?= $(shell git describe --exact-match --tags HEAD 2>/dev/null || :) -GITBRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || :) -LONGVERSION ?= $(shell git describe --tags --long --abbrev=8 --always HEAD)$(echo -$GITBRANCH | tr / - | grep -v '\-master' || :) -VERSION ?= $(if $(GITTAG),$(GITTAG),$(LONGVERSION)) -GITCOMMIT ?= $(shell git log -1 --date=iso --pretty=format:%H) -GITCOMMITDATE ?= $(shell git log -1 --date=iso --pretty=format:%cd) -GITCOMMITAUTHOR ?= $(shell git log -1 --date=iso --pretty="format:%an") - +VERSION := $(shell grep -o 'VERSION = "[^"]*' $(TOP)/version.go | cut -d'"' -f2) define run @go run github.com/goware/rerun/cmd/rerun -watch ./ -ignore vendor bin tests data/schema -run \ @@ -63,7 +56,7 @@ test: test-clean test-clean: GOGC=off go clean -testcache -eif: +eif: clean mkdir -p bin docker build --platform linux/amd64 --build-arg ENV_ARG=next -t waas-authenticator-builder . - docker run --platform linux/amd64 -v bin:/out waas-authenticator-builder + docker run --platform linux/amd64 -v $(TOP)/bin:/out waas-authenticator-builder waas-auth.$(VERSION) diff --git a/vendor/github.com/0xsequence/go-sequence/message.go b/vendor/github.com/0xsequence/go-sequence/message.go new file mode 100644 index 00000000..202cae42 --- /dev/null +++ b/vendor/github.com/0xsequence/go-sequence/message.go @@ -0,0 +1,20 @@ +package sequence + +import ( + "bytes" + "fmt" +) + +func IsEIP191Message(msg []byte) bool { + return bytes.HasPrefix(msg, []byte("\x19Ethereum Signed Message:\n")) +} + +func MessageToEIP191(msg []byte) []byte { + if !IsEIP191Message(msg) { + return bytes.Join([][]byte{ + []byte("\x19Ethereum Signed Message:\n"), + []byte(fmt.Sprintf("%v", len(msg))), + msg}, nil) + } + return msg +} diff --git a/version.go b/version.go index a5063b9c..afe402b7 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package waasauthenticator -const VERSION = "1.0.0-rc.1" +const VERSION = "1.0.0-rc.2"