Skip to content

Commit c302164

Browse files
committed
fix lint
1 parent 0269f54 commit c302164

File tree

4 files changed

+90
-22
lines changed

4 files changed

+90
-22
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Framework Code Generation
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
defaults:
8+
run:
9+
working-directory: framework/
10+
env:
11+
LOKI_TENANT_ID: promtail
12+
LOKI_URL: http://localhost:3030/loki/api/v1/push
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write
16+
contents: read
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
test:
21+
- name: TestSmokeGenerate
22+
count: 1
23+
timeout: 10m
24+
name: ${{ matrix.test.name }}
25+
steps:
26+
- name: Checkout repo
27+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
28+
- name: Configure AWS credentials using OIDC
29+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
30+
with:
31+
role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }}
32+
aws-region: us-east-1
33+
- name: Authenticate to ECR Public
34+
id: login-ecr-public
35+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
36+
with:
37+
registry-type: public
38+
- name: Set up Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version-file: go.mod
42+
- name: Cache Go modules
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
~/.cache/go-build
47+
~/go/pkg/mod
48+
key: go-modules-${{ hashFiles('framework/go.sum') }}-${{ runner.os }}-framework-codegen
49+
restore-keys: |
50+
go-modules-${{ runner.os }}-framework-codegen
51+
go-modules-${{ runner.os }}
52+
- name: Install dependencies
53+
run: go mod download
54+
- name: Run Codegen Tests
55+
run: |
56+
go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }}
57+
- name: Upload Logs
58+
if: always()
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: container-logs-${{ matrix.test.name }}
62+
path: framework/logs
63+
retention-days: 1

framework/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func BaseConfigName() (string, error) {
237237
if err != nil {
238238
return "", err
239239
}
240-
return strings.Replace(cp, ".toml", "", -1), nil
240+
return strings.ReplaceAll(cp, ".toml", ""), nil
241241
}
242242

243243
// BaseCacheName returns base cache file name, ex.: env.toml -> env-cache.toml
@@ -246,7 +246,7 @@ func BaseCacheName() (string, error) {
246246
if err != nil {
247247
return "", err
248248
}
249-
name := strings.Replace(cp, ".toml", "", -1)
249+
name := strings.ReplaceAll(cp, ".toml", "")
250250
return fmt.Sprintf("%s-cache.toml", name), nil
251251
}
252252

@@ -282,12 +282,12 @@ func Store[T any](cfg *T) error {
282282
if err != nil {
283283
return err
284284
}
285-
newCacheName := strings.Replace(baseConfigPath, ".toml", "", -1)
285+
newCacheName := strings.ReplaceAll(baseConfigPath, ".toml", "")
286286
if strings.Contains(newCacheName, "cache") {
287287
L.Info().Str("Cache", baseConfigPath).Msg("Cache file already exists, skipping")
288288
return nil
289289
}
290-
cachedOutName := fmt.Sprintf("%s-cache.toml", strings.Replace(baseConfigPath, ".toml", "", -1))
290+
cachedOutName := fmt.Sprintf("%s-cache.toml", strings.ReplaceAll(baseConfigPath, ".toml", ""))
291291
L.Info().Str("OutputFile", cachedOutName).Msg("Storing configuration output")
292292
d, err := toml.Marshal(cfg)
293293
if err != nil {
@@ -303,7 +303,7 @@ func Store[T any](cfg *T) error {
303303
}
304304
}
305305

306-
return os.WriteFile(writePath, d, 0600)
306+
return os.WriteFile(writePath, d, 0o600)
307307
}
308308

309309
// JSONStrDuration is JSON friendly duration that can be parsed from "1h2m0s" Go format

