-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Justin Kolberg <amd.prophet@gmail.com>
- Loading branch information
1 parent
f5fdc63
commit 10044b7
Showing
18 changed files
with
593 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
name: Build Otelcol Config Tool | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
arch_os: | ||
description: Architecture and OS in the form "{arch}_{os}". See GOARCH and GOOS for accepted values. | ||
default: linux_amd64 | ||
type: string | ||
sumo_component_gomod_version: | ||
description: Package version for components hosted in this repo. Normally, this is the v0.0.0-00010101000000-000000000000 placeholder. | ||
type: string | ||
required: false | ||
fips: | ||
description: Build binary with FIPS support | ||
default: false | ||
type: boolean | ||
runs-on: | ||
default: ubuntu-20.04 | ||
type: string | ||
save-cache: | ||
description: Save the module and build caches. | ||
default: false | ||
type: boolean | ||
secrets: | ||
apple_developer_certificate_p12_base64: | ||
required: false | ||
apple_developer_certificate_password: | ||
required: false | ||
app_store_connect_password: | ||
required: false | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
GO_VERSION: "1.21.4" | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ${{ inputs.runs-on }} | ||
env: | ||
FIPS_SUFFIX: ${{ inputs.fips && '-fips' || '' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Fetch current branch | ||
run: ./ci/fetch_current_branch.sh | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache: false | ||
|
||
- name: Get Go env values | ||
run: | | ||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV" | ||
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_ENV" | ||
echo "GOARCH=$(go env GOARCH)" >> "$GITHUB_ENV" | ||
echo "GOOS=$(go env GOOS)" >> "$GITHUB_ENV" | ||
echo "ARCH_OS=$(go env GOOS)_$(go env GOARCH)" >> $GITHUB_ENV | ||
- name: Get cache key | ||
id: get-cache-key | ||
run: | | ||
echo "cache-key=go-build-${{ env.GO_VERSION }}-otelcol-config${FIPS_SUFFIX}-${{inputs.arch_os}}-${{ hashFiles('pkg/tools/otelcol-config/go.sum') }}" >> $GITHUB_OUTPUT | ||
echo "restore-keys=go-build-${{ env.GO_VERSION }}-otelcol-config${FIPS_SUFFIX}-${{inputs.arch_os}}-" >> $GITHUB_OUTPUT | ||
echo "toolchain-cache-key=toolchain-${{inputs.arch_os}}-${{ hashFiles('pkg/tools/otelcol-config/build-fips/config.mak', 'pkg/tools/otelcol-config/build-fips/Makefile') }}" >> $GITHUB_OUTPUT | ||
- uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
${{ env.GOMODCACHE }}/cache | ||
${{ env.GOCACHE }} | ||
key: ${{ steps.get-cache-key.outputs.cache-key }} | ||
restore-keys: | | ||
${{ steps.get-cache-key.outputs.restore-keys }} | ||
- name: Build | ||
if: '! inputs.fips' | ||
run: make otelcol-config-${{inputs.arch_os}} | ||
working-directory: ./pkg/tools/otelcol-config | ||
|
||
- uses: actions/cache/restore@v4 | ||
id: restore-toolchain-cache | ||
if: inputs.fips && contains(inputs.arch_os, 'linux') | ||
with: | ||
path: | | ||
/opt/toolchain | ||
key: ${{ steps.get-cache-key.outputs.toolchain-cache-key }} | ||
|
||
# TODO: pass go version to toolchain make target | ||
- name: Rebuild Toolchains | ||
id: rebuild-toolchain | ||
if: ${{ steps.restore-toolchain-cache.outcome == 'success' && steps.restore-toolchain-cache.outputs.cache-hit != 'true' }} | ||
run: make toolchain-${{ inputs.arch_os }} OUTPUT=/opt/toolchain -j3 | ||
working-directory: ./toolchains | ||
|
||
- name: Build (FIPS) | ||
if: inputs.fips && contains(inputs.arch_os, 'linux') | ||
run: | | ||
CC=$(find /opt/toolchain/bin -type f -name "*-linux-musl-gcc") | ||
test "$CC" | ||
echo "Using toolchain: $CC" | ||
make otelcol-config-${{inputs.arch_os}} \ | ||
FIPS_SUFFIX="-fips" \ | ||
CGO_ENABLED="1" \ | ||
CC="$CC" \ | ||
EXTRA_LDFLAGS="-linkmode external -extldflags '-static'" | ||
working-directory: ./pkg/tools/otelcol-config | ||
|
||
- name: Build (FIPS) | ||
if: inputs.fips && contains(inputs.arch_os, 'linux') | ||
run: | | ||
CC=$(find /opt/toolchain/bin -type f -name "*-linux-musl-gcc") | ||
test "$CC" | ||
echo "Using toolchain: $CC" | ||
make otelcol-config-${{inputs.arch_os}} \ | ||
FIPS_SUFFIX="-fips" \ | ||
CGO_ENABLED="1" \ | ||
CC="$CC" \ | ||
EXTRA_LDFLAGS="-linkmode external -extldflags '-static'" | ||
working-directory: ./pkg/tools/otelcol-config | ||
|
||
- name: Set binary name | ||
id: set-binary-name | ||
run: echo "binary_name=otelcol-config${FIPS_SUFFIX}-${{inputs.arch_os}}" >> $GITHUB_OUTPUT | ||
|
||
- name: Show BoringSSL symbols | ||
if: inputs.fips && contains(inputs.arch_os, 'linux') | ||
working-directory: ./pkg/tools/otelcol-config | ||
run: | | ||
go tool nm ${{ steps.set-binary-name.outputs.binary_name }} | \ | ||
grep "_Cfunc__goboringcrypto_" | ||
# TODO: find a way to test if the binary runs | ||
# - name: Test binary | ||
# if: inputs.arch_os == env.ARCH_OS | ||
# working-directory: ./pkg/tools/otelcol-config | ||
# run: | | ||
# ./${{ steps.set-binary-name.outputs.binary_name }} -t foo | ||
|
||
- name: Store binary as action artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.set-binary-name.outputs.binary_name }} | ||
path: ./pkg/tools/otelcol-config/${{ steps.set-binary-name.outputs.binary_name }} | ||
if-no-files-found: error | ||
|
||
- uses: actions/cache/save@v4 | ||
if: ${{ steps.rebuild-toolchain.outcome == 'success' }} | ||
with: | ||
path: | | ||
/opt/toolchain | ||
key: ${{ steps.get-cache-key.outputs.toolchain-cache-key }} | ||
|
||
- uses: actions/cache/save@v4 | ||
if: inputs.save-cache | ||
with: | ||
path: | | ||
${{ env.GOMODCACHE }}/cache | ||
${{ env.GOCACHE }} | ||
key: ${{ steps.get-cache-key.outputs.cache-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Run tests (otelcol-config) | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
arch_os: | ||
description: Architecture and OS in the form "{arch}_{os}". See GOARCH and GOOS for accepted values. | ||
default: linux_amd64 | ||
type: string | ||
boringcrypto: | ||
description: Run with BoringCrypto enabled | ||
default: false | ||
type: boolean | ||
runs-on: | ||
default: ubuntu-20.04 | ||
type: string | ||
only-if-changed: | ||
description: Run only if relevant files changed. | ||
default: false | ||
type: boolean | ||
save-cache: | ||
description: Save the module and build caches. | ||
default: false | ||
type: boolean | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
GO_VERSION: "1.21.4" | ||
|
||
jobs: | ||
test: | ||
name: Test (otelcol-config) | ||
runs-on: ${{ inputs.runs-on }} | ||
env: | ||
BORINGCRYPTO_SUFFIX: ${{ inputs.boringcrypto && '-boringcrypto' || '' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache: false | ||
|
||
- name: Get GOCACHE and GOMODCACHE | ||
run: | | ||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV" | ||
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_ENV" | ||
- name: Get cache key | ||
id: get-cache-key | ||
run: | | ||
echo "cache-key=go-test-${{ env.GO_VERSION }}${BORINGCRYPTO_SUFFIX}-${{inputs.arch_os}}-${{ hashFiles('pkg/tools/otelcol-config/go.sum') }}" >> $GITHUB_OUTPUT | ||
echo "restore-keys=go-test-${{ env.GO_VERSION }}${BORINGCRYPTO_SUFFIX}-${{inputs.arch_os}}-" >> $GITHUB_OUTPUT | ||
- uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
${{ env.GOMODCACHE }}/cache | ||
${{ env.GOCACHE }} | ||
key: ${{ steps.get-cache-key.outputs.cache-key }} | ||
restore-keys: | | ||
${{ steps.get-cache-key.outputs.restore-keys }} | ||
- name: Run tests | ||
run: make test ${{ inputs.boringcrypto && 'CGO_ENABLED=1 GOEXPERIMENT=boringcrypto' || '' }} | ||
working-directory: ./pkg/tools/otelcol-config | ||
|
||
- uses: actions/cache/save@v4 | ||
with: | ||
path: | | ||
${{ env.GOMODCACHE }}/cache | ||
${{ env.GOCACHE }} | ||
key: ${{ steps.get-cache-key.outputs.cache-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.