diff --git a/.github/workflows/validation-aws.yml b/.github/workflows/validation-aws.yml index 154edfa..0f7eecf 100644 --- a/.github/workflows/validation-aws.yml +++ b/.github/workflows/validation-aws.yml @@ -1,23 +1,13 @@ name: AWS Validation Tests on: - schedule: - # Run daily at 2 AM UTC - - cron: "0 2 * * *" workflow_dispatch: - # Allow manual triggering - pull_request: - paths: - - "v1/providers/aws/**" - - "internal/validation/**" - - "v1/**" - branches: [main] + # Run explicitly from the Actions UI, GitHub CLI, or API. jobs: aws-validation: name: AWS Provider Validation runs-on: ubuntu-latest - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/validation-nebius.yml b/.github/workflows/validation-nebius.yml index 781cd3b..9f9c3e3 100644 --- a/.github/workflows/validation-nebius.yml +++ b/.github/workflows/validation-nebius.yml @@ -1,23 +1,13 @@ name: Nebius Validation Tests on: - schedule: - # Run daily at 2 AM UTC - - cron: "0 2 * * *" workflow_dispatch: - # Allow manual triggering - pull_request: - paths: - - "v1/providers/nebius/**" - - "internal/validation/**" - - "v1/**" - branches: [main] + # Run explicitly from the Actions UI, GitHub CLI, or API. jobs: nebius-validation: name: Nebius Provider Validation runs-on: ubuntu-latest - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/validation-shadeform.yml b/.github/workflows/validation-shadeform.yml index e9ead9a..40d24bf 100644 --- a/.github/workflows/validation-shadeform.yml +++ b/.github/workflows/validation-shadeform.yml @@ -1,23 +1,13 @@ name: Shadeform Validation Tests on: - schedule: - # Run daily at 2 AM UTC - - cron: '0 2 * * *' workflow_dispatch: - # Allow manual triggering - pull_request: - paths: - - 'v1/providers/shadeform/**' - - 'internal/validation/**' - - 'v1/**' - branches: [ main ] + # Run explicitly from the Actions UI, GitHub CLI, or API. jobs: shadeform-validation: name: Shadeform Provider Validation runs-on: ubuntu-latest - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/validation-verda.yml b/.github/workflows/validation-verda.yml new file mode 100644 index 0000000..b743690 --- /dev/null +++ b/.github/workflows/validation-verda.yml @@ -0,0 +1,50 @@ +name: Verda Validation Tests + +on: + workflow_dispatch: + # Run explicitly from the Actions UI, GitHub CLI, or API. + +jobs: + verda-validation: + name: Verda Provider Validation + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install dependencies + run: make deps + + - name: Run Verda validation tests + env: + VERDA_CLIENT_ID: ${{ secrets.VERDA_CLIENT_ID }} + VERDA_CLIENT_SECRET: ${{ secrets.VERDA_CLIENT_SECRET }} + TEST_PRIVATE_KEY_BASE64: ${{ secrets.TEST_PRIVATE_KEY_BASE64 }} + TEST_PUBLIC_KEY_BASE64: ${{ secrets.TEST_PUBLIC_KEY_BASE64 }} + VALIDATION_TEST: true + run: | + cd v1/providers/verda + go test -v -short=false -timeout=30m ./... + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: verda-validation-results + path: | + v1/providers/verda/coverage.out diff --git a/Makefile b/Makefile index ad1fbb5..f064f9f 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BINARY_NAME=compute MODULE_NAME=github.com/brevdev/cloud BUILD_DIR=build COVERAGE_DIR=coverage +VALIDATION_REF?=$(shell git branch --show-current) # Load environment variables from .env file if it exists ifneq (,$(wildcard .env)) @@ -79,6 +80,23 @@ test-validation: @echo "Running validation tests..." $(GOTEST) -v -short=false ./... +# Trigger a provider validation workflow in GitHub Actions +.PHONY: trigger-validation +trigger-validation: + @if [ -z "$(PROVIDER)" ]; then \ + echo "Usage: make trigger-validation PROVIDER= [VALIDATION_REF=]"; \ + exit 1; \ + fi + @case "$(PROVIDER)" in \ + aws|nebius|shadeform|verda) ;; \ + *) echo "Unsupported provider: $(PROVIDER). Expected aws, nebius, shadeform, or verda."; exit 1 ;; \ + esac + @if [ -z "$(VALIDATION_REF)" ]; then \ + echo "VALIDATION_REF is required when Git is in a detached HEAD state."; \ + exit 1; \ + fi + gh workflow run validation-$(PROVIDER).yml --ref "$(VALIDATION_REF)" + # Run all tests including validation .PHONY: test-all test-all: @@ -201,24 +219,25 @@ install-tools: .PHONY: help help: @echo "Available targets:" - @echo " build - Build the project" - @echo " build-all - Build for Linux, macOS, and Windows" - @echo " test - Run tests (with -short flag)" - @echo " test-validation - Run validation tests (without -short flag)" - @echo " test-all - Run all tests including validation" - @echo " test-coverage - Run tests with coverage report" - @echo " test-race - Run tests with race detection" - @echo " bench - Run benchmarks" - @echo " lint - Run linter (golangci-lint)" - @echo " vet - Run go vet" - @echo " fmt - Format code" - @echo " fmt-check - Check if code is formatted" - @echo " security - Run security scan (gosec)" - @echo " clean - Clean build artifacts" - @echo " deps - Install dependencies" - @echo " deps-update - Update dependencies" - @echo " deps-verify - Verify dependencies" - @echo " docs - Generate documentation" - @echo " check - Run all checks (lint, vet, fmt-check, test)" - @echo " install-tools - Install development tools" - @echo " help - Show this help message" \ No newline at end of file + @echo " build - Build the project" + @echo " build-all - Build for Linux, macOS, and Windows" + @echo " test - Run tests (with -short flag)" + @echo " test-validation - Run validation tests (without -short flag)" + @echo " trigger-validation - Trigger one provider validation workflow in GitHub Actions" + @echo " test-all - Run all tests including validation" + @echo " test-coverage - Run tests with coverage report" + @echo " test-race - Run tests with race detection" + @echo " bench - Run benchmarks" + @echo " lint - Run linter (golangci-lint)" + @echo " vet - Run go vet" + @echo " fmt - Format code" + @echo " fmt-check - Check if code is formatted" + @echo " security - Run security scan (gosec)" + @echo " clean - Clean build artifacts" + @echo " deps - Install dependencies" + @echo " deps-update - Update dependencies" + @echo " deps-verify - Verify dependencies" + @echo " docs - Generate documentation" + @echo " check - Run all checks (lint, vet, fmt-check, test)" + @echo " install-tools - Install development tools" + @echo " help - Show this help message" diff --git a/v1/providers/verda/validation_test.go b/v1/providers/verda/validation_test.go index 29588f1..a8f7cb1 100644 --- a/v1/providers/verda/validation_test.go +++ b/v1/providers/verda/validation_test.go @@ -21,18 +21,6 @@ func TestValidationFunctions(t *testing.T) { }) } -func TestGetInstance(t *testing.T) { - checkValidationCredentials(t) - credential := validationCredential() - - client, err := credential.MakeClient(context.Background(), "") - require.NoError(t, err) - - instance, err := client.GetInstance(context.Background(), v1.CloudProviderInstanceID("b395e9e7-9a21-4ff1-a4b5-fb06d9652942")) - require.NoError(t, err) - require.NotNil(t, instance) -} - func TestInstanceLifecycleValidation(t *testing.T) { checkValidationCredentials(t)