Skip to content

fips: otelcol binaries for linux and windows #3828

fips: otelcol binaries for linux and windows

fips: otelcol binaries for linux and windows #3828

name: auto-instrumentation
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/auto-instrumentation.yml'
- 'cmd/otelcol/**'
- 'instrumentation/**'
- 'internal/**'
- '!**.md'
concurrency:
group: auto-instrumentation-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.11'
PIP_VERSION: '22.0.4'
REQUIREMENTS_PATH: "internal/buildscripts/packaging/tests/requirements.txt"
GO_VERSION: 1.22.7
jobs:
cross-compile:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
strategy:
matrix:
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Build Collector
run: |
make ${{ matrix.SYS_BINARIES }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.SYS_BINARIES }}
path: |
./bin/*
build-package:
runs-on: ubuntu-20.04
strategy:
matrix:
SYS_PACKAGE: [ "deb", "rpm" ]
ARCH: [ "amd64", "arm64"]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- name: Run tests
run: make -C instrumentation tests ARCH=${{ matrix.ARCH }}
- name: Build ${{ matrix.ARCH }} ${{ matrix.SYS_PACKAGE }} package
run: make -C instrumentation/ ${{ matrix.SYS_PACKAGE }}-package ARCH="${{ matrix.ARCH }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: splunk-otel-auto-instrumentation-${{ matrix.ARCH }}-${{ matrix.SYS_PACKAGE }}
path: ./instrumentation/dist/*.${{ matrix.SYS_PACKAGE }}
test-package-matrix:
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Get matrix
id: get-matrix
run: |
# create test matrix for distro and arch
dockerfiles=$(find internal/buildscripts/packaging/tests/instrumentation/images/ -name "Dockerfile.*" | cut -d '.' -f2- | sort -u)
if [ -z "$dockerfiles" ]; then
echo "Failed to get dockerfiles from internal/buildscripts/packaging/tests/instrumentation/images!" >&2
exit 1
fi
distro=$(for d in $dockerfiles; do echo -n "\"$d\","; done)
arch="\"amd64\", \"arm64\""
testcase="\"express\",\"tomcat\",\"dotnet\""
exclude='{"ARCH": "arm64", "TESTCASE": "dotnet"}' # splunk-otel-dotnet currently not supported on arm64
matrix="{\"DISTRO\": [${distro%,}], \"ARCH\": [${arch}], \"TESTCASE\": [${testcase}], \"exclude\": [${exclude}]}"
echo "$matrix" | jq
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
test-package:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ${{ fromJSON('["ubuntu-20.04", "ubuntu-22.04"]')[matrix.DISTRO == 'amazonlinux-2023'] }}
timeout-minutes: 60
needs: [cross-compile, build-package, test-package-matrix]
strategy:
matrix: ${{ fromJSON(needs.test-package-matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Get package type for ${{ matrix.DISTRO }}
run: |
for pkg in "deb" "rpm"; do
if [[ -f "internal/buildscripts/packaging/tests/instrumentation/images/${pkg}/Dockerfile.${{ matrix.DISTRO }}" ]]; then
echo "SYS_PACKAGE=${pkg}" >> $GITHUB_ENV
exit 0
fi
done
echo "Unknown distro '${{ matrix.DISTRO }}'!"
exit 1
- uses: actions/download-artifact@v4
with:
name: binaries-linux_${{ matrix.ARCH }}
path: ./bin
- uses: actions/download-artifact@v4
with:
name: splunk-otel-auto-instrumentation-${{ matrix.ARCH }}-${{ env.SYS_PACKAGE }}
path: ./instrumentation/dist
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: ${{ env.REQUIREMENTS_PATH }}
- name: Install pytest
run: |
if which pip; then
pip install --upgrade 'pip==${{ env.PIP_VERSION }}'
else
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py 'pip==${{ env.PIP_VERSION }}'
fi
pip install -r "${{ env.REQUIREMENTS_PATH }}"
- name: Test ${{ env.SYS_PACKAGE }} on ${{ matrix.DISTRO }} ${{ matrix.ARCH }}
id: pytest
continue-on-error: true
run: |
distro="${{ matrix.DISTRO }}"
if [[ "$distro" = "amazonlinux-2" ]]; then
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
testcase="${{ matrix.TESTCASE }} or uninstall"
python3 -u -m pytest -s --verbose -k "$distro and ${{ matrix.ARCH }} and ($testcase)" \
internal/buildscripts/packaging/tests/instrumentation/instrumentation_test.py
# qemu, networking, running systemd in containers, etc., can be flaky
- name: Re-run failed tests
if: ${{ steps.pytest.outcome == 'failure' }}
run: |
distro="${{ matrix.DISTRO }}"
if [[ "$distro" = "amazonlinux-2" ]]; then
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
testcase="${{ matrix.TESTCASE }} or uninstall"
python3 -u -m pytest -s --verbose -k "$distro and ${{ matrix.ARCH }} and ($testcase)" \
--last-failed \
internal/buildscripts/packaging/tests/instrumentation/instrumentation_test.py