Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Terraform CI for build and integration tests #1203

Merged
merged 7 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
push:
branches: [master]
pull_request:

permissions:
# Permission for checking out code
contents: read

jobs:
build:
name: Check & Build Provider
akinross marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: chmod +x ./scripts/gofmtcheck.sh
- name: gofmt Check
run: ./scripts/gofmtcheck.sh
- run: go mod tidy
- run: go mod vendor
- name: Check vendor for changes
run: git diff --exit-code
- name: Build
run: go build -v

# diff:
lhercot marked this conversation as resolved.
Show resolved Hide resolved
# name: Check Generated Code Difference
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-go@v5
# with:
# go-version-file: 'go.mod'
# - name: Generate provider code
# run: go generate
# - name: Check generated code for diffs
# run: git diff --exit-code

acceptance:
name: Acceptance Tests
needs: [build]
runs-on: ubuntu-latest
env:
ACI_USERNAME: 'ansible_github_ci'
ACI_PASSWORD: 'sJ94G92#8dq2hx*K4qh'
concurrency:
group: tf-aci-ci-test-${{ matrix.apic_host.name }}
cancel-in-progress: false
strategy:
fail-fast: false
matrix:
apic_host:
# - name: v4.2
lhercot marked this conversation as resolved.
Show resolved Hide resolved
# url: 'https://173.36.219.68/'
- name: v5.2
url: 'https://173.36.219.69/'
- name: v6.0
url: 'https://173.36.219.70/'
# - name: aws_cloud
# url: 'https://52.52.20.121/'
# - name: azure_cloud
# url: 'https://20.245.236.136/'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: '1.7.*'
akinross marked this conversation as resolved.
Show resolved Hide resolved
terraform_wrapper: false
- name: Terraform Acceptance Test (APIC ${{ matrix.apic_host.name }})
run: go test github.com/CiscoDevNet/terraform-provider-aci/v2/internal/provider -v -timeout 300m -coverprofile=coverage.out -covermode=atomic
env:
TF_ACC: '1'
TF_ACC_STATE_LINEAGE: '1'
ACI_VAL_REL_DN: false
ACI_URL: ${{ matrix.apic_host.url }}
- name: Upload coverage to Codecov
# Upload Coverage on latest only
if: ${{ matrix.apic_host.name == 'v6.0'}}
uses: codecov/codecov-action@v3
14 changes: 12 additions & 2 deletions internal/provider/data_source_aci_rest_managed.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ type AciRestManagedDataSource struct {
client *client.Client
}

// AciRestManagedDataSourceModel describes the data source model.
type AciRestManagedDataSourceModel struct {
Id types.String `tfsdk:"id"`
Dn types.String `tfsdk:"dn"`
ClassName types.String `tfsdk:"class_name"`
Content types.Map `tfsdk:"content"`
Child types.Set `tfsdk:"child"`
Annotation types.String `tfsdk:"annotation"`
}

func (d *AciRestManagedDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
tflog.Debug(ctx, "Start schema of datasource: aci_rest_managed")
resp.TypeName = req.ProviderTypeName + "_rest_managed"
Expand Down Expand Up @@ -110,7 +120,7 @@ func (d *AciRestManagedDataSource) Configure(ctx context.Context, req datasource

func (d *AciRestManagedDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Start read of datasource: aci_rest_managed")
var data *AciRestManagedResourceModel
var data *AciRestManagedDataSourceModel

// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
Expand Down Expand Up @@ -202,7 +212,7 @@ func (d *AciRestManagedDataSource) Read(ctx context.Context, req datasource.Read

}

func dataSourceRestManagedNotFoundError(diags *diag.Diagnostics, data *AciRestManagedResourceModel) {
func dataSourceRestManagedNotFoundError(diags *diag.Diagnostics, data *AciRestManagedDataSourceModel) {
diags.AddError(
"Failed to read aci_rest_managed data source",
fmt.Sprintf("The aci_rest_managed data source with dn '%s' has not been found", data.Dn),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ github.com/hashicorp/terraform-plugin-framework/provider/schema
github.com/hashicorp/terraform-plugin-framework/providerserver
github.com/hashicorp/terraform-plugin-framework/resource
github.com/hashicorp/terraform-plugin-framework/resource/schema
github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault
github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults
github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier
github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier
Expand Down
Loading