Skip to content

Commit 5436577

Browse files
authored
ci: refactor run-integration-tests to use larger runners (#705)
Refactor run-integration-tests workflow into reusable workflows to allow fine tuning which runners to use for which job depending on architecture. Experiments showed that building on default runner but using larger runner (4cores) for running integration tests on arm64 achieves best time/cost results. I.e. using larger runners to build on arm64 cuts the workflow runtime from about 30 minutes to about 20 minutes and therefore does not seem necessary. However, using larger runners to run test on arm64 is necessary not as much for time savings but for performance - without larger runners, tests run too slow and more spans are captured which causes actual results not to match test expectations.
1 parent 0b59806 commit 5436577

File tree

4 files changed

+326
-159
lines changed

4 files changed

+326
-159
lines changed

.github/workflows/make-agent.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: _make-agent
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
origin:
7+
description: 'newrelic-php-agent origin'
8+
required: true
9+
default: 'newrelic'
10+
type: string
11+
ref:
12+
description: 'Branch or tag'
13+
required: true
14+
type: string
15+
arch:
16+
description: 'Target architecture'
17+
required: true
18+
type: string
19+
runs-on:
20+
description: 'runner type'
21+
required: true
22+
type: string
23+
24+
jobs:
25+
build-agent:
26+
name: make agent (${{ matrix.platform }}, ${{ inputs.arch }}, ${{ matrix.php }})
27+
runs-on: ${{inputs.runs-on}}
28+
env:
29+
IMAGE_NAME: newrelic/nr-php-agent-builder
30+
IMAGE_TAG: make-php
31+
IMAGE_VERSION: ${{vars.MAKE_PHP_VERSION}}
32+
strategy:
33+
matrix:
34+
platform: [gnu, musl]
35+
php: ['8.0', '8.1', '8.2']
36+
steps:
37+
- name: Checkout Repo
38+
uses: actions/checkout@v3
39+
with:
40+
path: php-agent
41+
repository: ${{ inputs.origin }}/newrelic-php-agent
42+
ref: ${{ inputs.ref }}
43+
- name: Enable arm64 emulation
44+
if: ${{ inputs.arch == 'arm64' }}
45+
uses: docker/setup-qemu-action@v2
46+
with:
47+
image: tonistiigi/binfmt:${{vars.BINFMT_IMAGE_VERSION}}
48+
platforms: arm64
49+
- name: Login to Docker Hub
50+
uses: docker/login-action@v2
51+
with:
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
- name: Build axiom
55+
run: >
56+
docker run --rm --platform linux/${{inputs.arch}}
57+
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
58+
$IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make axiom
59+
- name: Build agent
60+
run: >
61+
docker run --rm --platform linux/${{inputs.arch}}
62+
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
63+
$IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent
64+
- name: Save newrelic.so for integration tests
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: newrelic.so-${{matrix.platform}}-${{inputs.arch}}-${{matrix.php}}
68+
path: php-agent/agent/modules/newrelic.so
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: _make-target
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
origin:
7+
description: 'newrelic-php-agent origin'
8+
required: true
9+
default: 'newrelic'
10+
type: string
11+
ref:
12+
description: 'Branch or tag'
13+
required: true
14+
type: string
15+
make-variant:
16+
description: 'Builder image tag'
17+
required: true
18+
type: string
19+
make-variant-version:
20+
description: 'Builder image version'
21+
required: true
22+
type: string
23+
make-target:
24+
description: 'make target'
25+
required: true
26+
type: string
27+
artifact-name:
28+
description: 'Build artifact name'
29+
required: true
30+
type: string
31+
artifact-pattern:
32+
description: 'Build artifact pattern'
33+
required: true
34+
type: string
35+
arch:
36+
description: 'Target architecture'
37+
required: true
38+
type: string
39+
runs-on:
40+
description: 'runner type'
41+
required: true
42+
type: string
43+
44+
jobs:
45+
make-target:
46+
name: make ${{ inputs.make-target }} using ${{inputs.make-variant}} (${{ matrix.platform }}, ${{inputs.arch}})
47+
runs-on: ${{inputs.runs-on}}
48+
env:
49+
IMAGE_NAME: newrelic/nr-php-agent-builder
50+
IMAGE_TAG: make-${{inputs.make-variant}}
51+
IMAGE_VERSION: ${{inputs.make-variant-version}}
52+
strategy:
53+
matrix:
54+
platform: [gnu, musl]
55+
steps:
56+
- name: Checkout newrelic-php-agent code
57+
uses: actions/checkout@v3
58+
with:
59+
path: php-agent
60+
repository: ${{ inputs.origin }}/newrelic-php-agent
61+
ref: ${{ inputs.ref }}
62+
- name: Enable arm64 emulation
63+
if: ${{ inputs.arch == 'arm64' }}
64+
uses: docker/setup-qemu-action@v2
65+
with:
66+
image: tonistiigi/binfmt:${{vars.BINFMT_IMAGE_VERSION}}
67+
platforms: arm64
68+
- name: Login to Docker Hub
69+
uses: docker/login-action@v2
70+
with:
71+
username: ${{ secrets.DOCKERHUB_USERNAME }}
72+
password: ${{ secrets.DOCKERHUB_TOKEN }}
73+
- name: Build ${{inputs.make-target}}
74+
run: >
75+
docker run --rm --platform linux/${{inputs.arch}}
76+
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
77+
-e ACCOUNT_supportability=${{secrets.ACCOUNT_SUPPORTABILITY}}
78+
-e APP_supportability=${{secrets.APP_SUPPORTABILITY}}
79+
$IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION ${{inputs.make-target}}
80+
- name: Save ${{inputs.make-target}} artifact
81+
uses: actions/upload-artifact@v3
82+
with:
83+
name: ${{inputs.artifact-name}}-${{matrix.platform}}-${{inputs.arch}}
84+
path: php-agent/${{ inputs.artifact-pattern }}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: _make-integration-tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
origin:
7+
description: 'newrelic-php-agent origin'
8+
required: true
9+
default: 'newrelic'
10+
type: string
11+
ref:
12+
description: 'Branch or tag'
13+
required: true
14+
type: string
15+
arch:
16+
description: 'Target architecture'
17+
required: true
18+
type: string
19+
continue-on-error:
20+
description: 'Continue on error'
21+
required: true
22+
type: boolean
23+
runs-on:
24+
description: 'runner type'
25+
required: true
26+
type: string
27+
28+
jobs:
29+
test-agent:
30+
name: test agent (${{ matrix.platform }}, ${{ inputs.arch }}, ${{ matrix.php }})
31+
runs-on: ${{inputs.runs-on}}
32+
continue-on-error: ${{inputs.continue-on-error}}
33+
strategy:
34+
fail-fast: true
35+
matrix:
36+
platform: [gnu, musl]
37+
php: ['8.0', '8.1', '8.2']
38+
steps:
39+
- name: Checkout integration tests
40+
uses: actions/checkout@v3
41+
with:
42+
path: php-agent
43+
repository: ${{ inputs.origin }}/newrelic-php-agent
44+
ref: ${{ inputs.ref }}
45+
- name: Get integration_runner
46+
uses: actions/download-artifact@v3
47+
with:
48+
name: integration_runner-${{matrix.platform}}-${{inputs.arch}}
49+
path: php-agent/bin
50+
- name: Get newrelic.so
51+
uses: actions/download-artifact@v3
52+
with:
53+
name: newrelic.so-${{matrix.platform}}-${{inputs.arch}}-${{matrix.php}}
54+
path: php-agent/agent/modules
55+
- name: Prep artifacts for use
56+
run: |
57+
chmod 755 php-agent/bin/integration_runner
58+
chmod 755 php-agent/agent/modules/newrelic.so
59+
- name: Enable arm64 emulation
60+
if: ${{ inputs.arch == 'arm64' }}
61+
uses: docker/setup-qemu-action@v2
62+
with:
63+
image: tonistiigi/binfmt:${{vars.BINFMT_IMAGE_VERSION}}
64+
platforms: arm64
65+
- name: Login to Docker Hub
66+
uses: docker/login-action@v2
67+
with:
68+
username: ${{ secrets.DOCKERHUB_USERNAME }}
69+
password: ${{ secrets.DOCKERHUB_TOKEN }}
70+
- name: Start services
71+
env:
72+
PHP: ${{matrix.php}}
73+
LIBC: ${{matrix.platform}}
74+
PLATFORM: linux/${{inputs.arch}}
75+
AGENT_CODE: ${{github.workspace}}/php-agent
76+
IMAGE_VERSION: ${{vars.MAKE_PHP_VERSION}}
77+
working-directory: ./php-agent
78+
run: |
79+
make test-services-start
80+
- name: Run integration tests
81+
working-directory: ./php-agent
82+
shell: bash
83+
run: |
84+
docker exec \
85+
-e PHPS=${{matrix.php}} \
86+
-e INTEGRATION_ARGS="-license ${{secrets.NR_TEST_LICENSE}} -collector ${{secrets.NR_COLLECTOR_HOST}} -agent agent/modules/newrelic.so" \
87+
-e APP_supportability=${{secrets.APP_SUPPORTABILITY}} \
88+
-e ACCOUNT_supportability=${{secrets.ACCOUNT_SUPPORTABILITY}} \
89+
-e ACCOUNT_supportability_trusted=${{secrets.ACCOUNT_SUPPORTABILITY_TRUSTED}} \
90+
-e SYNTHETICS_HEADER_supportability=${{secrets.SYNTHETICS_HEADER_SUPPORTABILITY}} \
91+
nr-php make integration-tests
92+
- name: Stop services
93+
env:
94+
PHP: ${{matrix.php}}
95+
LIBC: ${{matrix.platform}}
96+
AGENT_CODE: ${{github.workspace}}/php-agent
97+
working-directory: ./php-agent
98+
run: |
99+
make test-services-stop

0 commit comments

Comments
 (0)