Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action: tav #3127

Merged
merged 10 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/.jenkins_tav.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TAV:
FRAMEWORK:
- '@elastic/elasticsearch'
- '@elastic/elasticsearch-canary'
- '@hapi/hapi'
Expand Down
2 changes: 1 addition & 1 deletion .ci/.jenkins_tav_nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NODEJS_VERSION:
VERSION:
- "19"
- "18"
- "16"
Expand Down
98 changes: 1 addition & 97 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pipeline {
parameters {
booleanParam(name: 'Run_As_Main_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on main branch.')
booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks.')
booleanParam(name: 'tav_ci', defaultValue: true, description: 'Enable TAV tests.')
booleanParam(name: 'tests_ci', defaultValue: true, description: 'Enable tests.')
booleanParam(name: 'test_edge_ci', defaultValue: true, description: 'Enable tests for edge versions of nodejs.')
}
Expand All @@ -52,11 +51,6 @@ pipeline {
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
script {
dir("${BASE_DIR}"){
def regexps =[
"^lib/instrumentation/modules/",
"^test/instrumentation/modules/"
]
env.TAV_UPDATED = isGitRegionMatch(patterns: regexps)

// Skip all the stages except docs for PR's with asciidoc or md changes only
env.ONLY_DOCS = isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true)
Expand Down Expand Up @@ -107,47 +101,6 @@ pipeline {
}
}
}
/**
Run TAV tests.
*/
stage('TAV Test') {
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
}
when {
beforeAgent true
allOf {
not { tag pattern: 'v\\d+\\.\\d+\\.\\d+', comparator: 'REGEXP' }
anyOf {
expression { return params.Run_As_Main_Branch }
triggeredBy 'TimerTrigger'
changeRequest()
expression { return env.TAV_UPDATED != "false" }
}
expression { return params.tav_ci }
expression { return env.ONLY_DOCS == "false" }
}
}
steps {
deleteDir()
unstash 'source'
dir("${BASE_DIR}"){
script {
def tavContext = getSmartTAVContext()
withGithubNotify(context: tavContext.ghContextName, description: tavContext.ghDescription, tab: 'tests') {
def parallelTasks = [:]
tavContext.node['NODEJS_VERSION'].each{ version ->
tavContext.tav['TAV'].each{ tav_item ->
parallelTasks["Node.js-${version}-${tav_item}"] = generateStep(version: version, tav: tav_item)
}
}
parallel(parallelTasks)
}
}
}
}
}

/**
The "Edge Test" is a run of the agent test suite with pre-release builds
Expand Down Expand Up @@ -398,7 +351,6 @@ pipeline {

def generateStep(Map params = [:]){
def version = params?.version
def tav = params.containsKey('tav') ? params.tav : ''
def buildType = params.containsKey('buildType') ? params.buildType : 'release'
def contextManager = params.get('disableAsyncHooks', false) ? 'patch' : ''
return {
Expand All @@ -411,7 +363,7 @@ def generateStep(Map params = [:]){
dir("${BASE_DIR}"){
try {
retryWithSleep(retries: 2, seconds: 5, backoff: true) {
sh(label: "Run Tests", script: """.ci/scripts/test.sh -b "${buildType}" -t "${tav}" "${version}" """)
sh(label: "Run Tests", script: """.ci/scripts/test.sh -b "${buildType}" "${version}" """)
}
} finally {
junit(testResults: "test_output/*.junit.xml", allowEmptyResults: true, keepLongStdio: true)
Expand All @@ -424,54 +376,6 @@ def generateStep(Map params = [:]){
}
}

/**
* Gather the TAV context for the current execution. Then the TAV stage will execute
* the TAV using a smarter approach.
*/
def getSmartTAVContext() {
context = [:]
context.ghContextName = 'TAV Test'
context.ghDescription = context.ghContextName
context.node = readYaml(file: '.ci/.jenkins_tav_nodejs.yml')

// Hard to debug what's going on as there are a few nested conditions. Let's then add more verbose output
echo """\
env.GITHUB_COMMENT=${env.GITHUB_COMMENT}
params.Run_As_Main_Branch=${params.Run_As_Main_Branch}
env.CHANGE_ID=${env.CHANGE_ID}
env.TAV_UPDATED=${env.TAV_UPDATED}""".stripIndent()

if (env.GITHUB_COMMENT) {
def modules = getModulesFromCommentTrigger(regex: 'run module tests for (.+)')
if (modules.isEmpty()) {
context.ghDescription = 'TAV Test disabled'
context.tav = readYaml(text: 'TAV:')
context.node = readYaml(text: 'NODEJS_VERSION:')
} else {
if (modules.find{ it == 'ALL' }) {
context.tav = readYaml(file: '.ci/.jenkins_tav.yml')
} else {
context.ghContextName = 'TAV Test Subset'
context.ghDescription = 'TAV Test comment-triggered'
context.tav = readYaml(text: """TAV:${modules.collect{ it.replaceAll('"', '').replaceAll("'", '') }.collect{ "\n - '${it}'"}.join("") }""")
}
}
} else if (params.Run_As_Main_Branch) {
context.ghDescription = 'TAV Test param-triggered'
context.tav = readYaml(file: '.ci/.jenkins_tav.yml')
} else if (env.CHANGE_ID && env.TAV_UPDATED != "false") {
context.ghContextName = 'TAV Test Subset'
context.ghDescription = 'TAV Test changes-triggered'
sh '.ci/scripts/get_tav.sh .ci/.jenkins_generated_tav.yml'
context.tav = readYaml(file: '.ci/.jenkins_generated_tav.yml')
} else {
context.ghDescription = 'TAV Test disabled'
context.tav = readYaml(text: 'TAV:')
context.node = readYaml(text: 'NODEJS_VERSION:')
}
return context
}

def linting(){
return {
withNode(labels: 'linux && immutable', forceWorkspace: true, forceWorker: true) {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/opentelemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenTelemetry Export Trace

on:
workflow_run:
workflows: [Test, Lint, Snapshoty]
workflows: [Test, Lint, Snapshoty, TAV]
types: [completed]

jobs:
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/tav.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: TAV

on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '*.md'
- '*.asciidoc'
- 'docs/**'
- 'examples/**'
pull_request:
branches:
- main
paths-ignore:
- '*.md'
- '*.asciidoc'
- 'docs/**'
- 'examples/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

# limit the access of the generated GITHUB_TOKEN
permissions:
contents: read

jobs:

filter:
runs-on: ubuntu-latest
timeout-minutes: 3
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- id: generate
uses: elastic/apm-pipeline-library/.github/actions/version-framework@current
with:
versionsFile: .ci/.jenkins_tav_nodejs.yml
frameworksFile: .ci/.jenkins_tav.yml

test-tav:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [filter]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.filter.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- run: .ci/scripts/test.sh -b "release" -t "${{ matrix.framework }}" "${{ matrix.version }}"
env:
VERSION: ${{ matrix.version }}
ELASTIC_APM_CONTEXT_MANAGER: ''