Skip to content

Commit

Permalink
Adds a phone make target to check local schema against master
Browse files Browse the repository at this point in the history
The idea behind this addition is to avoid the CI round-trip for
ensuring our currently generated schema produces the results that we expect.
Currently missing from schema-tools is an implementation of the version command
which means we'll download a new artifact every time we run.

We also don't have a very safe OS check, etc, but it will at least work
on apple machines for the time being.
  • Loading branch information
kpitzen committed Mar 30, 2023
1 parent 842f081 commit 4b1f687
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# WARNING: This file is autogenerated - changes will be overwritten if not made via https://github.com/pulumi/ci-mgmt

.PHONY: check_schema

PACK := aws
ORG := pulumi
PROJECT := github.com/$(ORG)/pulumi-$(PACK)
Expand All @@ -12,10 +14,15 @@ JAVA_GEN := pulumi-java-gen
JAVA_GEN_VERSION := v0.7.1
TESTPARALLELISM := 10
WORKING_DIR := $(shell pwd)
SCHEMA_TOOLS_VERSION := v0.1.3

# Override repo path discovery because we're using a local checkout instead of the go mod
export PULUMI_REPO_PATHS=github.com/hashicorp/terraform-provider-aws=$(WORKING_DIR)/upstream

check_schema:
./scripts/get-schema-tools.sh $(SCHEMA_TOOLS_VERSION)
schema-tools compare -p $(PACK) -o master -n --local-path=provider/cmd/pulumi-resource-$(PACK)/schema.json

development: install_plugins provider build_sdks install_sdks

build: install_plugins provider build_sdks install_sdks
Expand Down
25 changes: 25 additions & 0 deletions scripts/get-schema-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /bin/bash

ACCOUNT='pulumi'
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m|tr '[:upper:]' '[:lower:]')
VERSION=$1

RELEASE_ARTIFACT="schema-tools-${VERSION}-${OS}-${ARCH}.tar.gz"
ARTIFACT_URL="https://github.com/${ACCOUNT}/schema-tools/releases/download/${VERSION}/${RELEASE_ARTIFACT}"

CURRENT_VERSION=$(schema-tools version 2>/dev/null)
echo "Downloading schema-tools ${VERSION} for ${OS} ${ARCH}..."

if [ CURRENT_VERSION == VERSION ]; then
echo "schema-tools ${VERSION} is already installed."
exit 0
else
echo "schema-tools ${CURRENT_VERSION} is installed. Installing ${VERSION}..."
curl -L -o /tmp/${RELEASE_ARTIFACT} ${ARTIFACT_URL}
tar -xzf /tmp/${RELEASE_ARTIFACT} -C /tmp
rm /tmp/${RELEASE_ARTIFACT}

echo "Moving schema-tools to /usr/local/bin - please enter your password if prompted."
sudo mv /tmp/schema-tools /usr/local/bin
fi

0 comments on commit 4b1f687

Please sign in to comment.