• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fogfish / scud / 16100426599

06 Jul 2025 03:14PM UTC coverage: 85.599% (-3.2%) from 88.828%
16100426599

Pull #36

github

fogfish
optimize hashing for asset via dependency tracing
Pull Request #36: Optimise assets hashing via dependency tracing for Golang modules

87 of 128 new or added lines in 3 files covered. (67.97%)

529 of 618 relevant lines covered (85.6%)

0.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.46
/runtime.go
1
//
2
// Copyright (C) 2020 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the MIT license.  See the LICENSE file for details.
6
// https://github.com/fogfish/scud
7
//
8

9
package scud
10

11
import (
12
        "fmt"
13
        "os"
14
        "path/filepath"
15

16
        "github.com/aws/aws-cdk-go/awscdk/v2"
17
        "github.com/aws/aws-cdk-go/awscdk/v2/awslambda"
18
        "github.com/aws/aws-cdk-go/awscdk/v2/awss3assets"
19
        "github.com/aws/jsii-runtime-go"
20
)
21

22
type Compiler interface {
23
        awscdk.ILocalBundling
24
        SourceCodeModule() string
25
        SourceCodeLambda() string
26
        SourceCodeVersion() string
27
}
28

29
// AssetCodeGo bundles lambda function from source code
30
func AssetCodeGo(compiler Compiler) awslambda.Code {
1✔
31
        hash := NewHasher(false)
1✔
32
        checksum, err := hash.Hash(
1✔
33
                compiler.SourceCodeModule(),
1✔
34
                compiler.SourceCodeLambda(),
1✔
35
                compiler.SourceCodeVersion(),
1✔
36
        )
1✔
37
        if err != nil {
1✔
NEW
38
                panic(fmt.Errorf("failed to compute hash of the source code: %w", err))
×
39
        }
40

41
        return awslambda.NewAssetCode(
1✔
42
                jsii.String("."),
1✔
43
                &awss3assets.AssetOptions{
1✔
44
                        AssetHashType: awscdk.AssetHashType_CUSTOM,
1✔
45
                        AssetHash:     jsii.String(checksum),
1✔
46
                        Bundling: &awscdk.BundlingOptions{
1✔
47
                                Image: awscdk.DockerImage_FromRegistry(jsii.String("golang")),
1✔
48
                                Local: compiler.(awscdk.ILocalBundling),
1✔
49
                                // Note: it make no sense to build Golang code inside container
1✔
50
                        },
1✔
51
                })
1✔
52
}
53

54
func rootSourceCode(sourceCodeModule string) string {
1✔
55
        sourceCode := os.Getenv("GITHUB_WORKSPACE")
1✔
56
        if sourceCode == "" {
1✔
57
                sourceCode = filepath.Join(os.Getenv("GOPATH"), "src", sourceCodeModule)
×
58
        }
×
59

60
        return sourceCode
1✔
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc