1+ # Example workflow for spicehq/cloud to consume the terraform provider artifact
2+ # Copy and adapt this workflow to your e2e test needs
3+ #
4+ # This workflow demonstrates how to:
5+ # 1. Download the pre-built provider from terraform-provider-spiceai (internal repo)
6+ # 2. Configure Terraform to use it via dev overrides
7+ # 3. Run e2e tests with the provider
8+ #
9+ # IMPORTANT: Since terraform-provider-spiceai is an internal repo, you need a PAT
10+ # or GitHub App token with `actions:read` permission on the source repo.
11+ # The default GITHUB_TOKEN does NOT work for cross-repo artifact access.
12+
13+ name : E2E Tests
14+
15+ on :
16+ pull_request :
17+ push :
18+ branches :
19+ - main
20+
21+ permissions :
22+ contents : read
23+
24+ jobs :
25+ e2e :
26+ name : E2E Tests
27+ runs-on : ubuntu-latest
28+ timeout-minutes : 30
29+ steps :
30+ - uses : actions/checkout@v4
31+
32+ # Download the provider artifact from terraform-provider-spiceai repo
33+ #
34+ # Required secret: GH_PAT
35+ # Create a Personal Access Token (classic) or Fine-grained PAT with:
36+ # - actions:read permission on spicehq/terraform-provider-spiceai
37+ # Or use a GitHub App installation token with Actions read permission
38+ #
39+ # To create the secret:
40+ # 1. Go to spicehq/cloud -> Settings -> Secrets and variables -> Actions
41+ # 2. Create a new secret named GH_PAT with your token
42+ - name : Download Terraform Provider
43+ uses : dawidd6/action-download-artifact@v6
44+ with :
45+ github_token : ${{ secrets.GH_PAT }}
46+ repo : spicehq/terraform-provider-spiceai
47+ workflow : build-artifact.yml
48+ branch : main
49+ name : terraform-provider-spiceai_linux_amd64
50+ path : .terraform-provider
51+
52+ # Alternative: Download using GitHub CLI
53+ # Uncomment this block and comment out the above step if you prefer gh cli
54+ # - name: Download Terraform Provider (gh cli)
55+ # env:
56+ # GH_TOKEN: ${{ secrets.GH_PAT }}
57+ # run: |
58+ # mkdir -p .terraform-provider
59+ #
60+ # # Get the latest successful workflow run
61+ # RUN_ID=$(gh run list \
62+ # --repo spicehq/terraform-provider-spiceai \
63+ # --workflow build-artifact.yml \
64+ # --branch main \
65+ # --status success \
66+ # --limit 1 \
67+ # --json databaseId \
68+ # --jq '.[0].databaseId')
69+ #
70+ # # Download the artifact
71+ # gh run download "$RUN_ID" \
72+ # --repo spicehq/terraform-provider-spiceai \
73+ # --name terraform-provider-spiceai_linux_amd64 \
74+ # --dir .terraform-provider
75+
76+ - name : Setup Terraform Provider
77+ run : |
78+ chmod +x .terraform-provider/terraform-provider-spiceai_linux_amd64
79+
80+ # Rename binary to match what Terraform expects
81+ mv .terraform-provider/terraform-provider-spiceai_linux_amd64 \
82+ .terraform-provider/terraform-provider-spiceai
83+
84+ # Create Terraform CLI config with dev override
85+ mkdir -p ~/.terraform.d
86+ cat > ~/.terraform.d/terraformrc << EOF
87+ provider_installation {
88+ dev_overrides {
89+ "spiceai/spiceai" = "${{ github.workspace }}/.terraform-provider"
90+ }
91+ direct {}
92+ }
93+ EOF
94+
95+ - name : Setup Terraform
96+ uses : hashicorp/setup-terraform@v3
97+ with :
98+ terraform_wrapper : false
99+
100+ # Your e2e test steps go here
101+ - name : Run E2E Tests
102+ env :
103+ SPICEAI_CLIENT_ID : ${{ secrets.SPICEAI_CLIENT_ID }}
104+ SPICEAI_CLIENT_SECRET : ${{ secrets.SPICEAI_CLIENT_SECRET }}
105+ TF_CLI_CONFIG_FILE : ~/.terraform.d/terraformrc
106+ run : |
107+ cd path/to/your/terraform/configs
108+
109+ # Note: With dev overrides, Terraform will warn that it's using
110+ # a locally-installed provider. This is expected behavior.
111+ terraform plan
112+ terraform apply -auto-approve
113+
114+ # Run your e2e test assertions here
115+
116+ # Cleanup
117+ terraform destroy -auto-approve
118+
119+ # =============================================================================
120+ # Setup Instructions
121+ # =============================================================================
122+ #
123+ # 1. Create a PAT (Personal Access Token):
124+ # - Go to GitHub Settings -> Developer settings -> Personal access tokens
125+ # - For Fine-grained token (recommended):
126+ # - Resource owner: spicehq
127+ # - Repository access: Select "spicehq/terraform-provider-spiceai"
128+ # - Permissions: Actions (read)
129+ # - For Classic token:
130+ # - Select scope: repo (for internal repos)
131+ #
132+ # 2. Add the PAT as a secret in spicehq/cloud:
133+ # - Go to spicehq/cloud -> Settings -> Secrets and variables -> Actions
134+ # - New repository secret: GH_PAT = <your-token>
135+ #
136+ # 3. Also add Spice.ai credentials as secrets:
137+ # - SPICEAI_CLIENT_ID
138+ # - SPICEAI_CLIENT_SECRET
139+ #
140+ # =============================================================================
141+ # Notes
142+ # =============================================================================
143+ #
144+ # - Artifacts are retained for 90 days by default
145+ # - For macOS runners, use macos-latest and download darwin_arm64 or darwin_amd64
146+ # - The provider is built on every merge to main in terraform-provider-spiceai
0 commit comments