From 09d8effd8a8f7b5c3e520ea802c2e66e8688e6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=BChlmann?= Date: Thu, 14 Nov 2024 09:01:42 +0100 Subject: [PATCH] Add build step --- Gemfile.lock | 12 ++++++++++++ ci/main.go | 39 ++++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 18a7940b..ac244302 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,6 +221,7 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) + docile (1.4.1) drb (2.2.0) ruby2_keywords dry-configurable (1.1.0) @@ -617,6 +618,14 @@ GEM websocket (~> 1.0) sentry-raven (3.1.2) faraday (>= 1.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov-rcov (0.3.7) + simplecov (>= 0.4.1) + simplecov_json_formatter (0.1.4) simpleidn (0.2.1) unf (~> 0.1.4) snaky_hash (2.0.1) @@ -736,6 +745,7 @@ DEPENDENCIES m matrix mini_racer + minitest minitest-reporters mocha nested_form_fields @@ -778,6 +788,8 @@ DEPENDENCIES selectize-rails selenium-webdriver sentry-raven + simplecov + simplecov-rcov spring swagger-blocks terser diff --git a/ci/main.go b/ci/main.go index 144f9c30..53342b24 100644 --- a/ci/main.go +++ b/ci/main.go @@ -38,7 +38,11 @@ type Results struct { // Returns a Container built from the Dockerfile in the provided Directory func (m *Ci) Build(_ context.Context, dir *dagger.Directory) *dagger.Container { - return dag.Container().Build(dir) + return dag.Container(). + WithDirectory("/src", dir). + WithWorkdir("/src"). + Directory("/src"). + DockerBuild() } // Returns the result of haml-lint run against the sources in the provided Directory @@ -178,6 +182,11 @@ func (m *Ci) BaseTestContainer(_ context.Context, dir *dagger.Directory) *dagger WithExec([]string{"bundle", "install", "--jobs", "4", "--retry", "3"}) } +// Publish the Container built from the Dockerfile in the provided registry +func (m *Ci) Publish(ctx context.Context, dir *dagger.Directory, destImage string) (string, error) { + return m.Build(ctx, dir).Publish(ctx, destImage) +} + // Executes all the steps and returns a Results object func (m *Ci) Ci( ctx context.Context, @@ -226,14 +235,14 @@ func (m *Ci) CiIntegration( }() /* - var vulnerabilityScan = func() *dagger.File { - defer wg.Done() - return m.Vulnscan(m.Sbom(m.Build(ctx, dir))) - }() - var image = func() *dagger.Container { - defer wg.Done() - return m.Build(ctx, dir) - }() + var vulnerabilityScan = func() *dagger.File { + defer wg.Done() + return m.Vulnscan(m.Sbom(m.Build(ctx, dir))) + }() + var image = func() *dagger.Container { + defer wg.Done() + return m.Build(ctx, dir) + }() */ var testReports = func() *dagger.Directory { @@ -250,11 +259,11 @@ func (m *Ci) CiIntegration( securityScanName, _ := securityScan.Name(ctx) //vulnerabilityScanName, _ := vulnerabilityScan.Name(ctx) result_container := dag.Container(). - WithWorkdir("/tmp/out"). - WithFile(fmt.Sprintf("/tmp/out/lint/%s", lintOutputName), lintOutput). - WithFile(fmt.Sprintf("/tmp/out/scan/%s", securityScanName), securityScan). - WithDirectory("/tmp/out/unit-tests/", testReports) - //WithFile(fmt.Sprintf("/tmp/out/vuln/%s", vulnerabilityScanName), vulnerabilityScan) + WithWorkdir("/tmp/out"). + WithFile(fmt.Sprintf("/tmp/out/lint/%s", lintOutputName), lintOutput). + WithFile(fmt.Sprintf("/tmp/out/scan/%s", securityScanName), securityScan). + WithDirectory("/tmp/out/unit-tests/", testReports) + //WithFile(fmt.Sprintf("/tmp/out/vuln/%s", vulnerabilityScanName), vulnerabilityScan) return result_container. - Directory(".") + Directory(".") }