Skip to content

Commit d71b7d8

Browse files
committed
use interfaces version
1 parent 56e1c06 commit d71b7d8

File tree

4 files changed

+9
-186
lines changed

4 files changed

+9
-186
lines changed

.github/workflows/dagger.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- dagger-generic-pipeline-int
99
- dagger-generic-pipeline-status
1010
- dagger-generic-pipeline-flex
11+
- dagger-generic-pipeline-flex-interfaces
1112
jobs:
1213
pipeline:
1314
runs-on: 'ubuntu-latest'
@@ -24,7 +25,7 @@ jobs:
2425
DT_API_KEY: ${{ secrets.DT_API_KEY }}
2526
with:
2627
# Dagger Version
27-
version: 0.17.1
28+
version: 0.18.6
2829
# Dagger CLI Flags
2930
#dagger-flags: # optional, default is --progress plain
3031
# CLI verb (call, run, download, up, functions, shell, query)
@@ -54,7 +55,7 @@ jobs:
5455
uses: dagger/[email protected]
5556
with:
5657
# Dagger Version
57-
version: 0.17.1
58+
version: 0.18.6
5859
# Dagger CLI Flags
5960
#dagger-flags: # optional, default is --progress plain
6061
# CLI verb (call, run, download, up, functions, shell, query)

