Skip to content

Update nginx.yml (#316) #252

Update nginx.yml (#316)

Update nginx.yml (#316) #252

Workflow file for this run

name: nginx instrumentation CI
on:
workflow_dispatch:
push:
branches: "*"
paths:
- 'instrumentation/nginx/**'
- '.github/workflows/nginx.yml'
tags:
- 'nginx/*'
pull_request:
branches: [main]
paths:
- 'instrumentation/nginx/**'
- '.github/workflows/nginx.yml'
jobs:
create-release:
if: startsWith(github.ref, 'refs/tags/nginx')
runs-on: ubuntu-latest
steps:
- name: Release
uses: softprops/action-gh-release@v2
upload-release-artifacts:
if: startsWith(github.ref, 'refs/tags/nginx')
runs-on: ubuntu-latest
needs: [nginx-build-test, create-release]
steps:
- name: Create directory
run: |
mkdir artifacts
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Upload release artifacts
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
files: ./artifacts/*
nginx-build-test:
name: nginx
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
image: ["ubuntu:24.04", "debian:11", "alpine:3.20", "amazonlinux:2", "amazonlinux:2023"]
nginx: ["1.27.3", "1.27.1", "1.26.2", "1.24.0", "1.22.1"]
steps:
- name: checkout otel nginx
uses: actions/checkout@v4
- name: setup
run: |
sudo ./instrumentation/nginx/ci/setup_environment.sh
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: build express backend docker
run: |
cd instrumentation/nginx
docker build -t otel-nginx-test/express-backend \
-f test/backend/simple_express/Dockerfile \
--cache-from type=local,src=/tmp/buildx-cache/express \
--cache-to type=local,dest=/tmp/buildx-cache/express-new \
--load \
test/backend/simple_express
- name: Choose Dockerfile
run: |
if [[ "${{ matrix.image }}" == "alpine"* ]]; then
echo "dockerfile=Dockerfile_alpine" >> $GITHUB_ENV
elif [[ "${{ matrix.image }}" == "amazonlinux"* ]]; then
echo "dockerfile=Dockerfile_amazonlinux" >> $GITHUB_ENV
else
echo "dockerfile=Dockerfile" >> $GITHUB_ENV
fi
- name: build nginx docker
run: |
cd instrumentation/nginx
docker build -t otel-nginx-test/nginx \
--build-arg image=${{ matrix.image }} \
--build-arg nginx_version=${{ matrix.nginx }} \
-f test/${{ env.dockerfile }} \
--cache-from type=local,src=/tmp/buildx-cache/nginx \
--cache-to type=local,dest=/tmp/buildx-cache/nginx-new \
--load \
.
- name: update cache
run: |
rm -rf /tmp/buildx-cache/express
rm -rf /tmp/buildx-cache/nginx
mv /tmp/buildx-cache/express-new /tmp/buildx-cache/express
mv /tmp/buildx-cache/nginx-new /tmp/buildx-cache/nginx
- name: run tests
run: |
cd instrumentation/nginx/test/instrumentation
mix local.hex --force --if-missing
mix local.rebar --force --if-missing
mix deps.get
mix test
- name: copy artifacts
id: artifacts
run: |
cd instrumentation/nginx
mkdir -p /tmp/otel_ngx/
docker build -f test/${{ env.dockerfile }} \
--build-arg image=${{ matrix.image }} \
--build-arg nginx_version=${{ matrix.nginx }} \
--target export \
--output type=local,dest=/tmp/otel_ngx .
echo "artifactName=otel_ngx_module-$(echo ${{ matrix.image }} | sed s/:/-/)-${{ matrix.nginx }}.so" >> $GITHUB_ENV
- name: rename artifact
run: |
mv /tmp/otel_ngx/otel_ngx_module.so /tmp/otel_ngx/${{ env.artifactName }}
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifactName }}
path: /tmp/otel_ngx/${{ env.artifactName }}