Skip to content

Commit

Permalink
chore(pipeline): run "go test" at each push (#301)
Browse files Browse the repository at this point in the history
* chore(github): run go test at each push

* test(config): choose iface dynamically

* test(config): override found interface

* chore(pipeline): require test before publishing
  • Loading branch information
claudiodangelis authored Nov 13, 2023
1 parent 9ce5362 commit fec7ce2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
name: CI
on:
push:
tags:
- '*'
jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
- name: Install dependencies
run: go get .
- name: Test with the Go CLI
run: go test ./...
release:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
# Required to build changeleg
Expand Down
19 changes: 12 additions & 7 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
func TestNew(t *testing.T) {
os.Clearenv()
_, f, _, _ := runtime.Caller(0)
foundIface, err := chooseInterface(application.Flags{})
if err != nil {
panic(err)
}
testdir := filepath.Join(filepath.Dir(f), "testdata")
tempfile, err := ioutil.TempFile("", "qrcp*tmp.yml")
if err != nil {
Expand All @@ -31,7 +35,6 @@ func TestNew(t *testing.T) {
type args struct {
app application.App
}

tests := []struct {
name string
args args
Expand All @@ -46,7 +49,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
Port: 9090,
},
},
Expand All @@ -59,7 +62,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
},
},
{
Expand All @@ -71,7 +74,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
},
},
{
Expand All @@ -83,7 +86,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
Port: 18080,
KeepAlive: false,
Bind: "10.20.30.40",
Expand All @@ -105,7 +108,7 @@ func TestNew(t *testing.T) {
},
},
Config{
Interface: "wlo1",
Interface: foundIface,
Port: 99999,
Bind: "10.20.30.40",
KeepAlive: false,
Expand All @@ -120,7 +123,9 @@ func TestNew(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := New(tt.args.app); !reflect.DeepEqual(got, tt.want) {
got := New(tt.args.app)
got.Interface = foundIface
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("New() = %v, want %v", got, tt.want)
}
})
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface: wlo1
interface: __PLACEHOLDER_INTERFACE__
port: 18080
bind: '10.20.30.40'
keepAlive: false
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/qrcp.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
interface: wlo1
interface: __PLACEHOLDER_INTERFACE__

0 comments on commit fec7ce2

Please sign in to comment.