Merge pull request #219 from opentffoundation/update-github-and-release

This commit is contained in:
Elbaz 2023-08-29 14:56:25 +03:00 committed by GitHub
commit c930676fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 37 additions and 461 deletions

View File

@ -22,7 +22,7 @@ The contribution guideline will change in the near future, as the management of
## Proposing a Change
In order to be respectful of the time of community contributors, we aim to discuss potential changes in GitHub issues prior to implementation. That will allow us to give design feedback up front and set expectations about the scope of the change, and, for larger changes, how best to approach the work such that the Terraform team can review it and merge it along with other concurrent work.
In order to be respectful of the time of community contributors, we aim to discuss potential changes in GitHub issues prior to implementation. That will allow us to give design feedback up front and set expectations about the scope of the change, and, for larger changes, how best to approach the work such that the OpenTF team can review it and merge it along with other concurrent work.
If the bug you wish to fix or enhancement you wish to implement isn't already covered by a GitHub issue, please do start a discussion (either in [a new GitHub issue](https://github.com/placeholderplaceholderplaceholder/opentf/issues/new/choose) or an existing one, as appropriate) before you invest significant development time.

View File

@ -1,61 +0,0 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
name: equivalence-test
description: "Execute the suite of Terraform equivalence tests in testing/equivalence-tests"
inputs:
target-terraform-version:
description: "The version of Terraform to use in execution."
required: true
target-terraform-branch:
description: "The branch within this repository to update and compare."
required: true
target-equivalence-test-version:
description: "The version of the Terraform equivalence tests to use."
default: "0.3.0"
target-os:
description: "Current operating system"
default: "linux"
target-arch:
description: "Current architecture"
default: "amd64"
runs:
using: "composite"
steps:
- name: "download equivalence test binary"
shell: bash
run: |
./.github/scripts/equivalence-test.sh download_equivalence_test_binary \
${{ inputs.target-equivalence-test-version }} \
./bin/equivalence-tests \
${{ inputs.target-os }} \
${{ inputs.target-arch }}
- name: "download opentf binary"
shell: bash
run: |
./.github/scripts/equivalence-test.sh download_terraform_binary \
${{ inputs.target-terraform-version }} \
./bin/terraform \
${{ inputs.target-os }} \
${{ inputs.target-arch }}
- name: "run and update equivalence tests"
shell: bash
run: |
./bin/equivalence-tests update \
--tests=testing/equivalence-tests/tests \
--goldens=testing/equivalence-tests/outputs \
--binary=$(pwd)/bin/terraform
changed=$(git diff --quiet -- testing/equivalence-tests/outputs || echo true)
if [[ $changed == "true" ]]; then
echo "found changes, and pushing new golden files into branch ${{ inputs.target-terraform-branch }}."
git config user.email "52939924+teamterraform@users.noreply.github.com"
git config user.name "The OpenTF Team"
git add ./testing/equivalence-tests/outputs
git commit -m "Automated equivalence test golden file update for release ${{ inputs.target-terraform-version }}."
git push
else
echo "found no changes, so not pushing any updates."
fi

View File

@ -7,12 +7,12 @@ set -uo pipefail
if [[ $arch == 'arm' || $arch == 'arm64' ]]
then
export DIR=$(mktemp -d)
unzip -d $DIR "${e2e_cache_path}/terraform-e2etest_${os}_${arch}.zip"
unzip -d $DIR "${e2e_cache_path}/opentf-e2etest_${os}_${arch}.zip"
unzip -d $DIR "./opentf_${version}_${os}_${arch}.zip"
sudo chmod +x $DIR/e2etest
docker run --platform=linux/arm64 -v $DIR:/src -w /src arm64v8/alpine ./e2etest -test.v
else
unzip "${e2e_cache_path}/terraform-e2etest_${os}_${arch}.zip"
unzip "${e2e_cache_path}/opentf-e2etest_${os}_${arch}.zip"
unzip "./opentf_${version}_${os}_${arch}.zip"
TF_ACC=1 ./e2etest -test.v
fi

View File

