Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOISSUE - Fix CI tests #31

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) Abstract Machines
# SPDX-License-Identifier: Apache-2.0

# CoAP is temporarily ignored since we don't have tests for it yet.
coverage:
ignore:
- "cmd/*"
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ jobs:
run: |
go test --race -v -count=1 -coverprofile=coverage/twins.out ./twins/...

- name: Upload coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV }}
directory: ./coverage/
name: codecov-umbrella
files: ./coverage/*.out
codecov_yml_path: .codecov.yml
verbose: true
4 changes: 1 addition & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ linters-settings:
alias: repoerr
- pkg: github.com/absmach/magistrala/pkg/sdk/mocks
alias: sdkmocks

gocritic:
enabled-checks:
- importShadow
Expand Down Expand Up @@ -84,8 +83,7 @@ linters:
- dogsled
- errchkjson
- errname
- execinquery
- exportloopref
- copyloopvar
- ginkgolinter
- gocheckcompilerdirectives
- gofumpt
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# contrib
# Magistrala Contrib reository

[![codecov](https://codecov.io/gh/absmach/mg-contrib/graph/badge.svg?token=0OD8Qw0Mxd)](https://codecov.io/gh/absmach/mg-contrib)

Extra bits that didn't make it into the main Magistrala repository
18 changes: 9 additions & 9 deletions tools/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,19 @@ func createThings(s sdk.SDK, conf Config, token string) ([]sdk.Thing, error) {
for i := 0; i < batches; i++ {
ths, err := createThingsInBatch(s, conf, token, batchSize)
if err != nil {
return []sdk.Thing{}, fmt.Errorf("Failed to create the things: %w", err)
return []sdk.Thing{}, fmt.Errorf("failed to create the things: %w", err)
}
things = append(things, ths...)
}
ths, err := createThingsInBatch(s, conf, token, conf.Num%uint64(batchSize))
if err != nil {
return []sdk.Thing{}, fmt.Errorf("Failed to create the things: %w", err)
return []sdk.Thing{}, fmt.Errorf("failed to create the things: %w", err)
}
things = append(things, ths...)
} else {
ths, err := createThingsInBatch(s, conf, token, conf.Num)
if err != nil {
return []sdk.Thing{}, fmt.Errorf("Failed to create the things: %w", err)
return []sdk.Thing{}, fmt.Errorf("failed to create the things: %w", err)
}
things = append(things, ths...)
}
Expand Down Expand Up @@ -295,19 +295,19 @@ func createChannels(s sdk.SDK, conf Config, token string) ([]sdk.Channel, error)
for i := 0; i < batches; i++ {
chs, err := createChannelsInBatch(s, conf, token, batchSize)
if err != nil {
return []sdk.Channel{}, fmt.Errorf("Failed to create the channels: %w", err)
return []sdk.Channel{}, fmt.Errorf("failed to create the channels: %w", err)
}
channels = append(channels, chs...)
}
chs, err := createChannelsInBatch(s, conf, token, conf.Num%uint64(batchSize))
if err != nil {
return []sdk.Channel{}, fmt.Errorf("Failed to create the channels: %w", err)
return []sdk.Channel{}, fmt.Errorf("failed to create the channels: %w", err)
}
channels = append(channels, chs...)
} else {
chs, err := createChannelsInBatch(s, conf, token, conf.Num)
if err != nil {
return []sdk.Channel{}, fmt.Errorf("Failed to create the channels: %w", err)
return []sdk.Channel{}, fmt.Errorf("failed to create the channels: %w", err)
}
channels = append(channels, chs...)
}
Expand Down Expand Up @@ -572,7 +572,7 @@ func messaging(s sdk.SDK, conf Config, token string, things []sdk.Thing, channel

func sendHTTPMessage(s sdk.SDK, msg string, thing sdk.Thing, chanID string) error {
if err := s.SendMessage(chanID, msg, thing.Credentials.Secret); err != nil {
return fmt.Errorf("HTTP failed to send message from thing %s to channel %s: %w", thing.ID, chanID, err)
return fmt.Errorf("failed to send HTTP message from thing %s to channel %s: %w", thing.ID, chanID, err)
}

return nil
Expand All @@ -581,7 +581,7 @@ func sendHTTPMessage(s sdk.SDK, msg string, thing sdk.Thing, chanID string) erro
func sendCoAPMessage(msg string, thing sdk.Thing, chanID string) error {
cmd := exec.Command("coap-cli", "post", fmt.Sprintf("channels/%s/messages", chanID), "--auth", thing.Credentials.Secret, "-d", msg)
if _, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("CoAP failed to send message from thing %s to channel %s: %w", thing.ID, chanID, err)
return fmt.Errorf("failed to send CoAP message from thing %s to channel %s: %w", thing.ID, chanID, err)
}

return nil
Expand All @@ -590,7 +590,7 @@ func sendCoAPMessage(msg string, thing sdk.Thing, chanID string) error {
func sendMQTTMessage(msg string, thing sdk.Thing, chanID string) error {
cmd := exec.Command("mosquitto_pub", "--id-prefix", "magistrala", "-u", thing.ID, "-P", thing.Credentials.Secret, "-t", fmt.Sprintf("channels/%s/messages", chanID), "-h", "localhost", "-m", msg)
if _, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("MQTT failed to send message from thing %s to channel %s: %w", thing.ID, chanID, err)
return fmt.Errorf("failed to send MQTT message from thing %s to channel %s: %w", thing.ID, chanID, err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion twins/mongodb/twins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
invalidName = strings.Repeat("m", maxNameSize+1)
)

func Testtwinsave(t *testing.T) {
func TestTwinSave(t *testing.T) {
client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(addr))
require.Nil(t, err, fmt.Sprintf("Creating new MongoDB client expected to succeed: %s.\n", err))

Expand Down
Loading