Skip to content

Commit

Permalink
ci: added codecov and other minor doc fixes (#20)
Browse files Browse the repository at this point in the history
* ci: added codecov

* docs: added license header

* docs: added codecov label

* docs: added badges

* docs: fixed spelling
  • Loading branch information
karl-cardenas-coding authored Aug 4, 2024
1 parent 950cc92 commit 71c168a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
mkdir -p tests/data
make tests-coverage
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Go version](https://img.shields.io/github/go-mod/go-version/karl-cardenas-coding/go-lambda-cleanup)](https://golang.org/dl/)
[![Go Reference](https://pkg.go.dev/badge/github.com/karl-cardenas-coding/mywhoop.svg)](https://pkg.go.dev/github.com/karl-cardenas-coding/mywhoop)
[![Go Report Card](https://goreportcard.com/badge/github.com/karl-cardenas-coding/mywhoop)](https://goreportcard.com/report/github.com/karl-cardenas-coding/mywhoop)
[![codecov](https://codecov.io/github/karl-cardenas-coding/mywhoop/graph/badge.svg?token=ZHEE3T4HUG)](https://codecov.io/github/karl-cardenas-coding/mywhoop)

# MyWhoop

Expand Down
5 changes: 4 additions & 1 deletion cmd/extensions.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) karl-cardenas-coding
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
Expand Down Expand Up @@ -40,7 +43,7 @@ func determineNotificationExtension(cfg internal.ConfigurationData) (internal.No
}

// determineExporterExtension determines the export extension to use and returns the appropriate export.
// The paramter isServerMode is used to determine if the exporter is being used in server mode. Use this flag to set server mode defaults.
// The parameter isServerMode is used to determine if the exporter is being used in server mode. Use this flag to set server mode defaults.
func determineExporterExtension(cfg internal.ConfigurationData, client *http.Client, dataLocation string) (internal.Export, error) {

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func downloadWhoopData(ctx context.Context, config internal.ConfigurationData, c
token, err := internal.ReadTokenFromFile(config.Credentials.CredentialsFile)
if err != nil {
slog.Error("unable to read token file", "error", err)
notifyErr := notify.Publish(client, []byte(fmt.Sprintf("Failed to read the authentication token from file during the regular daily retreive cycle. Additional context below: \n %s", err)), internal.EventErrors.String())
notifyErr := notify.Publish(client, []byte(fmt.Sprintf("Failed to read the authentication token from file during the regular daily retrieve cycle. Additional context below: \n %s", err)), internal.EventErrors.String())
if notifyErr != nil {
slog.Error("unable to send notification", "error", notifyErr)
}
Expand Down
25 changes: 25 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) karl-cardenas-coding
# SPDX-License-Identifier: Apache-2.0



codecov:
require_ci_to_pass: true
comment:
behavior: default
layout: reach,diff,flags,tree,reach
show_carryforward_flags: false
coverage:
precision: 2
range:
- 60.0
- 85.0
round: down
status:
changes: true
default_rules:
flag_coverage_not_uploaded_behavior: include
patch: true
project: true
github_checks:
annotations: true
16 changes: 8 additions & 8 deletions export/aws_s3_export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ func TestAWSS3Export(t *testing.T) {
}

tests := []struct {
descritpion string
description string
awsS3 *AWS_S3
data []byte
errorExpected bool
}{
{
descritpion: "Test case 1: Export data to S3",
description: "Test case 1: Export data to S3",
awsS3: &AWS_S3{
Region: "us-east-1",
Bucket: mockBucketName,
Expand All @@ -240,7 +240,7 @@ func TestAWSS3Export(t *testing.T) {
errorExpected: false,
},
{
descritpion: "Test case 2: Empty data",
description: "Test case 2: Empty data",
awsS3: &AWS_S3{
Region: "us-east-1",
Bucket: mockBucketName,
Expand All @@ -257,7 +257,7 @@ func TestAWSS3Export(t *testing.T) {
errorExpected: true,
},
{
descritpion: "Test case 3: 0 data length",
description: "Test case 3: 0 data length",
awsS3: &AWS_S3{
Region: "us-east-1",
Bucket: mockBucketName,
Expand All @@ -274,13 +274,13 @@ func TestAWSS3Export(t *testing.T) {
errorExpected: true,
},
{
descritpion: "Test case 4: Nil AWS S3",
description: "Test case 4: Nil AWS S3",
awsS3: nil,
data: []byte(`{"name": "John Doe", "age": 30}`),
errorExpected: true,
},
{
descritpion: "Test case 5: over 10 MB data",
description: "Test case 5: over 10 MB data",
awsS3: &AWS_S3{
Region: "us-east-1",
Bucket: mockBucketName,
Expand All @@ -297,7 +297,7 @@ func TestAWSS3Export(t *testing.T) {
errorExpected: false,
},
{
descritpion: "Test case 6: No bucket",
description: "Test case 6: No bucket",
awsS3: &AWS_S3{
Region: "us-east-1",
Bucket: "",
Expand All @@ -316,7 +316,7 @@ func TestAWSS3Export(t *testing.T) {
}

for index, tc := range tests {
t.Run(tc.descritpion, func(t *testing.T) {
t.Run(tc.description, func(t *testing.T) {
err := tc.awsS3.Export(tc.data)
if !tc.errorExpected && err != nil {
t.Errorf("Test Case - %d: Unexpected error: %v", index+1, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestGetEndpoint(t *testing.T) {
got := getEndpoint()

if got.AuthURL != expected.AuthURL {
t.Errorf("an error occured. Expected %s but got %s", expected.AuthURL, got.AuthURL)
t.Errorf("an error occurred. Expected %s but got %s", expected.AuthURL, got.AuthURL)
}

if got.TokenURL != expected.TokenURL {
t.Errorf("an error occured. Expected %s but got %s", expected.TokenURL, got.TokenURL)
t.Errorf("an error occurred. Expected %s but got %s", expected.TokenURL, got.TokenURL)
}

}
Expand Down

0 comments on commit 71c168a

Please sign in to comment.