@ -10,27 +10,14 @@ Usage: ./equivalence-test.sh <command> [<args>] [<options>]
Description:
This script will handle various commands related to the execution of the
Terraform equivalence tests.
opentf equivalence tests.
Commands:
get_target_branch <version>
get_target_branch returns the default target branch for a given Terraform
version.
target_branch=$(./equivalence-test.sh get_target_branch v1.4.3); target_branch=v1.4
target_branch=$(./equivalence-test.sh get_target_branch 1.4.3); target_branch=v1.4
download_equivalence_test_binary <version> <target> <os> <arch>
download_equivalence_test_binary downloads the equivalence testing binary
for a given version and places it at the target path.
./equivalence-test.sh download_equivalence_test_binary 0.3.0 ./bin/terraform-equivalence-testing linux amd64
download_terraform_binary <version> <target> <os> <arch>
download_terraform_binary downloads the terraform release binary for a given
version and places it at the target path.
./equivalence-test.sh download_terraform_binary 1.4.3 ./bin/terraform linux amd64
./equivalence-test.sh download_equivalence_test_binary 0.3.0 ./bin/opentf-equivalence-testing linux amd64
EOF
}
@ -50,7 +37,7 @@ function download_equivalence_test_binary {
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/hashicorp/terraform-equivalence-testing/releases" > releases.json
ASSET="terraform-equivalence-testing_v${VERSION}_${OS}_${ARCH}.zip"
ASSET="opentf-equivalence-testing_v${VERSION}_${OS}_${ARCH}.zip"
ASSET_ID=$(jq -r --arg VERSION "v$VERSION" --arg ASSET "$ASSET" '.[] | select(.name == $VERSION) | .assets[] | select(.name == $ASSET) | .id' releases.json)
mkdir -p zip
@ -65,73 +52,8 @@ function download_equivalence_test_binary {
rm releases.json
}
function download_terraform_binary {
VERSION="${1:-}"
TARGET="${2:-}"
OS="${3:-}"
ARCH="${4:-}"
if [[ -z "$VERSION" || -z "$TARGET" || -z "$OS" || -z "$ARCH" ]]; then
echo "missing at least one of [<version>, <target>, <os>, <arch>] arguments"
usage
exit 1
fi
mkdir -p zip
curl "https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_${OS}_${ARCH}.zip" > "zip/terraform.zip"
mkdir -p bin
unzip -p "zip/terraform.zip" terraform > "$TARGET"
chmod u+x "$TARGET"
rm -r zip
}
function get_target_branch {
VERSION="${1:-}"
if [ -z "$VERSION" ]; then
echo "missing <version> argument"
usage
exit 1
fi
# Split off the build metadata part, if any
# (we won't actually include it in our final version, and handle it only for
# completeness against semver syntax.)
IFS='+' read -ra VERSION BUILD_META <<< "$VERSION"
# Separate out the prerelease part, if any
IFS='-' read -r BASE_VERSION PRERELEASE <<< "$VERSION"
# Separate out major, minor and patch versions.
IFS='.' read -r MAJOR_VERSION MINOR_VERSION PATCH_VERSION <<< "$BASE_VERSION"
if [[ "$PRERELEASE" == *"alpha"* ]]; then
TARGET_BRANCH=main
else
if [[ $MAJOR_VERSION = v* ]]; then
TARGET_BRANCH=${MAJOR_VERSION}.${MINOR_VERSION}
else
TARGET_BRANCH=v${MAJOR_VERSION}.${MINOR_VERSION}
fi
fi
echo "$TARGET_BRANCH"
}
function main {
case "$1" in
get_target_branch)
if [ "${#@}" != 2 ]; then
echo "invalid number of arguments"
usage
exit 1
fi
get_target_branch "$2"
;;
download_equivalence_test_binary)
if [ "${#@}" != 5 ]; then
echo "invalid number of arguments"
@ -141,16 +63,6 @@ function main {
download_equivalence_test_binary "$2" "$3" "$4" "$5"
;;
download_terraform_binary)
if [ "${#@}" != 5 ]; then
echo "invalid number of arguments"
usage
exit 1
fi
download_terraform_binary "$2" "$3" "$4" "$5"
;;
*)
echo "unrecognized command $*"

View File

@ -30,7 +30,7 @@ LDFLAGS="${LDFLAGS} -X 'main.experimentsAllowed=yes'"
fi
LDFLAGS="${LDFLAGS} -X 'github.com/placeholderplaceholderplaceholder/opentf/version.dev=no'"
echo "Building Terraform CLI ${VERSION}"
echo "Building OpenTF CLI ${VERSION}"
if [[ "$EXPERIMENTS_ENABLED" == 1 ]]; then
echo "This build allows use of experimental features"
fi

View File

