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 418ad24
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 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
19 changes: 17 additions & 2 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)
goFiles, 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 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: "BP_UNDER_TEST=ttl.sh/${PACKAGE}-${VERSION}:1h make integration",
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 @@ -111,7 +111,7 @@ github:

unitSteps := workflow.Jobs["unit"].Steps
Expect(unitSteps[len(unitSteps)-2].Run).Should(ContainSubstring("richgo test ./... -run Unit"))
Expect(unitSteps[len(unitSteps)-1].Run).Should(ContainSubstring("go test ./integration/... -run Integration"))
Expect(unitSteps[len(unitSteps)-1].Run).Should(ContainSubstring("BP_UNDER_TEST=ttl.sh/${PACKAGE}-${VERSION}:1h make integration"))
})
})

Expand Down

0 comments on commit 418ad24

Please sign in to comment.