Skip to content

Commit d860980

Browse files
authored
ci: bit of CI work
1 parent 624c134 commit d860980

File tree

4 files changed

+14
-27
lines changed

4 files changed

+14
-27
lines changed

.github/workflows/sonarcloud.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
experimental: true
2525
- run: mise run dev:lint --no-fail
26-
- run: mise run test:unit --ci
26+
- run: mise run test:unit
2727
- name: SonarCloud Scan
2828
uses: sonarsource/sonarcloud-github-action@6bbd64e0cb2194e04addb429d669a9ee873eeeef
2929
env:

.mise/tasks/dev/lint

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ if test "$fix" = 0; then
2525
fixflags="--fix"
2626
fi
2727

28-
golangci-lint run --issues-exit-code="$nofail" $fixflags
28+
golangci-lint run \
29+
--issues-exit-code="$nofail" \
30+
--max-issues-per-linter 0 \
31+
--max-same-issues 0 \
32+
$fixflags

.mise/tasks/test/unit

+2-20
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,7 @@
22
# mise sources=["go.mod", "go.sum", "internal/**/*", "cmd/**/*", "*.go"]
33
# mise outputs=["build/unit_coverage.out", "build/unit_test_report.json"]
44

5-
ci=1
6-
7-
handle_argument() {
8-
echo "Argument '$1' not supported" >&2; exit 1
9-
}
10-
11-
while test "$#" -gt 0; do
12-
case "$1" in
13-
--ci) ci=0; shift 1;;
14-
15-
-*) echo "unknown option: $1" >&2; exit 1;;
16-
*) handle_argument "$1"; shift 1;;
17-
esac
18-
done
19-
205
mkdir -p build
216

22-
if test "$ci" = 0; then
23-
go test -coverprofile build/unit_coverage.out -json ./... > build/unit_test_report.json || true
24-
else
25-
go test -coverprofile build/unit_coverage.out ./...
26-
fi
7+
go test -json ./... > build/unit_test_report.json || true
8+
go test -coverprofile build/unit_coverage.out ./...

internal/configProvider/config_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ import (
3535
)
3636

3737
var testYamlFilePath = "testdata/config.yaml"
38+
var securitySaltFilePath = "testdata/security.salt"
39+
var securitySiteKeyFilePath = "testdata/security.sitekey"
3840
var testFilePath = "testdata/test.file"
3941
var databaseUserKey = "database.user"
4042
var databasePasswordKey = "database.password"
4143
var nonExistentYamlFilePath = "testdata/non-existent.yaml"
42-
var newUserNameString = "new-username"
4344
var newPasswordString = "new-password 42 c@t"
4445
var rootConfigYamlPath = "/config.yaml"
4546

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

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

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

240-
// sleep for a 100 milliseconds to allow the file watcher to pick up the
241+
// sleep for 100 milliseconds to allow the file watcher to pick up the
241242
// change and reload the config
242243
time.Sleep(100 * time.Millisecond)
243244

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

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

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

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

317318
cfg := c.Get()

0 commit comments

Comments
 (0)