Skip to content

Commit

Permalink
Allow customizing test folder directory and adding kubectl installati…
Browse files Browse the repository at this point in the history
…on (#1316)

This PR contains 2 changes that will not be squashed when merged to
maintain their history.

Changes:

- Enable specifying if `kubectl` needs to be installed in a workflow
- Add a configuration option to specify where integration tests are
located. Defaults to `examples` if unspecified
  • Loading branch information
rquitales authored Jan 27, 2025
1 parent 13e81c8 commit eaa0319
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
8 changes: 8 additions & 0 deletions provider-ci/internal/pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ type Config struct {
// This function is called by the make renovate target after the Renovate bot has finished updating
// project dependencies in a PR. It is responsible for rebuilding any generated files as needed.
RenovateCmd string `yaml:"renovateCmd"`

// InstallKubectl determines if we need to install the kubectl CLI. This will use the latest stable version.
// Used in pulumi-eks currently.
InstallKubectl string `yaml:"install-kubectl"`

// TestFolder defines where the test directory for integration tests is located.
// Defaults to "examples" if not set.
TestFolder string `yaml:"test-folder"`
}

// LoadLocalConfig loads the provider configuration at the given path with
Expand Down
4 changes: 4 additions & 0 deletions provider-ci/internal/pkg/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func GeneratePackage(opts GenerateOpts) error {
opts.Config.ToolVersions.PulumiCTL = defaultPulumiCTLVersion
}

if opts.Config.TestFolder == "" {
opts.Config.TestFolder = "examples"
}

// Clean up old workflows if requested
if opts.Config.CleanGithubWorkflows {
workflows, err := os.ReadDir(filepath.Join(opts.OutDir, ".github", "workflows"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ jobs:
#{{- end }}#
- name: Run tests
if: matrix.testTarget == 'local'
run: cd examples && go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -skip TestPulumiExamples -parallel 4 .
run: cd #{{ .Config.TestFolder }}# && go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -skip TestPulumiExamples -parallel 4 .
- name: Run pulumi/examples tests
if: matrix.testTarget == 'pulumiExamples'
run: cd examples && go test -v -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -run TestPulumiExamples -parallel 4 .
#{{- else }}#
- name: Generate test shards
run: |-
cd examples
cd #{{ .Config.TestFolder }}#
go run github.com/pulumi/shard@861c9ce4aa851e98c19f8376892bf7e47238fa1b \
--total ${{ matrix.total-shards }} \
--index ${{ matrix.current-shard }} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ bin/$(PROVIDER): .make/schema

test: export PATH := $(WORKING_DIR)/bin:$(PATH)
test:
cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h $(value GOTESTARGS)
cd #{{ .Config.TestFolder }}# && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h $(value GOTESTARGS)
.PHONY: test

#{{- if .Config.TestProviderCmd }}#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ runs:
uses: jaxxstorm/action-install-gh-release@cd6b2b78ad38bdd294341cda064ec0692b06215b # v1.14.0
with:
repo: pulumi/schema-tools

#{{- if .Config.InstallKubectl }}#

- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: 'latest'
id: install
#{{- end }}#

- name: Setup Node
if: inputs.tools == 'all' || contains(inputs.tools, 'nodejs')
Expand Down

0 comments on commit eaa0319

Please sign in to comment.