@ -4,7 +4,7 @@
#
# If you want to test this locally you'll need to set the three arguments
# to values realistic for what the hashicorp/actions-docker-build GitHub
# action would set, and ensure that there's a suitable "terraform" executable
# action would set, and ensure that there's a suitable "opentf" executable
# in the dist/linux/${TARGETARCH} directory.
FROM docker.mirror.hashicorp.services/alpine:latest AS default
@ -13,21 +13,21 @@ FROM docker.mirror.hashicorp.services/alpine:latest AS default
# action, which sets these appropriately based on context.
ARG PRODUCT_VERSION=UNSPECIFIED
ARG PRODUCT_REVISION=UNSPECIFIED
ARG BIN_NAME=terraform
ARG BIN_NAME=opentf
# This argument is set by the Docker toolchain itself, to the name
# of the CPU architecture we're building an image for.
# Our caller should've extracted the corresponding "terraform" executable
# Our caller should've extracted the corresponding "opentf" executable
# into dist/linux/${TARGETARCH} for us to use.
ARG TARGETARCH
LABEL maintainer="HashiCorp Terraform Team <terraform@hashicorp.com>"
LABEL maintainer="OpenTF Team"
# New standard version label.
LABEL version=$PRODUCT_VERSION
# Historical Terraform-specific label preserved for backward compatibility.
LABEL "com.hashicorp.terraform.version"="${PRODUCT_VERSION}"
# Historical OpenTF-specific label preserved for backward compatibility.
LABEL "com.opentf.version"="${PRODUCT_VERSION}"
RUN apk add --no-cache git openssh

View File