ci/implementation/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func (m *Implementation) Postgres(
117117
// +default="latest"
118118
version string,
119119
) *dagger.Service {
120-
121120
return dag.Container().
122121
From(fmt.Sprintf("postgres:%s", version)).
123122
WithEnvVariable("POSTGRES_PASSWORD", "postgres").
@@ -131,7 +130,6 @@ func (m *Implementation) Memcached(
131130
// +default="latest"
132131
version string,
133132
) *dagger.Service {
134-
135133
return dag.Container().
136134
From(fmt.Sprintf("memcached:%s", version)).
137135
WithExposedPort(11211).

ci/main.go

Lines changed: 4 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -21,106 +21,6 @@ import (
2121

2222
type Ci struct{}
2323

24-
/*
25-
// Returns a lint container
26-
func (m *Ci) BuildLintContainer(
27-
dir *dagger.Directory,
28-
// +optional
29-
// +default=false
30-
pass bool,
31-
) *dagger.Container {
32-
return dag.Container().
33-
From("ruby:latest").
34-
WithMountedDirectory("/mnt", dir).
35-
WithWorkdir("/mnt").
36-
WithExec([]string{"gem", "install", "haml-lint"}).
37-
WithExec([]string{"sh", "-c", "mkdir -p /mnt/lint"}).
38-
WithExec(m.lintCommand(pass))
39-
}
40-
41-
// Returns the lint command
42-
func (m *Ci) lintCommand(pass bool) []string {
43-
if pass {
44-
return []string{"sh", "-c", "haml-lint -r json . > lint/lint.json || true"}
45-
}
46-
return []string{"sh", "-c", "haml-lint -r json . > lint/lint.json"}
47-
}
48-
49-
// Returns a sast container
50-
func (m *Ci) BuildSastContainer(dir *dagger.Directory) *dagger.Container {
51-
return dag.Container().
52-
From("presidentbeef/brakeman:latest").
53-
WithMountedDirectory("/app", dir).
54-
WithWorkdir("/app").
55-
WithExec([]string{"sh", "-c", "mkdir -p /app/sast"}).
56-
WithExec([]string{"sh", "-c", "/usr/src/app/bin/brakeman -o /app/sast/brakeman-output.tabs"})
57-
}
58-
59-
// Creates a PostgreSQL service for local testing based on the official image with the provided version. If no version is provided, 'latest' will be used.
60-
func (m *Ci) Postgres(
61-
_ context.Context,
62-
// +optional
63-
// +default="latest"
64-
version string) *dagger.Service {
65-
66-
return dag.Container().
67-
From(fmt.Sprintf("postgres:%s", version)).
68-
WithEnvVariable("POSTGRES_PASSWORD", "postgres").
69-
WithExposedPort(5432).
70-
AsService()
71-
}
72-
73-
// Creates a memcached service for local testing based on the official image with the provided version. If no version is provided, 'latest' will be used.
74-
func (m *Ci) Memcached(
75-
_ context.Context,
76-
// +optional
77-
// +default="latest"
78-
version string) *dagger.Service {
79-
80-
return dag.Container().
81-
From(fmt.Sprintf("memcached:%s", version)).
82-
WithExposedPort(11211).
83-
AsService()
84-
}
85-
86-
// Returns a test container
87-
func (m *Ci) BuildTestContainer(ctx context.Context, dir *dagger.Directory) *dagger.Container {
88-
return m.BaseTestContainer(ctx, dir).
89-
WithServiceBinding("postgresql", m.Postgres(ctx, "11")).
90-
WithServiceBinding("memcached", m.Memcached(ctx, "latest")).
91-
WithExec([]string{"bundle", "exec", "rails", "db:create"}).
92-
WithExec([]string{"bundle", "exec", "rails", "db:migrate"}).
93-
WithExec([]string{"bundle", "exec", "rails", "assets:precompile"}).
94-
WithExec([]string{"sh", "-c", "bundle exec rails test test/controllers test/domain test/fabricators test/fixtures test/helpers test/mailers test/models test/presenters test/support test/tarantula"})
95-
}
96-
97-
// Returns a Container with the base setup for running the rails test suite
98-
func (m *Ci) BaseTestContainer(_ context.Context, dir *dagger.Directory) *dagger.Container {
99-
return dag.Container().
100-
From("registry.puzzle.ch/docker.io/ruby:3.2").
101-
WithExec([]string{"useradd", "-m", "-u", "1001", "ruby"}).
102-
WithMountedDirectory("/mnt", dir, dagger.ContainerWithMountedDirectoryOpts{Owner: "ruby"}).
103-
WithWorkdir("/mnt").
104-
WithEnvVariable("RAILS_DB_HOST", "postgresql"). // This is the service name of the postgres container called by rails
105-
WithEnvVariable("RAILS_TEST_DB_HOST", "postgresql").
106-
WithEnvVariable("RAILS_TEST_DB_NAME", "postgres").
107-
WithEnvVariable("RAILS_TEST_DB_USERNAME", "postgres").
108-
WithEnvVariable("RAILS_TEST_DB_PASSWORD", "postgres").
109-
WithEnvVariable("RAILS_ENV", "test").
110-
WithEnvVariable("CI", "true").
111-
WithEnvVariable("PGDATESTYLE", "German").
112-
WithEnvVariable("TZ", "Europe/Zurich").
113-
WithEnvVariable("DEBIAN_FRONTEND", "noninteractive").
114-
WithEnvVariable("TEST_REPORTS", "true").
115-
WithExec([]string{"apt-get", "update"}).
116-
WithExec([]string{"apt-get", "-yqq", "install", "libpq-dev", "libvips-dev", "chromium", "graphviz", "imagemagick"}).
117-
WithUser("ruby").
118-
//WithExec([]string{"gem", "update", "--system"}).
119-
WithExec([]string{"gem", "install", "bundler", "--version", `~>2`}).
120-
WithExec([]string{"bundle", "install", "--jobs", "4", "--retry", "3"})
121-
}
122-
123-
12424
// Executes all the steps and returns a directory with the results
12525
func (m *Ci) CiIntegration(
12626
ctx context.Context,
@@ -143,90 +43,14 @@ func (m *Ci) CiIntegration(
14343
// +default=false
14444
pass bool,
14545
) *dagger.Directory {
146-
var wg sync.WaitGroup
147-
wg.Add(3)
148-
149-
var lintContainer = func() *dagger.Container {
150-
defer wg.Done()
151-
return m.BuildLintContainer(dir, pass)
152-
}()
153-
154-
var sastContainer = func() *dagger.Container {
155-
defer wg.Done()
156-
return m.BuildSastContainer(dir)
157-
}()
158-
159-
var testContainer = func() *dagger.Container {
160-
defer wg.Done()
161-
return m.BuildTestContainer(ctx, dir)
162-
}()
163-
164-
// This Blocks the execution until its counter become 0
165-
wg.Wait()
166-
167-
return dag.PitcFlow().Flex(
168-
// source directory
169-
dir,
170-
dagger.PitcFlowFlexOpts{
171-
// lint container
172-
LintContainer: lintContainer,
173-
// lint report directory name "lint/lint.json"
174-
LintReportDir: "/mnt/lint",
175-
// sast container
176-
SastContainer: sastContainer,
177-
// security scan report directory name "/app/sast/brakeman-output.tabs"
178-
SastReportDir: "/app/sast",
179-
// test container
180-
TestContainer: testContainer,
181-
// test report folder name "/mnt/test/reports"
182-
TestReportDir: "/mnt/test/reports",
183-
// registry username for publishing the container image
184-
RegistryUsername: registryUsername,
185-
// registry password for publishing the container image
186-
RegistryPassword: registryPassword,
187-
// registry address registry/repository/image:tag
188-
RegistryAddress: registryAddress,
189-
// deptrack address for publishing the SBOM https://deptrack.example.com/api/v1/bom
190-
DtAddress: dtAddress,
191-
// deptrack project UUID
192-
DtProjectUUID: dtProjectUUID,
193-
// deptrack API key
194-
DtAPIKey: dtApiKey},
195-
)
196-
}
197-
*/
198-
199-
// Executes all the steps and returns a directory with the results
200-
func (m *Ci) CiInterface(
201-
ctx context.Context,
202-
// source directory
203-
dir *dagger.Directory,
204-
// registry username for publishing the contaner image
205-
registryUsername string,
206-
// registry password for publishing the container image
207-
registryPassword *dagger.Secret,
208-
// registry address registry/repository/image:tag
209-
registryAddress string,
210-
// deptrack address for publishing the SBOM https://deptrack.example.com/api/v1/bom
211-
dtAddress string,
212-
// deptrack project UUID
213-
dtProjectUUID string,
214-
// deptrack API key
215-
dtApiKey *dagger.Secret,
216-
// ignore linter failures
217-
// +optional
218-
// +default=false
219-
pass bool,
220-
) *dagger.Directory {
221-
222-
return dag.PitcFlow().Flexi(
46+
return dag.PitcFlow().Iflex(
22347
// source directory
22448
dir,
225-
dagger.PitcFlowFlexiOpts{
226-
LintReports: dag.PitcFlow().Lint(dir, true, dag.Implementation().AsPitcFlowLinting()),
49+
dagger.PitcFlowIflexOpts{
50+
LintReports: dag.PitcFlow().Lint(dir, pass, dag.Implementation().AsPitcFlowLinting()),
22751
SecurityReports: dag.PitcFlow().SecurityScan(dir, dag.Implementation().AsPitcFlowSecurityScanning()),
22852
TestReports: dag.PitcFlow().Test(dir, dag.Implementation().AsPitcFlowTesting()),
229-
IntegrationTestReports: dag.PitcFlow().IntegrationTest(dir, dag.Implementation().AsPitcFlowIntegrationTesting()),
53+
//IntegrationTestReports: dag.PitcFlow().IntegrationTest(dir, dag.Implementation().AsPitcFlowIntegrationTesting()),
23054
// registry username for publishing the container image
23155
RegistryUsername: registryUsername,
23256
// registry password for publishing the container image

dagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"dependencies": [
88
{
99
"name": "pitc-flow",
10-
"source": "github.com/puzzle/dagger-module-pitc-flow/pitc-flow@e0f6ec342f0797de171c16346f90a8fce945ad3f",
11-
"pin": "e0f6ec342f0797de171c16346f90a8fce945ad3f"
10+
"source": "github.com/puzzle/dagger-module-pitc-flow/pitc-flow@ee7b3325f2ac3ef40c3a2d1253203dd534de3e70",
11+
"pin": "ee7b3325f2ac3ef40c3a2d1253203dd534de3e70"
1212
},
1313
{
1414
"name": "implementation",

0 commit comments

Comments
 (0)