Repository: elastic/synthetics
Pull request #730 (2023-04-04 08:09:06)

Migrate e2e sythetics 2 GH Actions Workflow
## Details

Migrate e2e synthetics mbp and schedule to GH Actions workflow

## Motivation

Jenkins to GH Actions Migration

apmmachine: 
## :green_heart: Build Succeeded


<!-- BUILD BADGES-->
> _the below badges are clickable and redirect to their specific view in the CI or DOCS_
[![Pipeline View](https://img.shields.io/badge/pipeline-pipeline%20-green)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-730/detail/PR-730/1//pipeline) [![Test View](https://img.shields.io/badge/test-test-green)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-730/detail/PR-730/1//tests) [![Changes](https://img.shields.io/badge/changes-changes-green)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-730/detail/PR-730/1//changes) [![Artifacts](https://img.shields.io/badge/artifacts-artifacts-yellow)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-730/detail/PR-730/1//artifacts) [![preview](https://img.shields.io/badge/docs-preview-yellowgreen)](http://synthetics_730.docs-preview.app.elstc.co/diff)  [![preview](https://img.shields.io/badge/elastic-observability-blue)](https://ci-stats.elastic.co/app/apm/services/apm-ci/transactions/view?rangeFrom=2023-04-04T07:59:25.568Z&rangeTo=2023-04-04T08:19:25.568Z&transactionName=BUILD+apm-agent-rum%2Felastic-synthetics%2FPR-%7Bnumber%7D&transactionType=job&latencyAggregationType=avg&traceId=663e1e3649a003ae7bf6bdbfb65626a3&transactionId=305a0243ac33c928)

<!-- BUILD SUMMARY-->
<details><summary>Expand to view the summary</summary>
<p>

#### Build stats




* Start Time: 2023-04-04T08:09:25.568+0000


* Duration: 14 min 42 sec




#### Test stats :test_tube:

| Test         | Results                         |
| ------------ | :-----------------------------: |
| Failed       | 0  |
| Passed       | 215  |
| Skipped      | 2 |
| Total        | 217   |


</p>
</details>

<!-- TEST RESULTS IF ANY-->


<!-- STEPS ERRORS IF ANY -->














## :robot: GitHub comments

<details><summary>Expand to view the GitHub comments</summary>
<p>

To re-run your PR in the CI, just comment with:



- `/test` : Re-trigger the build.




</p>
</details>

<!--COMMENT_GENERATED_WITH_ID_comment.id-->

Patch:
diff --git a/.ci/schedule.groovy b/.ci/schedule.groovy
deleted file mode 100644
index 1e16fe3..0000000
--- a/.ci/schedule.groovy
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env groovy
-
-@Library('apm@current') _
-
-pipeline {
-  agent none
-  environment {
-    NOTIFY_TO = credentials('notify-to')
-    PIPELINE_LOG_LEVEL='INFO'
-  }
-  options {
-    timeout(time: 1, unit: 'HOURS')
-    buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20'))
-    timestamps()
-    ansiColor('xterm')
-    disableResume()
-    durabilityHint('PERFORMANCE_OPTIMIZED')
-  }
-  triggers {
-    cron('H 4,16 * * 1-5')
-  }
-  stages {
-    stage('Run Tasks'){
-      steps {
-        build(job: 'apm-agent-rum/e2e-synthetics-mbp/main',
-          propagate: false,
-          wait: false
-        )
-      }
-    }
-  }
-  post {
-    cleanup {
-      notifyBuildResult()
-    }
-  }
-}


Test patch:
diff --git a/.ci/e2e-synthetics.groovy b/.ci/e2e-synthetics.groovy
deleted file mode 100644
index 852b0aa..0000000
--- a/.ci/e2e-synthetics.groovy
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/env groovy
-
-@Library('apm@current') _
-
-pipeline {
-  agent { label 'ubuntu-20 && immutable' }
-  environment {
-    REPO = "synthetics"
-    BASE_DIR = "src/github.com/elastic/${env.REPO}"
-    DOCKER_REGISTRY = 'docker.elastic.co'
-    DOCKER_ELASTIC_SECRET = 'secret/observability-team/ci/docker-registry/prod'
-    PIPELINE_LOG_LEVEL = 'INFO'
-    SLACK_CHANNEL = '#synthetics-user_experience-uptime'
-    E2E_FOLDER = "__tests__/e2e"
-    GO_VERSION = "1.19.1"
-  }
-  options {
-    timeout(time: 1, unit: 'HOURS')  // to support releases then we will add a timeout in each stage
-    buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
-    timestamps()
-    ansiColor('xterm')
-    disableResume()
-    durabilityHint('PERFORMANCE_OPTIMIZED')
-    rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
-    quietPeriod(10)
-  }
-  stages {
-    stage('Checkout') {
-      options {
-        skipDefaultCheckout()
-        timeout(5)
-      }
-      steps {
-        deleteDir()
-        gitCheckout(basedir: "${BASE_DIR}")
-        stash allowEmpty: true, name: 'source', useDefaultExcludes: false, excludes: ".nvm/**,.npm/_cacache/**,.nvm/.git/**"
-      }
-    }
-    stage('Build') {
-      options {
-        skipDefaultCheckout()
-      }
-      steps {
-        cleanup()
-        withNodeJSEnv(){
-          dir("${BASE_DIR}"){
-            sh(label: 'npm install', script: 'npm install')
-            sh(label: 'Build',script: 'npm run build')
-          }
-        }
-      }
-    }
-    stage('E2e Test') {
-      options {
-        skipDefaultCheckout()
-      }
-      steps {
-        dockerLogin(secret: "${DOCKER_ELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}")
-        withNodeJSEnv(){
-          withGoEnv(){
-            dir("${BASE_DIR}/${E2E_FOLDER}"){
-              sh(label: 'npm install', script: 'npm install')
-              sh(label: 'run e2e tests', script: '''#!/bin/bash
-                npm run test:ci_integration_all
-              ''')
-            }
-          }
-        }
-      }
-      post {
-        always {
-          archiveArtifacts(allowEmptyArchive: true, artifacts: "${BASE_DIR}/${E2E_FOLDER}/junit_*.xml")
-          junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/${E2E_FOLDER}/junit_*.xml")
-        }
-      }
-    }
-  }
-  post {
-    cleanup {
-      notifyBuildResult(prComment: true)
-    }
-    unsuccessful {
-      notifyStatus(slackStatus: 'danger', subject: "[${env.REPO}] e2e failed", body: "(<${env.RUN_DISPLAY_URL}|Open>)")
-    }
-  }
-}
-
-def cleanup(){
-  dir("${BASE_DIR}"){
-    deleteDir()
-  }
-  unstash 'source'
-}
-
-/**
-  This is the wrapper to send notifications for the e2e process through
-  slack and email, since it requires some formatting to support the same
-  message in both systems.
- */
-def notifyStatus(def args = [:]) {
-  releaseNotification(slackChannel: "${env.SLACK_CHANNEL}",
-                      slackColor: args.slackStatus,
-                      slackCredentialsId: 'jenkins-slack-integration-token',
-                      to: 'synthrum@elastic.co',
-                      subject: args.subject,
-                      body: args.body)
-}
diff --git a/.ci/jobs/e2e-synthetics-mbp.yml b/.ci/jobs/e2e-synthetics-mbp.yml
deleted file mode 100644
index 80d1ee7..0000000
--- a/.ci/jobs/e2e-synthetics-mbp.yml
+++ /dev/null
@@ -1,44 +0,0 @@
----
-- job:
-    name: apm-agent-rum/e2e-synthetics-mbp
-    display-name: E2E for Elastic Synthetics
-    description: E2E for Elastic Synthetics.
-    project-type: multibranch
-    script-path: .ci/e2e-synthetics.groovy
-    scm:
-      - github:
-          branch-discovery: 'no-pr'
-          discover-pr-forks-strategy: 'merge-current'
-          discover-pr-forks-trust: 'permission'
-          discover-pr-origin: 'merge-current'
-          discover-tags: false
-          disable-pr-notifications: true
-          head-filter-regex: '(main|\d+\.\d+\.\d+|PR-.*)'
-          notification-context: 'elastic-synthetics'
-          repo: 'synthetics'
-          repo-owner: 'elastic'
-          credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
-          ssh-checkout:
-            credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
-          build-strategies:
-            - regular-branches: true
-            - change-request:
-                ignore-target-only-changes: true
-          property-strategies:
-            all-branches:
-              - suppress-scm-triggering: true
-          clean:
-              after: true
-              before: true
-          prune: true
-          shallow-clone: true
-          depth: 3
-          do-not-fetch-tags: true
-          submodule:
-              disable: false
-              recursive: true
-              parent-credentials: true
-              timeout: 100
-          timeout: '15'
-          use-author: true
-          wipe-workspace: true
diff --git a/.ci/jobs/e2e-synthetics-schedule.yml b/.ci/jobs/e2e-synthetics-schedule.yml
deleted file mode 100644
index 25ec6de..0000000
--- a/.ci/jobs/e2e-synthetics-schedule.yml
+++ /dev/null
@@ -1,26 +0,0 @@
----
-- job:
-    name: apm-agent-rum/e2e-synthetics-schedule
-    display-name: Jobs scheduled daily
-    description: Jobs scheduled daily from Monday to Friday
-    project-type: pipeline
-    parameters:
-      - string:
-          name: branch_specifier
-          default: main
-          description: the Git branch specifier to build
-    pipeline-scm:
-      script-path: .ci/schedule.groovy
-      scm:
-        - git:
-            url: git@github.com:elastic/synthetics.git
-            refspec: +refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pr/*
-            wipe-workspace: 'True'
-            name: origin
-            shallow-clone: true
-            credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba
-            reference-repo: /var/lib/jenkins/.git-references/synthetics.git
-            branches:
-              - $branch_specifier
-    triggers:
-      - timed: 'H 4,16 * * 1-5'
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
new file mode 100644
index 0000000..6c1658f
--- /dev/null
+++ b/.github/workflows/e2e.yml
@@ -0,0 +1,43 @@
+name: e2e
+
+on:
+  workflow_dispatch: ~
+  schedule:
+    - cron: "0 4,16 * * 1-5"
+  push:
+    branches:
+      - main
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-node@v3
+        with:
+          cache: npm
+          node-version-file: .nvmrc
+      - uses: actions/setup-go@v4
+        with:
+          go-version: 1.19
+      - run: npm ci
+      - run: npm run build
+      - run: npm install
+        working-directory: __tests__/e2e
+      - run: npm run test:ci_integration_all
+        working-directory: __tests__/e2e
+        env:
+          TERM: xterm # this is needed for tput
+      - if: success() || failure()
+        uses: actions/upload-artifact@v3
+        with:
+          name: test-results
+          path: "**/junit_*.xml"
+          if-no-files-found: error
+      - if: always()
+        uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
+        with:
+          vaultUrl: ${{ secrets.VAULT_ADDR }}
+          vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
+          vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
+          slackChannel: "#synthetics-user_experience-uptime"
diff --git a/.github/workflows/test-reporter.yml b/.github/workflows/test-reporter.yml
index b504c9a..b470d9a 100644
--- a/.github/workflows/test-reporter.yml
+++ b/.github/workflows/test-reporter.yml
@@ -5,6 +5,7 @@ on:
   workflow_run:
     workflows:
       - ci
+      - e2e
     types:
       - completed
 
@@ -15,6 +16,6 @@ jobs:
       - uses: elastic/apm-pipeline-library/.github/actions/test-report@current
         with:
           artifact: test-results
-          name: test-report
-          path: "**/junit.xml"
+          name: ${{ github.event.workflow_run.name }}-test-report
+          path: "**/junit*.xml"
           reporter: java-junit