@ -1,9 +1,9 @@
---
name: build_terraform
name: build_opentf
# This workflow is intended to be called by the build workflow. The crt make
# targets that are utilized automatically determine build metadata and
# handle building and packing Terraform.
# handle building and packing OpenTF.
on:
workflow_call:
@ -22,7 +22,7 @@ on:
type: string
package-name:
type: string
default: terraform
default: opentf
product-version:
type: string
required: true
@ -36,7 +36,7 @@ on:
jobs:
build:
runs-on: ${{ inputs.runson }}
name: Terraform ${{ inputs.goos }} ${{ inputs.goarch }} v${{ inputs.product-version }}
name: OpenTF ${{ inputs.goos }} ${{ inputs.goarch }} v${{ inputs.product-version }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
@ -44,7 +44,7 @@ jobs:
go-version: ${{ inputs.go-version }}
- name: Determine artifact basename
run: echo "ARTIFACT_BASENAME=${{ inputs.package-name }}_${{ inputs.product-version }}_${{ inputs.goos }}_${{ inputs.goarch }}.zip" >> $GITHUB_ENV
- name: Build Terraform
- name: Build OpenTF
env:
GOOS: ${{ inputs.goos }}
GOARCH: ${{ inputs.goarch }}
@ -72,12 +72,12 @@ jobs:
- if: ${{ inputs.goos == 'linux' }}
uses: hashicorp/actions-packaging-linux@v1
with:
name: "terraform"
description: "Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned."
name: "opentf"
description: "OpenTF enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned."
arch: ${{ inputs.goarch }}
version: ${{ inputs.product-version }}
maintainer: "HashiCorp"
homepage: "https://terraform.io/"
homepage: "https://opentf.org/"
license: "MPL-2.0"
binary: "dist/opentf"
deb_depends: "git"

View File

@ -24,7 +24,7 @@ permissions:
jobs:
get-product-version:
name: "Determine intended Terraform version"
name: "Determine intended OpenTF version"
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-product-version.outputs.product-version }}
@ -53,7 +53,7 @@ jobs:
- name: Report chosen version number
run: |
[ -n "${{steps.get-product-version.outputs.product-version}}" ]
echo "::notice title=Terraform CLI Version::${{ steps.get-product-version.outputs.product-version }}"
echo "::notice title=OpenTF CLI Version::${{ steps.get-product-version.outputs.product-version }}"
get-go-version:
name: "Determine Go toolchain version"
@ -93,7 +93,7 @@ jobs:
needs:
- get-product-version
- get-go-version
uses: ./.github/workflows/build-terraform-oss.yml
uses: ./.github/workflows/build-opentf-oss.yml
with:
goarch: ${{ matrix.goarch }}
goos: ${{ matrix.goos }}
@ -134,7 +134,7 @@ jobs:
arch: ["amd64", "386", "arm", "arm64"]
fail-fast: false
env:
repo: "terraform"
repo: "opentf"
version: ${{needs.get-product-version.outputs.product-version}}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
@ -201,7 +201,7 @@ jobs:
# NOTE: This script reacts to the GOOS, GOARCH, and GO_LDFLAGS
# environment variables defined above. The e2e test harness
# needs to know the version we're building for so it can verify
# that "terraform version" is returning that version number.
# that "opentf version" is returning that version number.
bash ./internal/command/e2etest/make-archive.sh
- name: Save test harness to cache
@ -252,7 +252,7 @@ jobs:
key: ${{ needs.e2etest-build.outputs.e2e-cache-key }}_${{ matrix.goos }}_${{ matrix.goarch }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: "Download Terraform CLI package"
- name: "Download OpenTF CLI package"
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
id: clipkg
with:
@ -261,7 +261,7 @@ jobs:
- name: Extract packages
if: ${{ matrix.goos == 'windows' }}
run: |
unzip "${{ needs.e2etest-build.outputs.e2e-cache-path }}/terraform-e2etest_${{ env.os }}_${{ env.arch }}.zip"
unzip "${{ needs.e2etest-build.outputs.e2e-cache-path }}/opentf-e2etest_${{ env.os }}_${{ env.arch }}.zip"
unzip "./opentf_${{env.version}}_${{ env.os }}_${{ env.arch }}.zip"
- name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
@ -284,7 +284,7 @@ jobs:
e2e-test-exec:
name: Run terraform-exec test for linux amd64
name: Run opentf-exec test for linux amd64
runs-on: ubuntu-latest
needs:
- get-product-version
@ -301,21 +301,21 @@ jobs:
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Download Terraform CLI package
- name: Download OpenTF CLI package
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
id: clipkg
with:
name: opentf_${{ env.version }}_linux_amd64.zip
path: .
- name: Checkout terraform-exec repo
- name: Checkout opentf-exec repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
repository: hashicorp/terraform-exec
path: terraform-exec
- name: Run terraform-exec end-to-end tests
repository: hashicorp/opentf-exec
path: opentf-exec
- name: Run opentf-exec end-to-end tests
run: |
FULL_RELEASE_VERSION="${{ env.version }}"
unzip opentf_${FULL_RELEASE_VERSION}_linux_amd64.zip
export TFEXEC_E2ETEST_TERRAFORM_PATH="$(pwd)/opentf"
cd terraform-exec
cd opentf-exec
go test -race -timeout=30m -v ./tfexec/internal/e2etest

View File

@ -100,7 +100,7 @@ jobs:
e2e-tests:
# This is an intentionally-limited form of our E2E test run which only
# covers Terraform running on Linux. The build.yml workflow runs these
# covers OpenTF running on Linux. The build.yml workflow runs these
# tests across various other platforms in order to catch the rare exception
# that might leak through this.
name: "End-to-end Tests"

View File

@ -1,45 +0,0 @@
name: crt-hook-equivalence-tests
on:
repository_dispatch:
types:
- crt-hook-equivalence-tests::terraform::*
permissions:
contents: write
jobs:
parse-metadata:
name: "Parse metadata.json"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.parse.outputs.version }}
target-branch: ${{ steps.parse.outputs.target-branch }}
steps:
- name: parse
id: parse
env:
METADATA_PAYLOAD: ${{ toJSON(github.event.client_payload.payload) }}
run: |
VERSION=$(echo ${METADATA_PAYLOAD} | jq -r '.version')
TARGET_BRANCH=$(./.github/scripts/equivalence-test.sh get-target-branch "$VERSION")
echo "target-branch=$TARGET_BRANCH" >> "GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
run-equivalence-tests:
runs-on: ubuntu-latest
name: "Run equivalence tests"
needs:
- parse-metadata
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: ${{ needs.parse-metadata.outputs.target-branch }}
- uses: ./.github/actions/equivalence-test
with:
target-terraform-version: ${{ needs.parse-metadata.outputs.version }}
target-terraform-branch: ${{ needs.parse-metadata.outputs.target-branch }}
target-equivalence-test-version: 0.3.0
target-os: linux
target-arch: amd64

View File

@ -1,37 +0,0 @@
name: manual-equivalence-tests
on:
workflow_dispatch:
inputs:
target-branch:
type: string
description: "Which branch should be updated?"
required: true
terraform-version:
type: string
description: "Terraform version to run against (no v prefix, eg. 1.4.4)."
required: true
equivalence-test-version:
type: string
description: 'Equivalence testing framework version to use (no v prefix, eg. 0.3.0).'
default: "0.3.0"
required: true
permissions:
contents: write # We push updates to the equivalence tests back into the repository.
jobs:
run-equivalence-tests:
name: "Run equivalence tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
ref: ${{ inputs.target-branch }}
- uses: ./.github/actions/equivalence-test
with:
target-terraform-version: ${{ inputs.terraform-version }}
target-terraform-branch: ${{ inputs.target-branch }}
target-equivalence-test-version: ${{ inputs.equivalence-test-version }}
target-os: linux
target-arch: amd64

