From b888d80c8639d8c968c5d7b9e7a2b8f4a73cfd8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Tue, 12 Dec 2023 08:58:39 +0100 Subject: [PATCH 1/3] internal/apps: remove pr_default options We are not running the test apps on PRs anymore, so there is no way to invoke the jobs without either the workflow_call or workflow_dispatch inputs being available. So we need no pr_default values to fall back to. --- .github/workflows/test-apps.cue | 5 +-- .github/workflows/test-apps.yml | 60 ++++++++++++++++----------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test-apps.cue b/.github/workflows/test-apps.cue index d531abe8b6..739292b029 100644 --- a/.github/workflows/test-apps.cue +++ b/.github/workflows/test-apps.cue @@ -24,21 +24,18 @@ type: "number", description: "Requests per second", default: 5, - pr_default: default, }, scenario_duration: { env: "DD_TEST_APPS_TOTAL_DURATION", type: "string", description: "Scenario duration", default: "10m", - pr_default: "60s", }, profile_period: { env: "DD_TEST_APPS_PROFILE_PERIOD", type: "string", description: "Profile period", default: "60s", - pr_default: "10s", }, } @@ -147,7 +144,7 @@ jobs: { name: "Run Scenario" env: { for name, arg in #args { - "\(arg.env)": "${{ inputs['arg: \(name)'] || '\(arg.pr_default)' }}", + "\(arg.env)": "${{ inputs['arg: \(name)'] }}", } }, run: "cd ./internal/apps && ./run-scenario.bash '\(scenario.name)'" diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 99a2436a1d..0bc614a1f0 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -101,9 +101,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v1' job-0-1: name: unit-of-work/v1 (staging) @@ -127,9 +127,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v1' job-1-0: name: unit-of-work/v2 (prod) @@ -153,9 +153,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v2' job-1-1: name: unit-of-work/v2 (staging) @@ -179,9 +179,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v2' job-2-0: name: memory-leak/goroutine (prod) @@ -205,9 +205,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine' job-2-1: name: memory-leak/goroutine (staging) @@ -231,9 +231,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine' job-3-0: name: memory-leak/heap (prod) @@ -257,9 +257,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/heap' job-3-1: name: memory-leak/heap (staging) @@ -283,9 +283,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/heap' job-4-0: name: memory-leak/goroutine-heap (prod) @@ -309,9 +309,9 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine-heap' job-4-1: name: memory-leak/goroutine-heap (staging) @@ -335,7 +335,7 @@ jobs: cache: true - name: Run Scenario env: - DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}' - DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}' - DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}' + DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}' + DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}' + DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}' run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine-heap' From 3e6c4455a9194f88f34644125e49289e1b17620b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Tue, 12 Dec 2023 10:02:38 +0100 Subject: [PATCH 2/3] internal/apps: tagging for manual/scheduled runs --- .github/workflows/test-apps-schedule.yml | 4 +++- .github/workflows/test-apps.cue | 11 +++++++++-- .github/workflows/test-apps.yml | 10 +++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-apps-schedule.yml b/.github/workflows/test-apps-schedule.yml index 5919efd893..fba9c472ee 100644 --- a/.github/workflows/test-apps-schedule.yml +++ b/.github/workflows/test-apps-schedule.yml @@ -13,10 +13,12 @@ jobs: secrets: inherit with: "arg: scenario_duration": "10m" + "arg: tags": "trigger:nightly" weekly: if: github.event.schedule == '0 0 * * 2' uses: ./.github/workflows/test-apps.yml secrets: inherit with: - "arg: scenario_duration": "1h" \ No newline at end of file + "arg: scenario_duration": "1h" + "arg: tags": "trigger:weekly" \ No newline at end of file diff --git a/.github/workflows/test-apps.cue b/.github/workflows/test-apps.cue index 739292b029..06865e5ccd 100644 --- a/.github/workflows/test-apps.cue +++ b/.github/workflows/test-apps.cue @@ -37,6 +37,12 @@ description: "Profile period", default: "60s", }, + tags: { + env: false, + type: "string", + description: "Extra DD_TAGS", + default: "trigger:manual", + }, } #envs: [ @@ -103,7 +109,7 @@ on: { env: { DD_ENV: "github", - DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }}", + DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} $${{ inputs['arg: tags'] }}", } jobs: { @@ -143,7 +149,8 @@ jobs: { { name: "Run Scenario" env: { - for name, arg in #args { + // args.env is (string|false), so we use null coalescing to type cast to string + for name, arg in #args if (*(arg.env&string) | "") != "" { "\(arg.env)": "${{ inputs['arg: \(name)'] }}", } }, diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index 0bc614a1f0..cf26ab1087 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -25,6 +25,10 @@ name: Test Apps type: string default: 60s description: Profile period + 'arg: tags': + type: string + default: trigger:manual + description: Extra DD_TAGS 'scenario: unit-of-work/v1': type: boolean default: true @@ -60,6 +64,10 @@ name: Test Apps type: string default: 60s description: Profile period + 'arg: tags': + type: string + default: trigger:manual + description: Extra DD_TAGS 'scenario: unit-of-work/v1': type: boolean default: false @@ -77,7 +85,7 @@ name: Test Apps default: false env: DD_ENV: github - DD_TAGS: github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} + DD_TAGS: 'github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} $${{ inputs[''arg: tags''] }}' jobs: job-0-0: name: unit-of-work/v1 (prod) From 90dc5d59bb438ba53ddfc1b1c5e7a028356e5b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Tue, 12 Dec 2023 10:20:13 +0100 Subject: [PATCH 3/3] internal/apps: pass scenario inputs as JSON Work around the fact that workflow_dispatch triggers can only have a maximum of 10 inputs, ugh. See links below for more info. - https://github.com/DataDog/dd-trace-go/actions/runs/7179140710 - https://github.com/orgs/community/discussions/8774 --- .github/workflows/test-apps.cue | 21 +++++++----- .github/workflows/test-apps.yml | 60 +++++++++++---------------------- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/.github/workflows/test-apps.cue b/.github/workflows/test-apps.cue index 06865e5ccd..72e6953cef 100644 --- a/.github/workflows/test-apps.cue +++ b/.github/workflows/test-apps.cue @@ -1,4 +1,5 @@ // See /internal/apps/README.md for more information. +import "encoding/json" #scenarios: [ { @@ -77,13 +78,15 @@ }, } - for scenario in #scenarios { - "scenario: \(scenario.name)": { - type: "boolean", - default: true | false, - } - } - + scenarios: { + type: "string", + default: json.Marshal([ + for scenario in #scenarios { + scenario.name + } + ]), + description: "Scenarios to run" + }, } } @@ -109,7 +112,7 @@ on: { env: { DD_ENV: "github", - DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} $${{ inputs['arg: tags'] }}", + DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} ${{ inputs['arg: tags'] }}", } jobs: { @@ -119,7 +122,7 @@ jobs: { name: "\(scenario.name) (\(env.name))", "runs-on": "ubuntu-latest", - #if_scenario: "inputs['scenario: \(scenario.name)']", + #if_scenario: "contains(fromJSON(inputs['scenarios']), '\(scenario.name)')", #if_env: "inputs['env: \(env.name)']", if: "\(#if_scenario) && \(#if_env)" diff --git a/.github/workflows/test-apps.yml b/.github/workflows/test-apps.yml index cf26ab1087..95044a8564 100644 --- a/.github/workflows/test-apps.yml +++ b/.github/workflows/test-apps.yml @@ -3,6 +3,10 @@ name: Test Apps "on": workflow_call: inputs: + scenarios: + type: string + default: '["unit-of-work/v1","unit-of-work/v2","memory-leak/goroutine","memory-leak/heap","memory-leak/goroutine-heap"]' + description: Scenarios to run ref: description: The branch to run the workflow on required: false @@ -29,23 +33,12 @@ name: Test Apps type: string default: trigger:manual description: Extra DD_TAGS - 'scenario: unit-of-work/v1': - type: boolean - default: true - 'scenario: unit-of-work/v2': - type: boolean - default: true - 'scenario: memory-leak/goroutine': - type: boolean - default: true - 'scenario: memory-leak/heap': - type: boolean - default: true - 'scenario: memory-leak/goroutine-heap': - type: boolean - default: true workflow_dispatch: inputs: + scenarios: + type: string + default: '["unit-of-work/v1","unit-of-work/v2","memory-leak/goroutine","memory-leak/heap","memory-leak/goroutine-heap"]' + description: Scenarios to run 'env: prod': type: boolean default: true @@ -68,29 +61,14 @@ name: Test Apps type: string default: trigger:manual description: Extra DD_TAGS - 'scenario: unit-of-work/v1': - type: boolean - default: false - 'scenario: unit-of-work/v2': - type: boolean - default: false - 'scenario: memory-leak/goroutine': - type: boolean - default: false - 'scenario: memory-leak/heap': - type: boolean - default: false - 'scenario: memory-leak/goroutine-heap': - type: boolean - default: false env: DD_ENV: github - DD_TAGS: 'github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} $${{ inputs[''arg: tags''] }}' + DD_TAGS: 'github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} ${{ inputs[''arg: tags''] }}' jobs: job-0-0: name: unit-of-work/v1 (prod) runs-on: ubuntu-latest - if: 'inputs[''scenario: unit-of-work/v1''] && inputs[''env: prod'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v1'') && inputs[''env: prod'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -116,7 +94,7 @@ jobs: job-0-1: name: unit-of-work/v1 (staging) runs-on: ubuntu-latest - if: 'inputs[''scenario: unit-of-work/v1''] && inputs[''env: staging'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v1'') && inputs[''env: staging'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -142,7 +120,7 @@ jobs: job-1-0: name: unit-of-work/v2 (prod) runs-on: ubuntu-latest - if: 'inputs[''scenario: unit-of-work/v2''] && inputs[''env: prod'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v2'') && inputs[''env: prod'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -168,7 +146,7 @@ jobs: job-1-1: name: unit-of-work/v2 (staging) runs-on: ubuntu-latest - if: 'inputs[''scenario: unit-of-work/v2''] && inputs[''env: staging'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v2'') && inputs[''env: staging'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -194,7 +172,7 @@ jobs: job-2-0: name: memory-leak/goroutine (prod) runs-on: ubuntu-latest - if: 'inputs[''scenario: memory-leak/goroutine''] && inputs[''env: prod'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine'') && inputs[''env: prod'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -220,7 +198,7 @@ jobs: job-2-1: name: memory-leak/goroutine (staging) runs-on: ubuntu-latest - if: 'inputs[''scenario: memory-leak/goroutine''] && inputs[''env: staging'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine'') && inputs[''env: staging'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -246,7 +224,7 @@ jobs: job-3-0: name: memory-leak/heap (prod) runs-on: ubuntu-latest - if: 'inputs[''scenario: memory-leak/heap''] && inputs[''env: prod'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/heap'') && inputs[''env: prod'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -272,7 +250,7 @@ jobs: job-3-1: name: memory-leak/heap (staging) runs-on: ubuntu-latest - if: 'inputs[''scenario: memory-leak/heap''] && inputs[''env: staging'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/heap'') && inputs[''env: staging'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -298,7 +276,7 @@ jobs: job-4-0: name: memory-leak/goroutine-heap (prod) runs-on: ubuntu-latest - if: 'inputs[''scenario: memory-leak/goroutine-heap''] && inputs[''env: prod'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine-heap'') && inputs[''env: prod'']' steps: - name: Checkout Code uses: actions/checkout@v3 @@ -324,7 +302,7 @@ jobs: job-4-1: name: memory-leak/goroutine-heap (staging) runs-on: ubuntu-latest - if: 'inputs[''scenario: memory-leak/goroutine-heap''] && inputs[''env: staging'']' + if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine-heap'') && inputs[''env: staging'']' steps: - name: Checkout Code uses: actions/checkout@v3