Skip to content

Commit

Permalink
Merge pull request #1587 from paketo-buildpacks/simplify-its
Browse files Browse the repository at this point in the history
Simplify integration tests
  • Loading branch information
anthonydahanne authored May 10, 2024
2 parents fb5de9c + c779710 commit 22f8660
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 59 deletions.
2 changes: 1 addition & 1 deletion octo/package-buildpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ if [[ "${PUBLISH:-x}" == "true" ]]; then
else
pack -v buildpack package \
"${PACKAGE}:${VERSION}" ${CONFIG} \
--format "${FORMAT}"
--format "${FORMAT}" $([ -n "$TTL_SH_PUBLISH" ] && [ "$TTL_SH_PUBLISH" = "true" ] && echo "--publish")
fi
2 changes: 1 addition & 1 deletion octo/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -euo pipefail

richgo test ./integration/... -run Integration
go test ./integration/... -run Integration
2 changes: 1 addition & 1 deletion octo/statik/statik.go

Large diffs are not rendered by default.

79 changes: 27 additions & 52 deletions octo/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,55 +110,6 @@ func ContributeTest(descriptor Descriptor) (*Contribution, error) {
w.Jobs["unit"] = j
}

if len(integrationTestFiles) > 0 {
j := actions.Job{
Name: "Integration Test",
RunsOn: []actions.VirtualEnvironment{actions.UbuntuLatest},
Steps: []actions.Step{
{
Uses: "actions/checkout@v4",
},
{
Uses: "actions/cache@v4",
With: map[string]interface{}{
"path": "${{ env.HOME }}/go/pkg/mod",
"key": "${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}",
"restore-keys": "${{ runner.os }}-go-",
},
},
{
Uses: "actions/setup-go@v5",
With: map[string]interface{}{"go-version": GoVersion},
},
{
Name: "Install create-package",
Run: StatikString("/install-create-package.sh"),
},
{
Name: "Install pack",
Run: StatikString("/install-experimental-pack.sh"),
},
{
Name: "Enable pack Experimental",
If: fmt.Sprintf("${{ %t }}", descriptor.Package.Platform.OS == PlatformWindows),
Run: StatikString("/enable-pack-experimental.sh"),
},
{
Name: "Install richgo",
Run: StatikString("/install-richgo.sh"),
Env: map[string]string{"RICHGO_VERSION": RichGoVersion},
},
{
Name: "Run Tests",
Run: StatikString("/run-integration-tests.sh"),
Env: map[string]string{"RICHGO_FORCE_COLOR": "1"},
},
},
}

w.Jobs["integration"] = j
}

if descriptor.Builder != nil {
j := actions.Job{
Name: "Create Builder Test",
Expand Down Expand Up @@ -247,16 +198,40 @@ func ContributeTest(descriptor Descriptor) (*Contribution, error) {
"VERSION": "${{ steps.version.outputs.version }}",
},
},
{
},
}

if len(integrationTestFiles) > 0 {
j.Steps = append(j.Steps,
actions.Step{
Name: "Package Buildpack",
Run: StatikString("/package-buildpack.sh"),
Env: map[string]string{
"FORMAT": format,
"PACKAGES": "ttl.sh/test-${{ steps.version.outputs.version }}",
"VERSION": "1h",
"TTL_SH_PUBLISH": "true",
},
},
actions.Step{
Name: "Run Integration Tests",
Run: StatikString("/run-integration-tests.sh"),
Env: map[string]string{
"PACKAGE": "test",
"VERSION": "${{ steps.version.outputs.version }}",
},
})
} else {
j.Steps = append(j.Steps,
actions.Step{
Name: "Package Buildpack",
Run: StatikString("/package-buildpack.sh"),
Env: map[string]string{
"FORMAT": format,
"PACKAGES": "test",
"VERSION": "${{ steps.version.outputs.version }}",
},
},
},
})
}

skipPrefixes := []string{
Expand Down
7 changes: 3 additions & 4 deletions octo/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ package:
var workflow jobs
Expect(yaml.Unmarshal(contribution.Content, &workflow)).To(Succeed())

Expect(len(workflow.Jobs)).To(Equal(3))
Expect(len(workflow.Jobs)).To(Equal(2))
Expect(workflow.Jobs["unit"]).To(Not(BeNil()))
Expect(workflow.Jobs["integration"]).To(Not(BeNil()))

unitSteps := workflow.Jobs["unit"].Steps
Expect(unitSteps[len(unitSteps)-1].Run).Should(ContainSubstring("richgo test ./... -run Unit"))

integrationSteps := workflow.Jobs["integration"].Steps
Expect(integrationSteps[len(integrationSteps)-1].Run).Should(ContainSubstring("richgo test ./integration/... -run Integration"))
createPackageSteps := workflow.Jobs["create-package"].Steps
Expect(createPackageSteps[len(createPackageSteps)-1].Run).Should(ContainSubstring("go test ./integration/... -run Integration"))
})
})
})
Expand Down

0 comments on commit 22f8660

Please sign in to comment.