Skip to content

Commit

Permalink
* Run the integration tests with make
Browse files Browse the repository at this point in the history
* Do not add Unit Test if there are only integration tests
  • Loading branch information
anthonydahanne committed Sep 20, 2024
1 parent e235784 commit 5ba9c19
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions octo/octo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
const (
CraneVersion = "0.19.1"
GoVersion = "1.23"
JavaVersion = "17"
PackVersion = "0.34.2"
BuildpackActionsVersion = "5.7.2"
RichGoVersion = "0.3.10"
Expand Down
5 changes: 5 additions & 0 deletions octo/run-integration-tests-composites.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

BP_UNDER_TEST=ttl.sh/${PACKAGE}-${VERSION}:1h make integration
2 changes: 1 addition & 1 deletion octo/statik/statik.go

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions octo/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ContributeTest(descriptor Descriptor) (*Contribution, error) {
Jobs: map[string]actions.Job{},
}

goFiles, err := Find(descriptor.Path, regexp.MustCompile(`.+\.go`).MatchString)
goFilesButNoIntegrationTests, err := Find(descriptor.Path, isGoFileButNotInIntegrationFolder)
if err != nil {
return nil, fmt.Errorf("unable to Find .go files in %s\n%w", descriptor.Path, err)
}
Expand All @@ -69,7 +69,7 @@ func ContributeTest(descriptor Descriptor) (*Contribution, error) {
return nil, fmt.Errorf("unable to Find .go files in %s\n%w", filepath.Join(descriptor.Path, "integration"), err)
}

if len(goFiles) > 0 {
if len(goFilesButNoIntegrationTests) > 0 {
j := actions.Job{
Name: "Unit Test",
RunsOn: []actions.VirtualEnvironment{actions.UbuntuLatest},
Expand Down Expand Up @@ -228,9 +228,17 @@ func ContributeTest(descriptor Descriptor) (*Contribution, error) {
"TTL_SH_PUBLISH": "true",
},
},
actions.Step{
Name: "Set up JDK",
Uses: "actions/setup-java@v5",
With: map[string]interface{}{
"java-version": JavaVersion,
"distribution": "liberica",
},
},
actions.Step{
Name: "Run Integration Tests",
Run: StatikString("/run-integration-tests.sh"),
Run: StatikString("/run-integration-tests-composites.sh"),
Env: map[string]string{
"PACKAGE": "test",
"VERSION": "${{ steps.version.outputs.version }}",
Expand Down Expand Up @@ -281,3 +289,10 @@ func ContributeTest(descriptor Descriptor) (*Contribution, error) {

return &c, nil
}

func isGoFileButNotInIntegrationFolder(path string) bool {
if regexp.MustCompile(`\.go$`).MatchString(path) && !regexp.MustCompile(`^.*integration/`).MatchString(path) {
return true
}
return false
}
2 changes: 1 addition & 1 deletion octo/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ github:
Expect(unitSteps[len(unitSteps)-1].Run).Should(ContainSubstring("richgo test ./... -run Unit"))

createPackageSteps := workflow.Jobs["create-package"].Steps
Expect(createPackageSteps[len(createPackageSteps)-1].Run).Should(ContainSubstring("go test ./integration/... -run Integration"))
Expect(createPackageSteps[len(createPackageSteps)-1].Run).Should(ContainSubstring("BP_UNDER_TEST=ttl.sh/${PACKAGE}-${VERSION}:1h make integration"))
})
})
})
Expand Down

0 comments on commit 5ba9c19

Please sign in to comment.