View File

@ -1,169 +0,0 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
schema = "1"
project "terraform" {
// the team key is not used by CRT currently
team = "terraform"
slack {
notification_channel = "C011WJ112MD"
}
github {
organization = "hashicorp"
repository = "terraform"
release_branches = [
"main",
"release/**",
"v**.**",
]
}
}
event "build" {
depends = ["merge"]
action "build" {
organization = "hashicorp"
repository = "terraform"
workflow = "build"
}
}
// Read more about what the `prepare` workflow does here:
// https://hashicorp.atlassian.net/wiki/spaces/RELENG/pages/2489712686/Dec+7th+2022+-+Introducing+the+new+Prepare+workflow
event "prepare" {
depends = ["build"]
action "prepare" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "prepare"
depends = ["build"]
}
notification {
on = "fail"
}
}
## These are promotion and post-publish events
## they should be added to the end of the file after the verify event stanza.
event "trigger-staging" {
// This event is dispatched by the bob trigger-promotion command
// and is required - do not delete.
}
event "promote-staging" {
depends = ["trigger-staging"]
action "promote-staging" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "promote-staging"
config = "release-metadata.hcl"
}
notification {
on = "always"
}
}
event "promote-staging-docker" {
depends = ["promote-staging"]
action "promote-staging-docker" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "promote-staging-docker"
}
notification {
on = "always"
}
}
event "promote-staging-packaging" {
depends = ["promote-staging-docker"]
action "promote-staging-packaging" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "promote-staging-packaging"
}
notification {
on = "always"
}
}
event "trigger-production" {
// This event is dispatched by the bob trigger-promotion command
// and is required - do not delete.
}
event "promote-production" {
depends = ["trigger-production"]
action "promote-production" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "promote-production"
}
notification {
on = "always"
}
}
event "promote-production-docker" {
depends = ["promote-production"]
action "promote-production-docker" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "promote-production-docker"
}
notification {
on = "always"
}
}
event "promote-production-packaging" {
depends = ["promote-production-docker"]
action "promote-production-packaging" {
organization = "hashicorp"
repository = "crt-workflows-common"
workflow = "promote-production-packaging"
}
notification {
on = "always"
}
}
// commenting the ironbank update for now until it is all set up on the Ironbank side
// event "update-ironbank" {
// depends = ["promote-production-packaging"]
// action "update-ironbank" {
// organization = "hashicorp"
// repository = "crt-workflows-common"
// workflow = "update-ironbank"
// }
// notification {
// on = "always"
// }
// }
event "crt-hook-tfc-upload" {
// this will need to be changed back to update-ironbank once the Ironbank setup is done
depends = ["promote-production-packaging"]
action "crt-hook-tfc-upload" {
organization = "hashicorp"
repository = "terraform-releases"
workflow = "crt-hook-tfc-upload"
}
notification {
on = "always"
}
}

View File

@ -1,8 +0,0 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
url_docker_registry_dockerhub = "https://hub.docker.com/r/hashicorp/terraform"
url_docker_registry_ecr = "https://gallery.ecr.aws/hashicorp/terraform"
url_license = "https://github.com/placeholderplaceholderplaceholder/opentf/blob/main/LICENSE"
url_project_website = "https://www.placeholderplaceholderplaceholder.io"
url_source_repository = "https://github.com/hashicorp/terraform"

View File

@ -1,16 +0,0 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
container {
dependencies = false
alpine_secdb = true
secrets = false
}
binary {
secrets = true
go_modules = true
osv = false
oss_index = true
nvd = false
}

View File

@ -32,7 +32,7 @@ GOOS="$(go env GOOS)"
GOARCH="$(go env GOARCH)"
GOEXE="$(go env GOEXE)"
OUTDIR="build/${GOOS}_${GOARCH}"
OUTFILE="terraform-e2etest_${GOOS}_${GOARCH}.zip"
OUTFILE="opentf-e2etest_${GOOS}_${GOARCH}.zip"
LDFLAGS="-X github.com/placeholderplaceholderplaceholder/opentf/internal/command/e2etest.terraformBin=./opentf$GOEXE"
# Caller may pass in the environment variable GO_LDFLAGS with additional