Adde gitea workflow: tests
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 57s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 57s
This commit is contained in:
parent
f6bcdc9903
commit
14441c2378
9
.gitea/workflows/Dockerfile_tests
Normal file
9
.gitea/workflows/Dockerfile_tests
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM golang:latest
|
||||||
|
|
||||||
|
RUN apt install -y make curl python3 && go install gotest.tools/gotestsum@latest
|
||||||
|
|
||||||
|
COPY . /source
|
||||||
|
|
||||||
|
WORKDIR /source
|
||||||
|
|
||||||
|
CMD ["make", "test"]
|
30
.gitea/workflows/tests.yml
Normal file
30
.gitea/workflows/tests.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
# https://docs.gitea.com/next/usage/actions/quickstart
|
||||||
|
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
|
||||||
|
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
|
||||||
|
|
||||||
|
name: Build Docker and Deploy
|
||||||
|
run-name: Build & Deploy ${{ gitea.ref }} on ${{ gitea.actor }}
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run_tests:
|
||||||
|
name: Run goext test-suite
|
||||||
|
runs-on: bfb-cicd-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Build test docker
|
||||||
|
id: build_docker
|
||||||
|
run: echo "DOCKER_IMG_ID=$(docker build -q . -f .gitea/workflows/Dockerfile_tests || echo __err_build__)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: docker run --rm "${{ steps.build_docker.outputs.DOCKER_IMG_ID }}"
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: docker image rm "${{ steps.build_docker.outputs.DOCKER_IMG_ID }}"
|
||||||
|
|
BIN
bfcodegen/_test_example.tgz
Normal file
BIN
bfcodegen/_test_example.tgz
Normal file
Binary file not shown.
@ -1,15 +1,42 @@
|
|||||||
package bfcodegen
|
package bfcodegen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
|
"gogs.mikescher.com/BlackForestBytes/goext/cmdext"
|
||||||
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||||
|
"gogs.mikescher.com/BlackForestBytes/goext/tst"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestApplyEnvOverridesSimple(t *testing.T) {
|
//go:embed _test_example.tgz
|
||||||
|
var ExampleModels []byte
|
||||||
|
|
||||||
err := GenerateEnumSpecs("/home/mike/Code/reiff/badennet/bnet-backend/models", "/home/mike/Code/reiff/badennet/bnet-backend/models/enums_gen.go")
|
func TestGenerateEnumSpecs(t *testing.T) {
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
tmpFile := filepath.Join(t.TempDir(), langext.MustHexUUID()+".tgz")
|
||||||
t.Fail()
|
|
||||||
}
|
tmpDir := filepath.Join(t.TempDir(), langext.MustHexUUID())
|
||||||
|
|
||||||
|
err := os.WriteFile(tmpFile, ExampleModels, 0o777)
|
||||||
|
tst.AssertNoErr(t, err)
|
||||||
|
|
||||||
|
t.Cleanup(func() { _ = os.Remove(tmpFile) })
|
||||||
|
|
||||||
|
err = os.Mkdir(tmpDir, 0o777)
|
||||||
|
tst.AssertNoErr(t, err)
|
||||||
|
|
||||||
|
t.Cleanup(func() { _ = os.RemoveAll(tmpFile) })
|
||||||
|
|
||||||
|
_, err = cmdext.Runner("tar").Arg("-xvzf").Arg(tmpFile).Arg("-C").Arg(tmpDir).FailOnExitCode().FailOnTimeout().Timeout(time.Minute).Run()
|
||||||
|
tst.AssertNoErr(t, err)
|
||||||
|
|
||||||
|
err = GenerateEnumSpecs(tmpDir, tmpDir+"/enums_gen.go")
|
||||||
|
tst.AssertNoErr(t, err)
|
||||||
|
|
||||||
|
err = GenerateEnumSpecs(tmpDir, tmpDir+"/enums_gen.go")
|
||||||
|
tst.AssertNoErr(t, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func TestStdout(t *testing.T) {
|
|||||||
|
|
||||||
func TestStderr(t *testing.T) {
|
func TestStderr(t *testing.T) {
|
||||||
|
|
||||||
res1, err := Runner("python").Arg("-c").Arg("import sys; print(\"error\", file=sys.stderr, end='')").Run()
|
res1, err := Runner("python3").Arg("-c").Arg("import sys; print(\"error\", file=sys.stderr, end='')").Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ func TestStderr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStdcombined(t *testing.T) {
|
func TestStdcombined(t *testing.T) {
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys; import time; print(\"1\", file=sys.stderr, flush=True); time.sleep(0.1); print(\"2\", file=sys.stdout, flush=True); time.sleep(0.1); print(\"3\", file=sys.stderr, flush=True)").
|
Arg("import sys; import time; print(\"1\", file=sys.stderr, flush=True); time.sleep(0.1); print(\"2\", file=sys.stdout, flush=True); time.sleep(0.1); print(\"3\", file=sys.stderr, flush=True)").
|
||||||
Run()
|
Run()
|
||||||
@ -82,7 +82,7 @@ func TestStdcombined(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPartialRead(t *testing.T) {
|
func TestPartialRead(t *testing.T) {
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys; import time; print(\"first message\", flush=True); time.sleep(5); print(\"cant see me\", flush=True);").
|
Arg("import sys; import time; print(\"first message\", flush=True); time.sleep(5); print(\"cant see me\", flush=True);").
|
||||||
Timeout(100 * time.Millisecond).
|
Timeout(100 * time.Millisecond).
|
||||||
@ -106,7 +106,7 @@ func TestPartialRead(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPartialReadStderr(t *testing.T) {
|
func TestPartialReadStderr(t *testing.T) {
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys; import time; print(\"first message\", file=sys.stderr, flush=True); time.sleep(5); print(\"cant see me\", file=sys.stderr, flush=True);").
|
Arg("import sys; import time; print(\"first message\", file=sys.stderr, flush=True); time.sleep(5); print(\"cant see me\", file=sys.stderr, flush=True);").
|
||||||
Timeout(100 * time.Millisecond).
|
Timeout(100 * time.Millisecond).
|
||||||
@ -131,7 +131,7 @@ func TestPartialReadStderr(t *testing.T) {
|
|||||||
|
|
||||||
func TestReadUnflushedStdout(t *testing.T) {
|
func TestReadUnflushedStdout(t *testing.T) {
|
||||||
|
|
||||||
res1, err := Runner("python").Arg("-c").Arg("import sys; print(\"message101\", file=sys.stdout, end='')").Run()
|
res1, err := Runner("python3").Arg("-c").Arg("import sys; print(\"message101\", file=sys.stdout, end='')").Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ func TestReadUnflushedStdout(t *testing.T) {
|
|||||||
|
|
||||||
func TestReadUnflushedStderr(t *testing.T) {
|
func TestReadUnflushedStderr(t *testing.T) {
|
||||||
|
|
||||||
res1, err := Runner("python").Arg("-c").Arg("import sys; print(\"message101\", file=sys.stderr, end='')").Run()
|
res1, err := Runner("python3").Arg("-c").Arg("import sys; print(\"message101\", file=sys.stderr, end='')").Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ func TestReadUnflushedStderr(t *testing.T) {
|
|||||||
func TestPartialReadUnflushed(t *testing.T) {
|
func TestPartialReadUnflushed(t *testing.T) {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
|
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys; import time; print(\"first message\", end=''); time.sleep(5); print(\"cant see me\", end='');").
|
Arg("import sys; import time; print(\"first message\", end=''); time.sleep(5); print(\"cant see me\", end='');").
|
||||||
Timeout(100 * time.Millisecond).
|
Timeout(100 * time.Millisecond).
|
||||||
@ -206,7 +206,7 @@ func TestPartialReadUnflushed(t *testing.T) {
|
|||||||
func TestPartialReadUnflushedStderr(t *testing.T) {
|
func TestPartialReadUnflushedStderr(t *testing.T) {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
|
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys; import time; print(\"first message\", file=sys.stderr, end=''); time.sleep(5); print(\"cant see me\", file=sys.stderr, end='');").
|
Arg("import sys; import time; print(\"first message\", file=sys.stderr, end=''); time.sleep(5); print(\"cant see me\", file=sys.stderr, end='');").
|
||||||
Timeout(100 * time.Millisecond).
|
Timeout(100 * time.Millisecond).
|
||||||
@ -231,7 +231,7 @@ func TestPartialReadUnflushedStderr(t *testing.T) {
|
|||||||
|
|
||||||
func TestListener(t *testing.T) {
|
func TestListener(t *testing.T) {
|
||||||
|
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys;" +
|
Arg("import sys;" +
|
||||||
"import time;" +
|
"import time;" +
|
||||||
@ -264,7 +264,7 @@ func TestListener(t *testing.T) {
|
|||||||
|
|
||||||
func TestLongStdout(t *testing.T) {
|
func TestLongStdout(t *testing.T) {
|
||||||
|
|
||||||
res1, err := Runner("python").
|
res1, err := Runner("python3").
|
||||||
Arg("-c").
|
Arg("-c").
|
||||||
Arg("import sys; import time; print(\"X\" * 125001 + \"\\n\"); print(\"Y\" * 125001 + \"\\n\"); print(\"Z\" * 125001 + \"\\n\");").
|
Arg("import sys; import time; print(\"X\" * 125001 + \"\\n\"); print(\"Y\" * 125001 + \"\\n\"); print(\"Z\" * 125001 + \"\\n\");").
|
||||||
Timeout(5000 * time.Millisecond).
|
Timeout(5000 * time.Millisecond).
|
||||||
@ -298,7 +298,7 @@ func TestFailOnTimeout(t *testing.T) {
|
|||||||
|
|
||||||
func TestFailOnStderr(t *testing.T) {
|
func TestFailOnStderr(t *testing.T) {
|
||||||
|
|
||||||
res1, err := Runner("python").Arg("-c").Arg("import sys; print(\"error\", file=sys.stderr, end='')").FailOnStderr().Run()
|
res1, err := Runner("python3").Arg("-c").Arg("import sys; print(\"error\", file=sys.stderr, end='')").FailOnStderr().Run()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("no err")
|
t.Errorf("no err")
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ func (t *RFC3339Time) UnmarshalText(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
|
func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
|
||||||
if bt == bsontype.Null {
|
if bt == bson.TypeNull {
|
||||||
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
|
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
|
||||||
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
|
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
|
||||||
// https://stackoverflow.com/questions/75167597
|
// https://stackoverflow.com/questions/75167597
|
||||||
@ -77,7 +77,7 @@ func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
|
|||||||
*t = RFC3339Time{}
|
*t = RFC3339Time{}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if bt != bsontype.DateTime {
|
if bt != bson.TypeDateTime {
|
||||||
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339Time", bt))
|
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339Time", bt))
|
||||||
}
|
}
|
||||||
var tt time.Time
|
var tt time.Time
|
||||||
|
@ -69,7 +69,7 @@ func (t *RFC3339NanoTime) UnmarshalText(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
|
func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error {
|
||||||
if bt == bsontype.Null {
|
if bt == bson.TypeNull {
|
||||||
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
|
// we can't set nil in UnmarshalBSONValue (so we use default(struct))
|
||||||
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
|
// Use mongoext.CreateGoExtBsonRegistry if you need to unmarsh pointer values
|
||||||
// https://stackoverflow.com/questions/75167597
|
// https://stackoverflow.com/questions/75167597
|
||||||
@ -77,7 +77,7 @@ func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) erro
|
|||||||
*t = RFC3339NanoTime{}
|
*t = RFC3339NanoTime{}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if bt != bsontype.DateTime {
|
if bt != bson.TypeDateTime {
|
||||||
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339NanoTime", bt))
|
return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339NanoTime", bt))
|
||||||
}
|
}
|
||||||
var tt time.Time
|
var tt time.Time
|
||||||
|
@ -2,6 +2,7 @@ package rfctime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"gogs.mikescher.com/BlackForestBytes/goext/timeext"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/tst"
|
"gogs.mikescher.com/BlackForestBytes/goext/tst"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -13,7 +14,7 @@ func TestRoundtrip(t *testing.T) {
|
|||||||
Value RFC3339NanoTime `json:"v"`
|
Value RFC3339NanoTime `json:"v"`
|
||||||
}
|
}
|
||||||
|
|
||||||
val1 := NewRFC3339Nano(time.Unix(0, 1675951556820915171))
|
val1 := NewRFC3339Nano(time.Unix(0, 1675951556820915171).In(timeext.TimezoneBerlin))
|
||||||
w1 := Wrap{val1}
|
w1 := Wrap{val1}
|
||||||
|
|
||||||
jstr1, err := json.Marshal(w1)
|
jstr1, err := json.Marshal(w1)
|
||||||
|
Loading…
Reference in New Issue
Block a user