Skip to content

Commit

Permalink
ci: bit of CI work
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsRC authored May 11, 2024
1 parent 624c134 commit d860980
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
experimental: true
- run: mise run dev:lint --no-fail
- run: mise run test:unit --ci
- run: mise run test:unit
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@6bbd64e0cb2194e04addb429d669a9ee873eeeef
env:
Expand Down
6 changes: 5 additions & 1 deletion .mise/tasks/dev/lint
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ if test "$fix" = 0; then
fixflags="--fix"
fi

golangci-lint run --issues-exit-code="$nofail" $fixflags
golangci-lint run \
--issues-exit-code="$nofail" \
--max-issues-per-linter 0 \
--max-same-issues 0 \
$fixflags
22 changes: 2 additions & 20 deletions .mise/tasks/test/unit
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,7 @@
# mise sources=["go.mod", "go.sum", "internal/**/*", "cmd/**/*", "*.go"]
# mise outputs=["build/unit_coverage.out", "build/unit_test_report.json"]

ci=1

handle_argument() {
echo "Argument '$1' not supported" >&2; exit 1
}

while test "$#" -gt 0; do
case "$1" in
--ci) ci=0; shift 1;;

-*) echo "unknown option: $1" >&2; exit 1;;
*) handle_argument "$1"; shift 1;;
esac
done

mkdir -p build

if test "$ci" = 0; then
go test -coverprofile build/unit_coverage.out -json ./... > build/unit_test_report.json || true
else
go test -coverprofile build/unit_coverage.out ./...
fi
go test -json ./... > build/unit_test_report.json || true
go test -coverprofile build/unit_coverage.out ./...
11 changes: 6 additions & 5 deletions internal/configProvider/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ import (
)

var testYamlFilePath = "testdata/config.yaml"
var securitySaltFilePath = "testdata/security.salt"
var securitySiteKeyFilePath = "testdata/security.sitekey"
var testFilePath = "testdata/test.file"
var databaseUserKey = "database.user"
var databasePasswordKey = "database.password"
var nonExistentYamlFilePath = "testdata/non-existent.yaml"
var newUserNameString = "new-username"
var newPasswordString = "new-password 42 c@t"
var rootConfigYamlPath = "/config.yaml"

Expand Down Expand Up @@ -227,7 +228,7 @@ func TestNewConfigProvider(t *testing.T) {
err := os.WriteFile(tempFile, yamlContent, 0644)
require.NoError(t, err)

c, err := NewConfigProvider(tempFile, nil, []string{testFilePath}, validator.NewValidator())
c, err := NewConfigProvider(tempFile, nil, []string{securitySaltFilePath, securitySiteKeyFilePath}, validator.NewValidator())
require.NoError(t, err)

require.Equal(t, initialPw, c.k.String(databasePasswordKey))
Expand All @@ -237,7 +238,7 @@ func TestNewConfigProvider(t *testing.T) {
err = os.WriteFile(tempFile, newYamlContent, 0644)
require.NoError(t, err)

// sleep for a 100 milliseconds to allow the file watcher to pick up the
// sleep for 100 milliseconds to allow the file watcher to pick up the
// change and reload the config
time.Sleep(100 * time.Millisecond)

Expand Down Expand Up @@ -269,7 +270,7 @@ func TestNewConfigProviderErrorUpdateFailValidate(t *testing.T) {
err = os.WriteFile(tempFile, yamlContent, 0644)
require.NoError(t, err)

c, err := NewConfigProvider(tempFile, nil, []string{testFilePath}, validator.NewValidator())
c, err := NewConfigProvider(tempFile, nil, []string{securitySaltFilePath, securitySiteKeyFilePath}, validator.NewValidator())
require.NoError(t, err)

cfg := c.Get()
Expand Down Expand Up @@ -311,7 +312,7 @@ func TestConfigProviderGet(t *testing.T) {
err = os.WriteFile(tempFile, yamlContent, 0644)
require.NoError(t, err)

c, err := NewConfigProvider(tempFile, nil, []string{testFilePath}, validator.NewValidator())
c, err := NewConfigProvider(tempFile, nil, []string{securitySaltFilePath, securitySiteKeyFilePath}, validator.NewValidator())
require.NoError(t, err)

cfg := c.Get()
Expand Down

0 comments on commit d860980

Please sign in to comment.