-
Notifications
You must be signed in to change notification settings - Fork 377
100 lines (97 loc) · 3.76 KB
/
lib-injection.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: "Library Injection"
on:
# Build each branch for testing
push:
jobs:
build-and-publish-test-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker
run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Docker Build
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/datadog/dd-trace-rb/dd-lib-ruby-init:${{ github.sha }}
platforms: 'linux/amd64,linux/arm64/v8'
build-args: DDTRACE_RUBY_SHA=${{ github.sha }}
context: ./lib-injection
test:
needs:
- build-and-publish-test-image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
lib-injection-connection: ['network']
lib-injection-use-admission-controller: ['', 'use-admission-controller']
weblog-variant:
- dd-lib-ruby-init-test-rails
- dd-lib-ruby-init-test-rails-explicit
- dd-lib-ruby-init-test-rails-gemsrb
fail-fast: false
env:
TEST_LIBRARY: ruby
WEBLOG_VARIANT: ${{ matrix.weblog-variant }}
LIBRARY_INJECTION_CONNECTION: ${{ matrix.lib-injection-connection }}
LIBRARY_INJECTION_ADMISSION_CONTROLLER: ${{ matrix.lib-injection-use-admission-controller }}
DOCKER_REGISTRY_IMAGES_PATH: ghcr.io/datadog
DOCKER_IMAGE_TAG: ${{ github.sha }}
BUILDX_PLATFORMS: linux/amd64,linux/arm64/v8
MODE: manual
steps:
- name: lib-injection test runner
id: lib-injection-test-runner
uses: DataDog/system-tests/lib-injection/runner@main
with:
docker-registry: ghcr.io
docker-registry-username: ${{ github.repository_owner }}
docker-registry-password: ${{ secrets.GITHUB_TOKEN }}
test-script: ./lib-injection/run-manual-lib-injection.sh
test-negative:
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- dd-lib-ruby-init-test-rails-conflict
- dd-lib-ruby-init-test-rails-bundle-deploy
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout system-tests
uses: actions/checkout@v4
with:
repository: DataDog/system-tests
path: system-tests
- name: Overwrite auto inject script with commit SHA
run: |
sed -i "s~<DD_TRACE_SHA_TO_BE_REPLACED>~${{github.sha}}~g" lib-injection/auto_inject.rb
sed -i "s~<DD_TRACE_VERSION_TO_BE_REPLACED>~~g" lib-injection/auto_inject.rb
- name: Build app
run: |
cp -r system-tests/lib-injection/build/docker/ruby/lib_injection_rails_app system-tests/lib-injection/build/docker/ruby/${{matrix.variant}}
cp system-tests/lib-injection/build/docker/ruby/.dockerignore system-tests/lib-injection/build/docker/ruby/${{matrix.variant}}
docker build -t ${{matrix.variant}} system-tests/lib-injection/build/docker/ruby/${{matrix.variant}}
- name: Run app with injection
run: |
docker run -d \
--name ${{matrix.variant}} \
-e RUBYOPT=-r/lib-injection/auto_inject \
-e DD_TRACE_DEBUG=true \
-v $(pwd)/lib-injection:/lib-injection \
-p 18080:18080 \
${{matrix.variant}}
- name: Log container to see error message
run: |
sleep 10
docker logs ${{matrix.variant}}
- name: Send http request to ensure app remains running even with lib injection failure
run: curl -v --retry 10 -f --retry-all-errors --retry-delay 5 -s -o /dev/null http://localhost:18080