Skip to content

Commit

Permalink
GitHub Actions workflow to compute provider schema diff (#2740)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Name

* Continue on error
  • Loading branch information
pietern authored Oct 4, 2023
1 parent 173d0c0 commit 3098694
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Provider schema

on:
pull_request:
types: [opened, synchronize]

workflow_dispatch:
inputs:
base:
description: 'Base ref'
default: 'master'
required: true
head:
description: 'Head ref'
default: 'master'
required: true

jobs:
compute_current:
name: "Generate current"
runs-on: ubuntu-latest

steps:
- if: github.event_name == 'pull_request'
name: Checkout
uses: actions/checkout@v4
with:
# Checkout main branch to generate schema for current release
ref: master

- if: github.event_name == 'workflow_dispatch'
name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.base }}

- name: 'Setup Go'
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: 'Setup Terraform'
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false

- run: make install

- name: Generate provider schema
shell: bash
run: |
set -ex
cd /tmp
cat > main.tf <<EOF
terraform {
required_providers {
databricks = {
source = "databricks/databricks"
}
}
}
EOF
terraform init
terraform providers schema -json > provider.json
- name: 'Upload provider schema'
uses: actions/upload-artifact@v3
with:
name: schema-current
path: /tmp/provider.json
retention-days: 1

compute_new:
name: "Generate new"
runs-on: ubuntu-latest

steps:
- if: github.event_name == 'pull_request'
name: Checkout
uses: actions/checkout@v4

- if: github.event_name == 'workflow_dispatch'
name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.head }}

- name: 'Setup Go'
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: 'Setup Terraform'
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false

- run: make install

- name: Generate provider schema
shell: bash
run: |
set -ex
cd /tmp
cat > main.tf <<EOF
terraform {
required_providers {
databricks = {
source = "databricks/databricks"
}
}
}
EOF
terraform init
terraform providers schema -json > provider.json
- name: 'Upload provider schema'
uses: actions/upload-artifact@v3
with:
name: schema-new
path: /tmp/provider.json
retention-days: 1

diff:
needs: [compute_current, compute_new]

name: "Compute diff"
runs-on: ubuntu-latest

steps:
- name: 'Setup Go'
uses: actions/setup-go@v4
with:
go-version: 1.21.x
cache: false

- run: go install github.com/josephburnett/jd@latest

- name: 'Download provider schemas'
uses: actions/download-artifact@v3

- run: ls -l schema*/*

- run: jd -color schema-current/provider.json schema-new/provider.json
continue-on-error: true

0 comments on commit 3098694

Please sign in to comment.