Skip to content

Commit

Permalink
chore: remove custom Make targets (#1485)
Browse files Browse the repository at this point in the history
Applies pulumi/ci-mgmt#1292 to this repository
to remove the need for custom Make targets.
  • Loading branch information
t0yv0 authored Jan 16, 2025
1 parent 493c844 commit ece099c
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 80 deletions.
4 changes: 3 additions & 1 deletion .ci-mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ aws: true
major-version: 2
template: generic

buildProviderCmd: "make PROVIDER_BIN=$(1) .make/provider"
buildProviderCmd: "OS=$(1) ARCH=$(2) OUT=$(3) yarn --cwd awsx build"
testProviderCmd: "yarn --cwd awsx test"
renovateCmd: "yarn --cwd awsx dedupe-deps && make generate_sdks"

env:
ALT_AWS_ACCESS_KEY_ID: ${{ secrets.ALT_AWS_ACCESS_KEY_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/upload-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
shell: bash
run: tar -zcf sdk/${{ inputs.language }}.tar.gz -C sdk/${{ inputs.language }} .
- name: Upload artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: ${{ inputs.language }}-sdk.tar.gz
path: ${{ github.workspace}}/sdk/${{ inputs.language }}.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: make provider_dist-${{ matrix.platform.os }}-${{ matrix.platform.arch }}

- name: Upload artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: pulumi-resource-awsx-v${{ inputs.version }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz
path: bin/pulumi-resource-awsx-v${{ inputs.version }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
continue-on-error: true
run: make prepare_local_workspace
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6
with:
version: v1.60
working-directory: provider
4 changes: 2 additions & 2 deletions .github/workflows/prerequisites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ jobs:
Maintainer note: consult the [runbook](https://github.com/pulumi/platform-providers-team/blob/main/playbooks/tf-provider-updating.md) for dealing with any breaking changes.
- name: Upload codegen binary for awsx
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: pulumi-gen-awsx
path: ${{ github.workspace }}/bin/pulumi-gen-awsx
retention-days: 30

- name: Upload schema-embed.json
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: schema-embed.json
path: provider/cmd/pulumi-resource-awsx/schema-embed.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,6 @@ jobs:
with:
providerVersion: ${{ inputs.version }}
# Prelease is run often but we only have 5 concurrent macos runners, so we only test after the stable release.
enableMacosRunner: ${{ inputs.isPrerelease == false }}
enableMacRunner: ${{ inputs.isPrerelease == false }}
skipGoSdk: ${{ inputs.skipGoSdk }}
pythonVersion: ${{ needs.publish_sdk.outputs.python_version }}
4 changes: 2 additions & 2 deletions .github/workflows/verify-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
description: "The version of the provider to verify"
required: true
type: string
enableMacosRunner:
enableMacRunner:
description: "Enable the macos-latest runner in addition to ubuntu-latest and windows-latest. Defaults to 'false'."
required: false
type: boolean
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
# Expression expands to ["ubuntu-latest","windows-latest"] or ["ubuntu-latest","windows-latest","macos-latest"]
# GitHub expressions don't have 'if' statements, so we use a ternary operator to conditionally include the MacOS runner suffix.
# See the docs for a similar example to this: https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson
runner: ${{ fromJSON(format('["ubuntu-latest","windows-latest"{0}]', github.event.inputs.enableMacRunner == 'true' && ',"macos-latest"' || '')) }}
runner: ${{ fromJSON(format('["ubuntu-latest","windows-latest"{0}]', inputs.enableMacRunner && ',"macos-latest"' || '')) }}
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout Repo
Expand Down
36 changes: 0 additions & 36 deletions .mk/build.mk

This file was deleted.

3 changes: 0 additions & 3 deletions .mk/renovate.mk

This file was deleted.

10 changes: 0 additions & 10 deletions .mk/test_provider.mk

This file was deleted.

46 changes: 24 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CODEGEN := pulumi-gen-$(PACK)
PROVIDER := pulumi-resource-$(PACK)
JAVA_GEN := pulumi-java-gen
TESTPARALLELISM := 10
GOTESTARGS := ""
WORKING_DIR := $(shell pwd)
PULUMI_PROVIDER_BUILD_PARALLELISM ?=
PULUMI_CONVERT := 0
Expand Down Expand Up @@ -214,29 +215,26 @@ lint_provider: provider
lint_provider.fix:
cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix
.PHONY: lint_provider lint_provider.fix
build_provider_cmd = OS=$(1) ARCH=$(2) OUT=$(3) yarn --cwd awsx build

provider: bin/$(PROVIDER)

# `make provider_no_deps` builds the provider binary directly, without ensuring that
# `cmd/pulumi-resource-awsx/schema.json` is valid and up to date.
# To create a release ready binary, you should use `make provider`.
build_provider_cmd = make PROVIDER_BIN=$(1) .make/provider
provider: bin/$(PROVIDER)
provider_no_deps:
$(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER))
$(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER))
bin/$(PROVIDER): .make/schema
$(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER))
$(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER))
.PHONY: provider provider_no_deps

test: export PATH := $(WORKING_DIR)/bin:$(PATH)
test:
cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h
cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h $(value GOTESTARGS)
.PHONY: test

test_provider_cmd = yarn --cwd awsx test
test_provider:
cd provider && go test -v -short \
-coverprofile="coverage.txt" \
-coverpkg="./...,github.com/hashicorp/terraform-provider-..." \
-parallel $(TESTPARALLELISM) \
./...
$(call test_provider_cmd)
.PHONY: test_provider

tfgen: schema
Expand Down Expand Up @@ -310,18 +308,18 @@ SKIP_SIGNING ?=

# These targets assume that the schema-embed.json exists - it's generated by tfgen.
# We disable CGO to ensure that the binary is statically linked.
bin/linux-amd64/$(PROVIDER): export GOOS := linux
bin/linux-amd64/$(PROVIDER): export GOARCH := amd64
bin/linux-arm64/$(PROVIDER): export GOOS := linux
bin/linux-arm64/$(PROVIDER): export GOARCH := arm64
bin/darwin-amd64/$(PROVIDER): export GOOS := darwin
bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64
bin/darwin-arm64/$(PROVIDER): export GOOS := darwin
bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64
bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows
bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64
bin/linux-amd64/$(PROVIDER): GOOS := linux
bin/linux-amd64/$(PROVIDER): GOARCH := amd64
bin/linux-arm64/$(PROVIDER): GOOS := linux
bin/linux-arm64/$(PROVIDER): GOARCH := arm64
bin/darwin-amd64/$(PROVIDER): GOOS := darwin
bin/darwin-amd64/$(PROVIDER): GOARCH := amd64
bin/darwin-arm64/$(PROVIDER): GOOS := darwin
bin/darwin-arm64/$(PROVIDER): GOARCH := arm64
bin/windows-amd64/$(PROVIDER).exe: GOOS := windows
bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64
bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar
$(call build_provider_cmd,$(WORKING_DIR)/$@)
$(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@)

@# Only sign windows binary if fully configured.
@# Test variables set by joining with | between and looking for || showing at least one variable is empty.
Expand Down Expand Up @@ -379,6 +377,10 @@ provider_dist-darwin-arm64: bin/$(PROVIDER)-v$(VERSION_GENERIC)-darwin-arm64.tar
provider_dist-windows-amd64: bin/$(PROVIDER)-v$(VERSION_GENERIC)-windows-amd64.tar.gz
provider_dist: provider_dist-linux-amd64 provider_dist-linux-arm64 provider_dist-darwin-amd64 provider_dist-darwin-arm64 provider_dist-windows-amd64
.PHONY: provider_dist-linux-amd64 provider_dist-linux-arm64 provider_dist-darwin-amd64 provider_dist-darwin-arm64 provider_dist-windows-amd64 provider_dist
renovate_cmd = yarn --cwd awsx dedupe-deps && make generate_sdks
renovate:
$(call renovate_cmd)
.PHONY: renovate

# Permit providers to extend the Makefile with provider-specific Make includes.
include $(wildcard .mk/*.mk)
1 change: 1 addition & 0 deletions awsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"scripts": {
"gen-scripts": "curl https://raw.githubusercontent.com/pulumi/pulumi/master/pkg/codegen/schema/pulumi.json | json2ts -o scripts/pulumi-schema.d.ts --unreachableDefinitions --ignoreMinAndMaxItems",
"gen-types": "ts-node scripts/generate-provider-types.ts",
"build": "SCHEMA=../provider/cmd/pulumi-resource-awsx/schema-embed.json ./scripts/build.sh",
"format": "prettier --list-different --write .",
"lint": "tslint -c tslint.json -p tsconfig.json",
"test": "jest",
Expand Down
53 changes: 53 additions & 0 deletions awsx/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

set -euo pipefail

# Bundle a Pulumi Package Schema and create a stand-alone executable versioned build for a desired platform.

: ${OS?"Environment variable OS must be set to the desired operating system for the build in the GOOS format"}
: ${ARCH?"Environment variable ARCH must be set to the desired architecture for the build in the GOARCH format"}
: ${OUT?"Environment variable OUT must be set to the desired output path for the binary"}
: ${SCHEMA?"Environment variable SCHEMA must point to a file with Pulumi Package Schema to embed in the build"}

NODEOS=""
case "${OS}" in
"linux")
NODEOS="linuxstatic"
;;
"darwin")
NODEOS="macos"
;;
"windows")
NODEOS="win"
;;
*)
echo "Unsupported OS: ${OS}"
exit 1
;;
esac

NODEARCH=""
case "${ARCH}" in
"amd64")
NODEARCH="x64"
;;
"arm64")
NODEARCH="arm64"
;;
*)
echo "Unsupported ARCH: ${ARCH}"
exit 1
;;
esac

TARGET="node16-${NODEOS}-${NODEARCH}"
VERSION=$(jq -r .version "${SCHEMA}")

yarn install --no-progress --frozen-lockfile
yarn check-duplicate-deps
yarn gen-types
yarn tsc
cp ${SCHEMA} bin/schema.json
cp package.json bin/package.json
yarn --cwd bin version --new-version "${VERSION}" --no-git-tag-version
yarn run pkg . --no-bytecode --public-packages "*" --public --target "${TARGET}" --output "${OUT}"

0 comments on commit ece099c

Please sign in to comment.