framework/tmpl_gen.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,6 @@ type ProductConfigurationSimple struct {
14721472
// TableTestParams params for generating a table test
14731473
type TableTestParams struct {
14741474
Package string
1475-
Namespace string
14761475
TableTestName string
14771476
TestCases []TestCaseParams
14781477
WorkloadCode string
@@ -1490,7 +1489,6 @@ type TestCaseParams struct {
14901489
// EnvBuilder builder for load test codegen
14911490
type EnvBuilder struct {
14921491
nodes int
1493-
namespace string
14941492
outputDir string
14951493
packageName string
14961494
cliName string
@@ -1550,7 +1548,10 @@ func (g *EnvCodegen) Read() error {
15501548
// Write generates a complete boilerplate, can be multiple files
15511549
func (g *EnvCodegen) Write() error {
15521550
// Create output directory
1553-
if err := os.MkdirAll(g.cfg.outputDir, os.ModePerm); err != nil {
1551+
if err := os.MkdirAll( //nolint:gosec
1552+
g.cfg.outputDir,
1553+
os.ModePerm,
1554+
); err != nil {
15541555
return fmt.Errorf("failed to create output directory: %w", err)
15551556
}
15561557

@@ -1559,7 +1560,7 @@ func (g *EnvCodegen) Write() error {
15591560
if err != nil {
15601561
return err
15611562
}
1562-
if err := os.WriteFile(
1563+
if err := os.WriteFile( //nolint:gosec
15631564
filepath.Join(g.cfg.outputDir, "go.mod"),
15641565
[]byte(goModContent),
15651566
os.ModePerm,
@@ -1572,7 +1573,7 @@ func (g *EnvCodegen) Write() error {
15721573
if err != nil {
15731574
return err
15741575
}
1575-
if err := os.WriteFile(
1576+
if err := os.WriteFile( //nolint:gosec
15761577
filepath.Join(g.cfg.outputDir, "Justfile"),
15771578
[]byte(justContents),
15781579
os.ModePerm,
@@ -1585,7 +1586,7 @@ func (g *EnvCodegen) Write() error {
15851586
if err != nil {
15861587
return err
15871588
}
1588-
if err := os.WriteFile(
1589+
if err := os.WriteFile( //nolint:gosec
15891590
filepath.Join(g.cfg.outputDir, "env.toml"),
15901591
[]byte(tomlContents),
15911592
os.ModePerm,
@@ -1594,7 +1595,10 @@ func (g *EnvCodegen) Write() error {
15941595
}
15951596

15961597
cliDir := filepath.Join(g.cfg.outputDir, "cmd", g.cfg.cliName)
1597-
if err := os.MkdirAll(cliDir, os.ModePerm); err != nil {
1598+
if err := os.MkdirAll( //nolint:gosec
1599+
cliDir,
1600+
os.ModePerm,
1601+
); err != nil {
15981602
return fmt.Errorf("failed to create CLI directory: %w", err)
15991603
}
16001604

@@ -1603,7 +1607,7 @@ func (g *EnvCodegen) Write() error {
16031607
if err != nil {
16041608
return err
16051609
}
1606-
if err := os.WriteFile(
1610+
if err := os.WriteFile( //nolint:gosec
16071611
filepath.Join(cliDir, fmt.Sprintf("%s.go", g.cfg.cliName)),
16081612
[]byte(cliContents),
16091613
os.ModePerm,
@@ -1616,7 +1620,7 @@ func (g *EnvCodegen) Write() error {
16161620
if err != nil {
16171621
return err
16181622
}
1619-
if err := os.WriteFile(
1623+
if err := os.WriteFile( //nolint:gosec
16201624
filepath.Join(cliDir, "completion.go"),
16211625
[]byte(completionContents),
16221626
os.ModePerm,
@@ -1629,7 +1633,7 @@ func (g *EnvCodegen) Write() error {
16291633
if err != nil {
16301634
return err
16311635
}
1632-
if err := os.WriteFile(
1636+
if err := os.WriteFile( //nolint:gosec
16331637
filepath.Join(g.cfg.outputDir, "tools.go"),
16341638
[]byte(toolsContents),
16351639
os.ModePerm,
@@ -1642,7 +1646,7 @@ func (g *EnvCodegen) Write() error {
16421646
if err != nil {
16431647
return err
16441648
}
1645-
if err := os.WriteFile(
1649+
if err := os.WriteFile( //nolint:gosec
16461650
filepath.Join(g.cfg.outputDir, "config.go"),
16471651
[]byte(configFileContents),
16481652
os.ModePerm,
@@ -1655,7 +1659,7 @@ func (g *EnvCodegen) Write() error {
16551659
if err != nil {
16561660
return err
16571661
}
1658-
if err := os.WriteFile(
1662+
if err := os.WriteFile( //nolint:gosec
16591663
filepath.Join(g.cfg.outputDir, "cldf.go"),
16601664
[]byte(cldfContents),
16611665
os.ModePerm,
@@ -1668,7 +1672,7 @@ func (g *EnvCodegen) Write() error {
16681672
if err != nil {
16691673
return err
16701674
}
1671-
if err := os.WriteFile(
1675+
if err := os.WriteFile( //nolint:gosec
16721676
filepath.Join(g.cfg.outputDir, "environment.go"),
16731677
[]byte(envFileContents),
16741678
os.ModePerm,
@@ -1681,12 +1685,12 @@ func (g *EnvCodegen) Write() error {
16811685
if err != nil {
16821686
return err
16831687
}
1684-
if err := os.WriteFile(
1688+
if err := os.WriteFile( //nolint:gosec
16851689
filepath.Join(g.cfg.outputDir, "product_configuration.go"),
16861690
[]byte(prodConfigFileContents),
16871691
os.ModePerm,
16881692
); err != nil {
1689-
return fmt.Errorf("failed to write product configration file: %w", err)
1693+
return fmt.Errorf("failed to write product configuration file: %w", err)
16901694
}
16911695

16921696
// tidy and finalize
@@ -1716,7 +1720,7 @@ func (g *EnvCodegen) Write() error {
17161720
func (g *EnvCodegen) GenerateGoMod() (string, error) {
17171721
data := GoModParams{
17181722
ModuleName: g.cfg.moduleName,
1719-
RuntimeVersion: strings.Replace(runtime.Version(), "go", "", -1),
1723+
RuntimeVersion: strings.ReplaceAll(runtime.Version(), "go", ""),
17201724
}
17211725
return render(GoModTemplate, data)
17221726
}

framework/tmpl_gen_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"time"
1010

1111
"github.com/pelletier/go-toml/v2"
12+
"github.com/stretchr/testify/require"
13+
1214
"github.com/smartcontractkit/chainlink-testing-framework/framework"
1315
"github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
14-
"github.com/stretchr/testify/require"
1516

1617
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
1718
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"

0 commit comments

Comments
 (0)