Skip to content

Commit

Permalink
fix(action): review corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicFS committed Sep 11, 2023
1 parent b4cb48b commit 5b18092
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions action/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Setup(ctx context.Context, client *dagger.Client, opts *SetupOpts, dockerfi
var container *dagger.Container
if dockerfileDirectoryPath == "" {
// Use URL
fmt.Printf("Container setup: URL mode")
fmt.Println("Container setup: URL mode")

// Make sure there is a non-empty URL or name provided
if opts.ContainerURL == "" {
Expand All @@ -60,7 +60,7 @@ func Setup(ctx context.Context, client *dagger.Client, opts *SetupOpts, dockerfi
container = client.Container().From(opts.ContainerURL)
} else {
// Use Dockerfile
fmt.Printf("Container setup: Dockerfile mode")
fmt.Println("Container setup: Dockerfile mode")

container = client.Container().Build(
client.Host().Directory(dockerfileDirectoryPath),
Expand Down
7 changes: 5 additions & 2 deletions action/recipes/coreboot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ func TestCoreboot(t *testing.T) {

// Copy over defconfig file into tmpDir
defconfigPath := filepath.Join(common.repoPath, "defconfig")
repoRootPath, err := filepath.Abs(filepath.Join(pwd, "../.."))
assert.NoError(t, err)
// common.repoPath = path to end user repository (in this case somewhere in /tmp)
// repoRootPath = path to our repository with this code (contains configuration files for testing)
err = filesystem.CopyFile(
filepath.Join(pwd, fmt.Sprintf("../../tests/coreboot_%s/seabios.defconfig", corebootVersion)),
filepath.Join(repoRootPath, fmt.Sprintf("tests/coreboot_%s/seabios.defconfig", corebootVersion)),
defconfigPath,
)
// ^^^ this relative path might be funky
assert.NoError(t, err)

// Artifacts
Expand Down
26 changes: 16 additions & 10 deletions action/recipes/linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ import (

func TestLinux(t *testing.T) {
// This test is really slow (like 100 seconds)
/*
if testing.Short() {
t.Skip("skipping test in short mode")
}
*/
if testing.Short() {
t.Skip("skipping test in short mode")
}

pwd, err := os.Getwd()
assert.NoError(t, err)
defer os.Chdir(pwd) // nolint:errcheck

// Use "" if you want to test containers from github package registry
// Use "../../docker/linux" if you want to test containers built fresh from Dockerfile
dockerfilePath := ""
if true {
if false {
dockerfilePath, err = filepath.Abs("../../docker/linux")
assert.NoError(t, err)
}
Expand Down Expand Up @@ -97,13 +96,15 @@ func TestLinux(t *testing.T) {
// create __tmp_files__ directory to store source-code of Linux Kernel
// mostly useful for repeated local-run tests to save bandwidth and time
tmpFiles := filepath.Join(pwd, "__tmp_files__")
err = exec.Command("mkdir", "-p", tmpFiles).Run()
err = os.MkdirAll(tmpFiles, 0o750)
assert.NoError(t, err)
err = os.Chdir(tmpFiles)
assert.NoError(t, err)
defer os.Chdir(pwd) // nolint:errcheck

// Download linux source code to __tmp_files__
var commands [][]string
// TODO: make these commands OS independent
if errors.Is(filesystem.CheckFileExists(fmt.Sprintf("linux-%s", linuxVersion.String())), os.ErrNotExist) {
commands = [][]string{
// Get Linux Kernel sources
Expand All @@ -129,9 +130,15 @@ func TestLinux(t *testing.T) {

// Copy over defconfig file into tmpDir/linux
defconfigPath := filepath.Join(common.repoPath, common.defconfigPath)
defconfigLocalPath, err := filepath.Abs(filepath.Join(pwd, fmt.Sprintf("../../tests/linux_%s/linux.defconfig", linuxVersion.String())))
// ^^^ this relative path might be funky
repoRootPath, err := filepath.Abs(filepath.Join(pwd, "../.."))
assert.NoError(t, err)
// common.repoPath = path to end user repository (in this case somewhere in /tmp)
// repoRootPath = path to our repository with this code (contains configuration files for testing)
defconfigLocalPath, err := filepath.Abs(filepath.Join(
repoRootPath,
fmt.Sprintf("tests/linux_%s/linux.defconfig", linuxVersion.String()),
))
assert.NoErrorf(t, err, "encountered issue with missing files, is '%s' the root of the repo?", repoRootPath)
err = filesystem.CopyFile(
defconfigLocalPath,
defconfigPath,
Expand Down Expand Up @@ -162,7 +169,6 @@ func TestLinux(t *testing.T) {
// Check artifacts
assert.ErrorIs(t, filesystem.CheckFileExists(filepath.Join(outputPath, "vmlinux")), os.ErrExist)
assert.ErrorIs(t, filesystem.CheckFileExists(filepath.Join(outputPath, "defconfig")), os.ErrExist)
assert.NoError(t, os.Chdir(pwd)) // just to make sure
})
}
assert.NoError(t, os.Chdir(pwd)) // just to make sure
Expand Down
7 changes: 1 addition & 6 deletions action/recipes/recipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,5 @@ func buildWithKernelBuildSystem(ctx context.Context, client *dagger.Client, comm
}

// Extract artifacts
err = container.GetArtifacts(ctx, myContainer, artifacts)
if err != nil {
return err
}

return nil
return container.GetArtifacts(ctx, myContainer, artifacts)
}

0 comments on commit 5b18092

Please sign in to comment.