Skip to content

Commit 0f7d250

Browse files
authored
feat: upgrade to project_v2 resources (#16)
* feat: upgrade to project_v2 resources * update integration test job * update integration test job * update example * update versions
1 parent 68e1f47 commit 0f7d250

127 files changed

Lines changed: 9127 additions & 3232 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Summary
2+
3+
<!-- What does this PR do? One paragraph or bullet list. -->
4+
5+
## Type of change
6+
7+
- [ ] Bug fix
8+
- [ ] New feature / resource support
9+
- [ ] Refactoring (no behavior change)
10+
- [ ] Documentation
11+
- [ ] CI / tooling
12+
13+
## Schema changes
14+
15+
- [ ] This PR modifies the YAML schema — `schemas/v1.json` and `docs/configuration/yaml-schema.md` updated
16+
- [ ] No schema changes
17+
18+
## Checklist
19+
20+
- [ ] `make fmt` passes
21+
- [ ] `make test` passes
22+
- [ ] `make lint` passes
23+
- [ ] `CHANGELOG.md` updated under `[Unreleased]`
24+
- [ ] Docs updated if behavior changed

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.tf"
7+
- "tests/**"
8+
- "schemas/**"
9+
- ".github/workflows/ci.yml"
10+
push:
11+
branches: [main]
12+
paths:
13+
- "**.tf"
14+
- "tests/**"
15+
- "schemas/**"
16+
17+
jobs:
18+
validate:
19+
name: Validate
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: hashicorp/setup-terraform@v3
26+
with:
27+
terraform_version_file: .terraform-version
28+
29+
- name: Cache Terraform providers
30+
uses: actions/cache@v4
31+
with:
32+
path: .terraform
33+
key: terraform-${{ hashFiles('.terraform.lock.hcl') }}
34+
restore-keys: terraform-
35+
36+
- name: Format check
37+
run: terraform fmt -check -recursive
38+
39+
- name: Init
40+
run: terraform init -backend=false
41+
42+
- name: Set up tflint
43+
uses: terraform-linters/setup-tflint@v4
44+
with:
45+
tflint_version: latest
46+
47+
- name: Lint
48+
run: |
49+
tflint --init
50+
tflint --recursive
51+
52+
- name: Test (mock providers)
53+
run: terraform test

.github/workflows/integration.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# integration.yml — runs Go/Terratest integration tests against a real dbt Cloud account.
2+
# Triggered manually only to avoid consuming sandbox API quota on every PR.
3+
# Requires secrets: DBT_CLOUD_ACCOUNT_ID, DBT_CLOUD_TOKEN
4+
5+
name: Integration Tests
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
host_url:
11+
description: "dbt Cloud host URL (leave blank for https://cloud.getdbt.com)"
12+
required: false
13+
default: ""
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
integration:
20+
name: Integration Tests
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version: "1.20"
31+
cache-dependency-path: test/go.sum
32+
33+
- name: Setup Terraform
34+
uses: hashicorp/setup-terraform@v3
35+
with:
36+
terraform_version_file: .terraform-version
37+
terraform_wrapper: false
38+
39+
- name: Go mod download
40+
working-directory: test
41+
run: go mod download
42+
43+
- name: Run integration tests
44+
working-directory: test
45+
env:
46+
RUN_INTEGRATION_TESTS: "1"
47+
DBT_CLOUD_ACCOUNT_ID: ${{ secrets.DBT_CLOUD_ACCOUNT_ID }}
48+
DBT_CLOUD_TOKEN: ${{ secrets.DBT_CLOUD_TOKEN }}
49+
DBT_CLOUD_HOST_URL: ${{ github.event.inputs.host_url }}
50+
run: go test -v -timeout 30m -run Integration ./...

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# release.yml — triggered by a version tag (e.g. git tag v1.2.3 && git push --tags).
2+
#
3+
# Produces two release assets:
4+
# starter.tar.gz — the examples/basic/ directory, ready to extract
5+
# install.sh — bootstrap script that downloads starter.tar.gz
6+
7+
name: Release
8+
9+
on:
10+
push:
11+
tags:
12+
- 'v*'
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
release:
19+
name: Create GitHub Release
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Package starter
27+
run: tar -czf starter.tar.gz -C examples/basic .
28+
29+
- name: Create release with assets
30+
uses: softprops/action-gh-release@v2
31+
with:
32+
files: |
33+
install.sh
34+
starter.tar.gz
35+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# test.yml — runs Terraform unit tests on every pull request and push to main.
2+
# Uses mock providers so no dbt Cloud credentials are required.
3+
4+
name: Test
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
root-tests:
17+
name: Root Module Tests
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Terraform
24+
uses: hashicorp/setup-terraform@v3
25+
with:
26+
terraform_version_file: .terraform-version
27+
28+
- name: Terraform Init
29+
run: terraform init -backend=false
30+
31+
- name: Terraform Test
32+
run: terraform test -verbose
33+
34+
module-tests:
35+
name: Module Tests (${{ matrix.module }})
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
module:
40+
- project
41+
- environments
42+
- jobs
43+
- credentials
44+
- repository
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Setup Terraform
51+
uses: hashicorp/setup-terraform@v3
52+
with:
53+
terraform_version_file: .terraform-version
54+
55+
- name: Terraform Init
56+
working-directory: modules/${{ matrix.module }}
57+
run: terraform init -backend=false
58+
59+
- name: Terraform Test
60+
working-directory: modules/${{ matrix.module }}
61+
run: terraform test -verbose

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ override.tf.json
3535
# Ignore CLI configuration files
3636
.terraformrc
3737
terraform.rc
38+
39+
*.DS_Store

.terraform-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.14.8

.terraform.lock.hcl

Lines changed: 20 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.terraformrc.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Terraform CLI config for running tests locally.
2+
# Removes the dev_overrides that point to a local provider build,
3+
# allowing terraform test to use the provider from .terraform/providers/.
4+
#
5+
# Usage:
6+
# TF_CLI_CONFIG_FILE=.terraformrc.test terraform test
7+
# TF_CLI_CONFIG_FILE=/path/to/repo/.terraformrc.test terraform -chdir=modules/project test
8+
9+
provider_installation {
10+
filesystem_mirror {
11+
path = "/Users/tylerrouze/dev/terraform-dbtcloud-yaml/.terraform/providers"
12+
include = ["registry.terraform.io/dbt-labs/dbtcloud"]
13+
}
14+
direct {
15+
exclude = ["registry.terraform.io/dbt-labs/dbtcloud"]
16+
}
17+
}

.tflint.hcl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
plugin "aws" {
2-
enabled = false
3-
}
4-
51
rule "terraform_required_version" {
62
enabled = true
73
}
@@ -21,6 +17,12 @@ rule "terraform_documented_outputs" {
2117
rule "terraform_naming_convention" {
2218
enabled = true
2319
format = "snake_case"
20+
21+
# Allow a leading underscore for locals — used as a convention for
22+
# "private" intermediate locals in validation.tf.
23+
locals {
24+
custom = "^_?[a-z][a-z0-9_]*$"
25+
}
2426
}
2527

2628
rule "terraform_comment_syntax" {
@@ -38,3 +40,7 @@ rule "terraform_unused_required_providers" {
3840
rule "terraform_standard_module_structure" {
3941
enabled = true
4042
}
43+
44+
rule "terraform_module_pinned_source" {
45+
enabled = false
46+
}

0 commit comments

Comments
 (0)