Update test.yaml #485
Workflow file for this run
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
name: Test | |
on: | |
push: | |
branches: | |
- '**' | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_call: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
verify-python-dependency: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- run: | | |
min_version_otel="$(curl https://pypi.org/project/opentelemetry-api/ | grep -F -- 'Python :: ' | cut -d ':' -f 3 | tr -d ' ' | grep -F -- 3. | cut -d . -f 2 | sort -n | head -n 1)" | |
min_version_otel="${min_version_otel:-8}" | |
min_version_shell="$(cat src/DEBIAN/control | grep '^Pre-Depends:' | tr ',' '\n' | grep -F -- 'python3 (>=' | cut -d '(' -f 2- | cut -d ')' -f 1 | cut -d ' ' -f 2 | cut -d . -f 2)" | |
[ "$min_version_shell" -ge "$min_version_otel" ] | |
verify-debian-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- run: sudo apt-get update && sudo apt-get -y install apt-file | |
- run: sudo apt-file update | |
- run: | | |
set -x | |
process_packages() { sed 's/^awk$/gawk/g' | sed 's/^python3$/python3-minimal/g'; } | |
process_commands() { sed 's/^awk$/gawk/g' | grep -vE '^which$' | grep -vE '^print$' | grep -vE '^rpm$'; } | |
patternify() { grep -v '^$' | grep -P '^[a-zA-Z0-9/_.-]+$' | while read -r pattern; do echo '^'"$pattern"'$'; done } | |
verify() { | |
local dependencies="$(cat src/DEBIAN/control | grep -E "$1" | cut -d : -f 2- | tr '|' ',' | tr ',' '\n' | cut -d '(' -f 1 | tr -d ' ' | process_packages | patternify)" | |
cat | while read -r file; do echo "Verifying $file" >&2; echo "$file"; done | xargs cat \ | |
| grep -v 'SKIP_DEPENDENCY_CHECK' | while read -r line; do line="${line%%#*}"; printf '%s\n' "$line"; done \ | |
| grep -oP '(^[[:space:]]*|\$\()\\?[a-zA-Z/][a-zA-Z0-9/_.-]*($|[[:space:]])' \ | |
| while read -r command; do command="${command% }"; command="${command# }"; command="${command#\$\(}"; command="${command#\\}"; [ "${#command}" -gt 1 ] && printf '%s\n' "$command" || true; done \ | |
| grep -vE '^_otel|^otel_|^OTEL_' | grep -vE "$(compgen -b | patternify)" | grep -vE "$(compgen -k | patternify)" | process_commands \ | |
| sort -u | while read -r command; do | |
printf '%s' "$command ... " | |
apt-file search /"$command" | grep -E "/$command\$" | grep -E ': /bin/|: /sbin/|: /usr/bin/|: /usr/sbin/|: /usr/local/bin/|: /usr/local/sbin/' | cut -d : -f 1 | grep -q "$dependencies" && echo OK || echo UNAVAILABLE | |
done | tee /dev/stderr | grep -q 'UNAVAILABLE' && return 1 || return 0 | |
} | |
find src/DEBIAN | grep -vE '^src/DEBIAN$|^src/DEBIAN/control$|^src/DEBIAN/triggers$' | verify '^Pre-Depends:' && find src -iname '*.sh' | grep -vE '^src/DEBIAN/' | verify '^Pre-Depends:|^Depends:|^Recommends:|^Suggests:' | |
verify-triggers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- run: | | |
set -o pipefail | |
cat src/DEBIAN/postinst | grep 'if type ' | awk '{for(i=1;i<NF;i++){if($i=="type"){print $(i+1)}}}' | while read -r command; do | |
cat src/DEBIAN/triggers | grep -qE /"$command" | |
done | |
build: | |
needs: [verify-python-dependency, verify-debian-dependencies, verify-triggers] | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./src | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- run: sudo apt-get update && sudo apt-get install devscripts debhelper alien | |
- run: sed -i "s/__VERSION__/$(cat ../VERSION)/g" DEBIAN/control | |
- run: dpkg-deb --root-owner-group -Zgzip --build . ../package.deb | |
- run: | | |
alien --to-rpm --scripts --keep-version --generate ../package.deb | |
rpm_dir=$(echo */*.spec | rev | cut -d / -f 2- | rev) | |
{ | |
dependencies_format_deb_to_rpm() { | |
tr '(' ' ' | tr -d ')' | sed 's/=/= /g' | sed 's/|/ or /g' | sed 's/.*/(&)/g' | |
} | |
dependencies_content_deb_to_rpm() { | |
grep -v 'python3-venv' | sed 's/^awk$/gawk | mawk/g' | sed 's/^dpkg$/rpm/g' | sed 's/^xxd$/xxd | vim-common | vim/g' | |
} | |
echo -n 'Requires: ' && cat DEBIAN/control | grep -E '^Pre-Depends:|^Depends:|^Recommends:' | cut -d ' ' -f 2- | tr ',' '\n' | tr -d ' ' | grep -v '^$' | dependencies_content_deb_to_rpm | dependencies_format_deb_to_rpm | tr '\n' ' ' && echo | |
echo "AutoReq: no" | |
echo "BuildArch: noarch" | |
cat "$rpm_dir"/*.spec | while read -r line; do | |
case "$line" in | |
'%post'*) | |
cat DEBIAN/triggers | grep -v '^$' | cut -d ' ' -f 2 | rev | cut -d / -f 1 | rev | sort -u | grep -v python3 | while read -r package; do | |
cat "$rpm_dir"/*.spec | sed -n '/^%post/,/^$/p' | sed 's/^%post/%triggerin -- '"$package"'/g' | |
cat "$rpm_dir"/*.spec | sed -n '/^%post/,/^$/p' | sed 's/^%post/%triggerun -- '"$package"'/g' | |
done | |
;; | |
*) ;; | |
esac | |
printf '%s\n' "$line" | |
done | |
} > rpm.spec && rm "$rpm_dir"/*.spec | |
rpmbuild -bb --buildroot="$(cat rpm.spec | grep '^Buildroot: ' | cut -d ' ' -f 2)" rpm.spec | |
mv ../*.rpm ../package.rpm | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: package.* | |
smoke: | |
needs: build | |
strategy: | |
matrix: | |
runner: ['ubuntu-latest', 'ubuntu-24.04-arm'] | |
fail-fast: false | |
runs-on: ${{ matrix.runner }} | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- run: sudo apt-get -y install ./package.deb | |
- run: bash -c "cd tests && bash run_tests.sh bash" | |
- run: sudo apt-get -y remove opentelemetry-shell | |
prepare-upgrade: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.dynamic-matrix.outputs.matrix }} | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- run: | | |
curl --no-progress-meter --fail --retry 16 --retry-all-errors --header "Authorization: Bearer $GITHUB_TOKEN" --head https://api.github.com/repos/"$GITHUB_REPOSITORY"/releases?per_page=100 \ | |
| tr '[:upper:]' '[:lower:]' | grep '^link: ' | cut -d ' ' -f 2- | tr -d ' <>' | tr ',' '\n' | grep 'rel="last"' | cut -d ';' -f 1 | cut -d '?' -f 2- | tr '&' '\n' | grep '^page=' | cut -d = -f 2 \ | |
| xargs seq 1 | xargs -I '{}' curl --no-progress-meter --fail --retry 16 --retry-all-errors --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/"$GITHUB_REPOSITORY"/releases?per_page=100\&page={} | jq -r '.[].tag_name' \ | |
| grep -v - | grep -v '^v1.0.0$' | grep -v '^v1.1.0$' | grep -v '^v1.12.6$' \ | |
| jq -nR '{"include": [inputs | select(length > 0) | {tag_name: .}]}' | tr -d '\n' | xargs -0 -I {} echo 'matrix={}' >> "$GITHUB_OUTPUT" | |
id: dynamic-matrix | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
upgrade: | |
needs: [prepare-upgrade, smoke] | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
matrix: ${{ fromJSON(needs.prepare-upgrade.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- run: | | |
curl --no-progress-meter --fail --retry 16 --retry-all-errors --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/"$GITHUB_REPOSITORY"/releases/tags/${{ matrix.tag_name }} | jq -r '.assets[].browser_download_url' | xargs wget --header "Authorization: Bearer $GITHUB_TOKEN" | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- run: sudo apt-get -y install ./*.deb | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- run: sudo apt-get -y install ./package.deb | |
prepare-images: | |
runs-on: ubuntu-latest | |
outputs: | |
images: ${{ steps.dynamic.outputs.images }} | |
images_upgradeable: ${{ steps.dynamic.outputs.images_upgradeable }} | |
env: | |
IMAGE_DEBIAN_OLDEST: 'debian:oldstable' | |
IMAGE_DEBIAN_STABLE: 'debian:stable' | |
IMAGE_DEBIAN_LATEST: 'debian:testing' | |
IMAGE_DEBIAN_DEV: 'debian:unstable' | |
IMAGE_DEBIAN_SLIM_OLDEST: 'debian:oldstable-slim' | |
IMAGE_DEBIAN_SLIM_STABLE: 'debian:stable-slim' | |
IMAGE_DEBIAN_SLIM_LATEST: 'debian:testing-slim' | |
IMAGE_DEBIAN_SLIM_DEV: 'debian:unstable-slim' | |
IMAGE_UBUNTU_OLDEST: 'ubuntu:focal' # needs manual maintenance on April 2025 (https://ubuntu.com/about/release-cycle) | |
IMAGE_UBUNTU_STABLE: 'ubuntu:latest' | |
IMAGE_UBUNTU_LATEST: 'ubuntu:rolling' | |
IMAGE_UBUNTU_DEV: 'ubuntu:devel' | |
IMAGE_CENTOS_OLDEST: '' # CentOS is EOL | |
IMAGE_CENTOS_STABLE: '' # CentOS is EOL | |
IMAGE_CENTOS_LATEST: 'centos:latest' | |
IMAGE_CENTOS_DEV: 'centos:latest' | |
IMAGE_FEDORA_OLDEST: 'fedora:40' # needs manual maintenance on June 2025 (https://docs.fedoraproject.org/en-US/releases/lifecycle/) | |
IMAGE_FEDORA_STABLE: 'fedora:41' # needs manual maintenance on June 2025 (https://docs.fedoraproject.org/en-US/releases/lifecycle/) | |
IMAGE_FEDORA_LATEST: 'fedora:latest' | |
IMAGE_FEDORA_DEV: 'fedora:rawhide' | |
IMAGE_RHEL_OLDEST: 'redhat/ubi8:latest' # needs manual maintenance | |
IMAGE_RHEL_STABLE: 'redhat/ubi9:latest' # needs manual maintenance | |
IMAGE_RHEL_LATEST: 'redhat/ubi9:latest' # needs manual maintenance | |
IMAGE_RHEL_DEV: '' # not public | |
IMAGE_OPENSUSE_OLDEST: 'opensuse/leap:15.6' # needs manual maintenance on January 2026 (https://endoflife.date/opensuse) | |
IMAGE_OPENSUSE_STABLE: 'opensuse/leap:latest' | |
IMAGE_OPENSUSE_LATEST: 'opensuse/tumbleweed:latest' | |
IMAGE_OPENSUSE_DEV: '' # not public | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- id: key | |
run: printenv | grep -E '^IMAGE_' | md5sum | cut -d ' ' -f 1 | xargs -I '{}' echo "key={}" >> "$GITHUB_OUTPUT" | |
- uses: actions/cache@v4 | |
with: | |
path: images.json | |
key: images ${{ steps.key.outputs.key }} | |
- if: ${{ hashFiles('images.json') == '' }} | |
run: | | |
min_version="$(cat src/DEBIAN/control | grep '^Pre-Depends:' | tr ',' '\n' | grep -F -- 'python3 (>=' | cut -d '(' -f 2- | cut -d ')' -f 1 | cut -d ' ' -f 2 | cut -d . -f 2)" | |
printenv | grep '^IMAGE_' | while read -r kvp; do | |
key="$(echo "$kvp" | cut -sd '=' -f 1 | tr '[:upper:]' '[:lower:]')" | |
value="$(echo "$kvp" | cut -sd '=' -f 2)" | |
if [ -z "$value" ]; then continue; fi | |
echo '((apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install python3) || dnf -y install python3 || yum -y install python3 || zypper --non-interactive install python3) > /dev/null && python3 --version' \ | |
| sudo docker run --rm --network=host -i "$value" \ | |
| cut -d ' ' -f 2 | cut -d . -f 2 | while read -r version; do [ "$version" -ge "$min_version" ] && echo "{\"image\":\"$value\",\"os\":\"$(echo "$key" | cut -d _ -f 2)\",\"type\":\"$(echo "$key" | cut -d _ -f 3)\"}" || true; done | |
done | jq -s > images.json | |
- run: | | |
[ "$(cat images.json | jq -r '.[].image' | wc -l)" -ge 5 ] # double check that we dont fail everywhere and then run no tests at all | |
cat images.json | jq '.[] | select(.type != "dev")' | jq .image | sort -u | jq -s -r tostring | xargs -0 -I {} echo 'images={}' >> "$GITHUB_OUTPUT" | |
cat images.json | jq '.[] | select(.type != "dev") | select(.type != "latest") | select(.os == "ubuntu")' | jq .image | sort -u | jq -s -r tostring | xargs -0 -I {} echo 'images_upgradeable={}' >> "$GITHUB_OUTPUT" | |
id: dynamic | |
prepare-shells: | |
runs-on: ubuntu-latest | |
outputs: | |
shells: ${{ steps.dynamic.outputs.shells }} | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- run: | | |
set -x | |
{ | |
echo sh | |
cat src/DEBIAN/control | grep '^Enhances: ' | tr ' ' '\n' | tr ',' '\n' | grep -v -F 'Enhances:' | grep -v '^$' | |
} | sort -u | while read -r shell; do echo "\"$shell\""; done | jq -s -r tostring | xargs -0 -I {} echo 'shells={}' >> "$GITHUB_OUTPUT" | |
id: dynamic | |
system-upgrade: | |
needs: [ prepare-images, smoke ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
image: ${{ fromJSON(needs.prepare-images.outputs.images_upgradeable) }} | |
fail-fast: false | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- run: | | |
echo ' | |
apt-get update | |
apt-get -y install /root/package.deb | |
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade && apt-get -y autoremove && apt-get -y autoclean | |
case "$(cat /etc/os-release | grep '^NAME=' | cut -d = -f 2 | tr -d "\"")" in | |
Ubuntu) | |
DEBIAN_FRONTEND=noninteractive apt-get -y install sed systemctl update-manager-core | |
sed -i "/Prompt/d" /etc/update-manager/release-upgrades && echo "Prompt=normal" >> /etc/update-manager/release-upgrades | |
do-release-upgrade -c || exit 0 && RELEASE_UPGRADER_ALLOW_THIRD_PARTY=1 do-release-upgrade -f DistUpgradeViewNonInteractive | |
;; | |
Debian*) | |
DEBIAN_FRONTEND=noninteractive apt-get -y install curl sed | |
version_destination="$(curl -sL https://deb.debian.org/debian/dists/testing/InRelease | grep "^Codename:" | cut -d " " -f 2)" | |
version_source="$(cat /etc/os-release | grep '^VERSION_CODENAME' | cut -d = -f 2)" | |
sed -i "s/$version_source/$version_destination/g" /etc/apt/sources.list /etc/apt/sources.list.d/* | |
sed -i "s/oldstable/testing/g" /etc/apt/sources.list /etc/apt/sources.list.d/* | |
sed -i "s/stable/testing/g" /etc/apt/sources.list /etc/apt/sources.list.d/* | |
;; | |
*) exit 1;; | |
esac | |
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade && apt-get -y autoremove && apt-get -y autoclean | |
' | sudo docker run -v $(pwd)/package.deb:/root/package.deb --rm --network=host -i --entrypoint=/bin/sh ${{ matrix.image }} -e | |
prepare-dependency: | |
runs-on: ubuntu-latest | |
outputs: | |
dependencies: ${{ steps.dynamic.outputs.dependencies }} | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/checkout@v4 | |
- run: | | |
cat src/DEBIAN/triggers | cut -sd ' ' -f 2- | rev | cut -sd / -f 1 | rev | grep -v '^$' \ | |
| grep -vF "$(cat src/DEBIAN/control | grep '^Pre-Depends:' | cut -d : -f 2- | tr '|' ',' | tr , '\n' | tr -d ' ' | cut -d '(' -f 1)" \ | |
| sort -u | while read -r dependency; do echo "\"$dependency\""; done | jq -s -r tostring | xargs -0 -I {} echo 'dependencies={}' >> "$GITHUB_OUTPUT" | |
id: dynamic | |
dependency: | |
needs: [ prepare-dependency, prepare-images, smoke ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
image: ${{ fromJSON(needs.prepare-images.outputs.images) }} | |
dependency: ${{ fromJSON(needs.prepare-dependency.outputs.dependencies) }} | |
fail-fast: false | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- run: | | |
echo ' | |
if type apt-get; then | |
apt-get update | |
apt-get -y remove ${{ matrix.dependency }} | |
DEBIAN_FRONTEND=noninteractive apt-get -y install /root/package.deb | |
DEBIAN_FRONTEND=noninteractive apt-get -y install ${{ matrix.dependency }} | |
apt-get -y remove ${{ matrix.dependency }} | |
elif type dnf; then | |
dnf -y upgrade --refresh | |
dnf -y remove ${{ matrix.dependency }} | |
dnf -y install /root/package.rpm | |
dnf -y install ${{ matrix.dependency }} | |
dnf -y remove ${{ matrix.dependency }} | |
elif type yum; then | |
yum -y update | |
yum -y remove ${{ matrix.dependency }} | |
yum -y install /root/package.rpm | |
yum -y install ${{ matrix.dependency }} | |
yum -y remove ${{ matrix.dependency }} | |
elif type zypper; then | |
zypper --non-interactive remove ${{ matrix.dependency }} || true | |
zypper --non-interactive install --allow-unsigned-rpm /root/package.rpm | |
zypper --non-interactive install ${{ matrix.dependency }} | |
zypper --non-interactive remove ${{ matrix.dependency }} | |
else | |
exit 1 | |
fi | |
' | sudo docker run -v $(pwd)/package.deb:/root/package.deb -v $(pwd)/package.rpm:/root/package.rpm --rm --network=host -i --entrypoint=/bin/sh ${{ matrix.image }} -e | |
install-manual-user: | |
needs: [ smoke ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: cat INSTALL.sh | sh -e | |
- run: type otel.sh | |
install-manual-os: | |
needs: [ prepare-images, smoke ] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: ${{ fromJSON(needs.prepare-images.outputs.images) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
{ | |
echo ' | |
if type apt-get; then apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install wget curl jq gawk sudo | |
elif type dnf; then dnf -y install wget jq gawk sudo | |
elif type yum; then yum -y install wget jq gawk sudo | |
elif type zypper; then zypper --non-interactive install wget jq gawk sudo | |
else exit 1 | |
fi | |
' | |
cat INSTALL.sh | |
echo type otel.sh | |
} | sudo docker run --rm --network=host -i --entrypoint=/bin/sh ${{ matrix.image }} -e | |
linux-shell: | |
needs: [ prepare-images, prepare-shells, smoke ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
os: ${{ fromJSON(needs.prepare-images.outputs.images) }} | |
update: ['FALSE', 'TRUE'] | |
shell: ${{ fromJSON(needs.prepare-shells.outputs.shells) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- run: mv ./package.* tests | |
- run: bash -c 'cd tests && bash run_tests_containerized.sh "${{ matrix.os }}" "${{ matrix.update }}" "${{ matrix.shell }}"' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
windows-shell: | |
needs: [ prepare-shells, smoke ] | |
runs-on: windows-latest | |
timeout-minutes: 120 | |
strategy: | |
matrix: | |
version: [1, 2] | |
shell: ${{ fromJSON(needs.prepare-shells.outputs.shells) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- uses: Vampire/[email protected] | |
with: | |
wsl-version: ${{ matrix.version }} | |
- shell: wsl-bash {0} | |
run: | | |
retry() { | |
while ! "$@"; do sleep 60; done | |
} | |
retry sudo apt-get update | |
retry sudo -E apt-get -y install ./packages/package.deb dos2unix jq psmisc wget curl time sudo | |
for package in parallel moreutils ncat wget2 python3 python3-pip gcc docker; do # TODO nodejs npm | |
sudo -E apt-get -y install "$package" || true | |
done | |
[ ${{ matrix.shell }} = sh ] || retry sudo -E apt-get -y install ${{ matrix.shell }} || exit 0 | |
dos2unix tests/*.sh tests/*/* | |
bash -c "cd tests && bash run_tests.sh ${{ matrix.shell }}" | |
sudo apt-get -y remove opentelemetry-shell | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
github-job: | |
needs: smoke | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
cache: ['false', 'true'] | |
fail-fast: false | |
steps: | |
- run: printenv | grep '^GITHUB_' | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- uses: ./actions/instrument/job | |
with: | |
cache: ${{ matrix.cache }} | |
env: | |
OTEL_METRICS_EXPORTER: console | |
OTEL_LOGS_EXPORTER: console | |
OTEL_TRACES_EXPORTER: console | |
OTEL_SHELL_CONFIG_GITHUB_INJECT_ON_MAIN: 'TRUE' | |
- run: | # check if install succeeded | |
type otel.sh && type strace | |
- run: | # check if instrumentation happened | |
[ "$(alias | grep '_otel_observe' | wc -l)" -gt 0 ] | |
- run: | # check if traceparent is injected | |
[ -n "$TRACEPARENT" ] | |
- run: echo hello world # check if simple command fails | |
- run: sudo apt-get update # check if complex command fails | |
- uses: actions/download-artifact@v4 # check if node action works | |
with: | |
name: packages | |
- uses: actions/hello-world-docker-action@main # check if docker action works | |
- uses: actions/first-interaction@v1 # node action with - in env vars | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
issue-message: "Hello, thanks for adding an issue for the first time!" | |
pr-message: "Hello, thanks for contributing for the first time!" | |
- uses: renovatebot/[email protected] # integration, node action with call to docker, docker flags that make injection more complicated, then call a node script via exec that already is injected with otel | |
env: | |
RENOVATE_DRY_RUN: full | |
RENOVATE_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RENOVATE_REPOSITORIES: ${{ github.repository }} | |
LOG_LEVEL: debug | |
- uses: docker/setup-qemu-action@v3 # some docker actions have otel built-in | |
- uses: docker/setup-buildx-action@v3 # some docker actions have otel built-in | |
- run: cp package.deb tests/package.deb | |
- uses: docker/build-push-action@v6 # some docker actions have otel built-in | |
with: | |
context: ./tests/ | |
tags: test | |
push: false | |
build-args: | | |
image=ubuntu:latest | |
update=TRUE | |
shell=bash | |
github-workflow: | |
needs: smoke | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- id: workflow_run | |
run: | | |
. ./actions/instrument/shared/github.sh | |
INPUT_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} gh_workflow_runs | jq -r '.workflow_runs[] | select(.status == "completed") | [ .id, .run_attempt ] | @tsv' | sed 's/\t/ /g' | head -n 1 | while read -r id run_attempt; do | |
echo "id=$id" >> "$GITHUB_OUTPUT" | |
echo "run_attempt=$run_attempt" >> "$GITHUB_OUTPUT" | |
done | |
- uses: ./actions/instrument/workflow | |
with: | |
workflow_run_id: ${{ steps.workflow_run.outputs.id }} | |
workflow_run_attempt: ${{ steps.workflow_run.outputs.run_attempt }} | |
env: | |
OTEL_METRICS_EXPORTER: console | |
OTEL_LOGS_EXPORTER: console | |
OTEL_TRACES_EXPORTER: console | |
OTEL_SHELL_SDK_OUTPUT_REDIRECT: /dev/stderr | |
prepare-performance: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.dynamic-matrix.outputs.matrix }} | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- run: | | |
{ echo '~local'; curl --no-progress-meter --fail --retry 16 --retry-all-errors --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/"$GITHUB_REPOSITORY"/releases | jq -r .[].tag_name | head --lines=10; } | jq -nR '{"include": [inputs | select(length > 0) | {tag_name: .}]}' | tr -d '\n' | xargs -0 -I {} echo 'matrix={}' >> "$GITHUB_OUTPUT" | |
id: dynamic-matrix | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
performance: | |
needs: [prepare-performance, smoke] | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
matrix: ${{ fromJSON(needs.prepare-performance.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- if: matrix.tag_name == '~local' | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- if: matrix.tag_name != '~local' | |
run: | | |
curl --no-progress-meter --fail --retry 16 --retry-all-errors --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/"$GITHUB_REPOSITORY"/releases | jq -r '.[] | select(.tag_name == "${{ matrix.tag_name }}") | .assets[].browser_download_url' | grep '.deb$' | xargs wget --header "Authorization: Bearer $GITHUB_TOKEN" | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- run: sudo apt-get install -y ./*.deb | |
- run: | | |
export OTEL_SHELL_SDK_OUTPUT_REDIRECT=/dev/null | |
command time -f '%U' bash -c '. /usr/bin/opentelemetry_shell.sh' 2>> performance.${{ matrix.tag_name }}.coldstart.list | |
for i in $(seq 1 100); do command time -f '%U' bash -c '. /usr/bin/opentelemetry_shell.sh' 2>> performance.${{ matrix.tag_name }}.warmstart.list; done | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: performance.${{ matrix.tag_name }}.coldstart.list | |
path: performance.${{ matrix.tag_name }}.coldstart.list | |
retention-days: 1 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: performance.${{ matrix.tag_name }}.warmstart.list | |
path: performance.${{ matrix.tag_name }}.warmstart.list | |
retention-days: 1 | |
performance-summary: | |
needs: performance | |
runs-on: ubuntu-latest | |
steps: | |
- uses: plengauer/opentelemetry-bash/actions/instrument/[email protected] | |
env: | |
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT }}' | |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '${{ secrets.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT }}' | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: 'performance.*.list' | |
merge-multiple: true | |
- run: | | |
for file in performance.*.list; do | |
type=$(echo $file | rev | cut -d . -f 2 | rev) | |
version=$(echo $file | cut -d . -f 2- | rev | cut -d . -f 3- | rev) | |
cat "$file" | grep -v 'No such file or directory' | sort -n | head -n 1 | xargs echo "$version" >> "$type".list | |
done | |
- run: | | |
sudo apt-get update && sudo apt-get install -y gnuplot-nox | |
echo ' | |
set terminal pngcairo enhanced font "Verdana,10" size 1024,1024 | |
set output "performance.png" | |
set title "Performance Comparison" | |
set xlabel "Version" | |
set xtics rotate by -45 | |
set ylabel "Performance" | |
set logscale y 10 | |
plot "coldstart.list" using 0:2:xticlabels(1) with linespoints title "Cold Start" lt rgb "blue", "warmstart.list" using 0:2:xticlabels(1) with linespoints title "Warm Start" lt rgb "red" | |
' > plot.gp | |
gnuplot plot.gp | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: performance.png | |
path: performance.png | |
retention-days: 90 | |
join: | |
needs: [upgrade, system-upgrade, dependency, linux-shell, windows-shell, github-job, github-workflow, install-manual-user, install-manual-os] | |
runs-on: ubuntu-latest | |
outputs: | |
success: ${{ steps.tests.outputs.success }} | |
steps: | |
- id: tests | |
run: echo "success=true" >> "$GITHUB_OUTPUT" | |
all: | |
if: ${{ always() }} # this is because we need this to fail and not skipped to avoid PRs getting merged without this passing | |
needs: join | |
runs-on: ubuntu-latest | |
steps: | |
- env: | |
SUCCESS: ${{ needs.join.outputs.success }} | |
run: | | |
[ "$SUCCESS" = 'true' ] |