Skip to content

Commit

Permalink
Merge branch 'main' into refactor-go-releaser-config
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascamata authored Jan 20, 2025
2 parents 13c8488 + e2502b0 commit 54fb332
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
fetch-depth: 0

- name: Setup QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
with:
platforms: arm64,ppc64le,linux/arm/v7,s390x

Expand Down Expand Up @@ -153,15 +153,15 @@ jobs:

- name: Upload linux service packages
if: ${{ matrix.GOOS == 'linux' && matrix.GOARCH == 'amd64' }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: linux-packages
path: distributions/${{ inputs.distribution }}/dist/linux_amd64_v1/*
if-no-files-found: error

- name: Upload MSI packages
if: matrix.GOOS == 'windows' && matrix.GOARCH == 'amd64'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: msi-packages
path: distributions/${{ inputs.distribution }}/dist/windows_amd64_v1/**/*.msi
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/base-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- uses: anchore/sbom-action/download-syft@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9

- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
with:
platforms: arm64,ppc64le,linux/arm/v7,s390x

Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
COSIGN_YES: true
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: artifacts-${{ inputs.distribution }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: distributions/${{ inputs.distribution }}/dist/**/*
Expand All @@ -153,7 +153,7 @@ jobs:

- uses: anchore/sbom-action/download-syft@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9

- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
with:
platforms: arm64,ppc64le,s390x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/builder-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: cp cmd/builder/Dockerfile .core/cmd/builder/Dockerfile
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
- uses: anchore/sbom-action/download-syft@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9
- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
with:
platforms: amd64, arm64,ppc64le
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/builder-testbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: cp cmd/builder/Dockerfile .core/cmd/builder/Dockerfile
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
- uses: anchore/sbom-action/download-syft@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9
- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
with:
platforms: amd64, arm64,ppc64le
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CHLOGGEN_CONFIG := .chloggen/config.yaml
DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-otlp"

ci: check build
check: ensure-goreleaser-up-to-date
check: ensure-goreleaser-up-to-date validate-components

build: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER}
Expand All @@ -38,6 +38,9 @@ goreleaser-verify: goreleaser
ensure-goreleaser-up-to-date: generate-goreleaser
@git diff -s --exit-code distributions/*/.goreleaser.yaml || (echo "Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1)

validate-components:
@./scripts/validate-components.sh

.PHONY: ocb
ocb:
ifeq (, $(shell command -v ocb 2>/dev/null))
Expand Down
88 changes: 88 additions & 0 deletions scripts/validate-components.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# This script verifies that all components declared in manifest.yaml files are
# defined in the builder-config.yaml from the opentelemetry-collector-contrib
# repository, ensuring they were built and tested successfully.

set -euo pipefail

BUILDER_CONFIG_URL="https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/main/cmd/otelcontribcol/builder-config.yaml"
MANIFEST_DIR="distributions"

# Ensure required tools are available
if ! command -v curl &> /dev/null || ! command -v yq &> /dev/null; then
echo "This script requires 'curl' and 'yq'. Please install them and try again."
exit 1
fi

# Fetch and parse valid components from builder-config.yaml
echo "Fetching builder-config.yaml..."
valid_components="$(
curl -s "$BUILDER_CONFIG_URL" \
| yq -r '
(
.extensions[]?.gomod,
.receivers[]?.gomod,
.connectors[]?.gomod,
.processors[]?.gomod,
.exporters[]?.gomod,
.providers[]?.gomod
)
' \
| awk '{print $1}' \
| sort -u
)"

if [[ -z "$valid_components" ]]; then
echo "Error: No valid 'gomod' entries found in builder-config.yaml!"
exit 1
fi

echo "Verifying all manifest.yaml files in '${MANIFEST_DIR}'..."

# We accumulate invalid components here as a multi-line string
invalid_components=""

# Use process substitution to avoid subshell issues
while IFS= read -r manifest_file; do
echo "Checking $manifest_file"

# Extract and trim components from the local manifest.yaml
manifest_components="$(
yq -r '
(
.extensions[]?.gomod,
.receivers[]?.gomod,
.connectors[]?.gomod,
.processors[]?.gomod,
.exporters[]?.gomod,
.providers[]?.gomod
)
' "$manifest_file" \
| awk '{print $1}' \
| sort -u
)"

# Compare each manifest component against the valid list
while IFS= read -r component; do
if ! printf '%s\n' "$valid_components" | grep -qxF "$component"; then
invalid_components="${invalid_components}\n${component}"
fi
done <<< "$manifest_components"

done < <(find "$MANIFEST_DIR" -type f -name "manifest.yaml")

if [[ -n "$invalid_components" ]]; then
echo
echo "The following components MUST be listed in"
echo "https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/otelcontribcol/builder-config.yaml"
echo "to ensure that they can be built:"
printf '%b\n' "$invalid_components" | sort -u
echo
exit 1
else
echo "All manifest.yaml components are valid!"
fi

0 comments on commit 54fb332

Please sign in to comment.