Skip to content

Commit

Permalink
Porting petoju terraform-provider-mysql (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
marioconsalvo authored Aug 27, 2024
1 parent 4e6a479 commit 54f416d
Show file tree
Hide file tree
Showing 125 changed files with 19,202 additions and 462 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/lint.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: pull-request

on:
workflow_call:
inputs: {}
pull_request:
branches:
- main
- v*
- feature*
paths-ignore:
- CHANGELOG.md

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Install go
uses: actions/setup-go@v4
with:
# The versions of golangci-lint and setup-go here cross-depend and need to update together.
go-version: 1.21
# Either this action or golangci-lint needs to disable the cache
cache: false
- name: disarm go:embed directives to enable lint
continue-on-error: true # this fails if there are no go:embed directives
run: |
git grep -l 'go:embed' -- provider | xargs sed -i 's/go:embed/ goembed/g'
- name: prepare upstream
continue-on-error: true
run: make upstream
- run: cd provider && go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.1
working-directory: provider
skip-pkg-cache: true
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build sdks
run: devbox run -- make build_sdks
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: release
on:
push:
tags:
- v*.*.*
env:
# THIS GITHUB_TOKEN IS A REQUIREMENT TO BE ABLE TO WRITE TO GH RELEASES
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# IF YOU NEED TO PUBLISH A NPM PACKAGE THEN ENSURE A NPM_TOKEN SECRET IS SET
# AND PUBLISH_NPM: TRUE. IF YOU WANT TO PUBLISH TO A PRIVATE NPM REGISTRY
# THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
NPM_REGISTRY_URL: https://registry.npmjs.org
# IF YOU NEED TO PUBLISH A NUGET PACKAGE THEN ENSURE AN NUGET_PUBLISH_KEY
# SECRET IS SET AND PUBLISH_NUGET: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
# NPM REGISTRY THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
# NUGET_PUBLISH_KEY: ${{ YOUR NUGET PUBLISH KEY HERE }}
# NUGET_FEED_URL: https://api.nuget.org/v3/index.json
# PUBLISH_NUGET: true
# IF YOU NEED TO PUBLISH A PYPI PACKAGE SET PUBLISH_PYPI: TRUE AND CHANGE PYPI_PASSWORD, PYPI_USERNAME TO YOUR CREDENTIALS.
# IF YOU WANT TO PUBLISH TO AN ALTERNATIVE PYPI REGISTRY THEN ENSURE THE PYPI_REPOSITORY_URL IS SET.
# PYPI_PASSWORD: ${{ YOUR PYPI PASSWORD HERE }}
# PYPI_USERNAME: "YOUR PYPI USERNAME HERE"
# PYPI_REPOSITORY_URL: ""
# PUBLISH_PYPI: true
jobs:
publish_binary:
name: Publish plugin binary
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{matrix.goversion}}
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.5.0
with:
repo: pulumi/pulumictl
- name: Set PreRelease Version
run: echo "GORELEASER_CURRENT_TAG=v$(pulumictl get version --language generic)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: -p 3 release --clean
version: latest
strategy:
fail-fast: true
matrix:
goversion:
- 1.21.x

publish_sdk:
name: Publish SDKs
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
language:
- nodejs
# - go
# - dotnet
# - python
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Publish SDK
run: devbox run -- make publish_${{ matrix.language }}
File renamed without changes.
13 changes: 7 additions & 6 deletions deployment-templates/.goreleaser.yml → .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: 2
archives:
- id: archive
name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}'
name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
before:
hooks:
- make tfgen
builds:
- binary: pulumi-resource-xyz
- binary: pulumi-resource-mysql
dir: provider
env:
- CGO_ENABLED=0
Expand All @@ -18,12 +19,12 @@ builds:
- linux
ldflags:
# The line below MUST align with the module in current provider/go.mod
- -X github.com/pulumi/pulumi-xyz/provider/pkg/version.Version={{.Tag }}
main: ./cmd/pulumi-resource-xyz/
- -X github.com/unobravo/pulumi-mysql/provider/pkg/version.Version={{.Tag }}
main: ./cmd/pulumi-resource-mysql/
changelog:
skip: true
disable: true
release:
disable: false
prerelease: auto
snapshot:
name_template: '{{ .Tag }}-SNAPSHOT'
version_template: "{{ .Tag }}-SNAPSHOT"
4 changes: 2 additions & 2 deletions COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LICENSE or <http://www.apache.org/licenses/LICENSE-2.0>).
This project is a larger work that combines with software written
by third parties, licensed under their own terms.

Notably, this larger work combines with the Terraform XYZ Provider,
Notably, this larger work combines with the petoju Terraform Mysql Provider,
which is licensed under the Mozilla Public License 2.0 (see
<https://www.mozilla.org/en-US/MPL/2.0/> or the project itself at
<https://github.com/terraform-providers/terraform-provider-aws>).
<https://github.com/petoju/terraform-provider-mysql>).
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PROJECT_NAME := xyz Package
PROJECT_NAME := mysql Package

SHELL := /bin/bash
PACK := xyz
PROJECT := github.com/pulumi/pulumi-xyz
NODE_MODULE_NAME := @abc/${PACK}
PACK := mysql
PROJECT := github.com/unobravo/pulumi-mysql
NODE_MODULE_NAME := @unobravo/${PACK}
TF_NAME := ${PACK}
PROVIDER_PATH := provider
VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version
Expand All @@ -17,7 +17,7 @@ TESTPARALLELISM := 4
WORKING_DIR := $(shell pwd)

OS := $(shell uname)
EMPTY_TO_AVOID_SED :=
EMPTY_TO_AVOID_SED :=

prepare::
@if test -z "${NAME}"; then echo "NAME not set"; exit 1; fi
Expand Down Expand Up @@ -56,7 +56,7 @@ tfgen:: install_plugins
provider:: tfgen install_plugins # build the provider binary
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})

build_sdks:: install_plugins provider build_nodejs build_python build_go build_dotnet # build all the sdks
build_sdks:: install_plugins provider build_nodejs build_go build_python build_dotnet # build all the sdks

build_nodejs:: VERSION := $(shell pulumictl get version --language javascript)
build_nodejs:: install_plugins tfgen # build the node sdk
Expand Down Expand Up @@ -89,6 +89,21 @@ build_dotnet:: install_plugins tfgen # build the dotnet sdk
build_go:: install_plugins tfgen # build the go sdk
$(WORKING_DIR)/bin/$(TFGEN) go --overlays provider/overlays/go --out sdk/go/

publish_nodejs:: build_nodejs
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} && \
cd $(WORKING_DIR)/sdk/nodejs/bin && \
sed -i -e "s/+dirty//" ./package.json && \
npm publish

publish_python::
echo "Not implemented" && exit 1

publish_dotnet::
echo "Not implemented" && exit 1

publish_go::
echo "Not implemented" && exit 1

lint_provider:: provider # lint the provider code
cd provider && golangci-lint run -c ../.golangci.yml

Expand Down
27 changes: 0 additions & 27 deletions deployment-templates/README-DEPLOYMENT.md

This file was deleted.

Loading

0 comments on commit 54f416d

Please sign in to comment.