Skip to content

Commit

Permalink
Revert "✨[RUM-3798] Report the cpu impact as a pr comment (#2702)"
Browse files Browse the repository at this point in the history
This reverts commit 1ea85f4.
  • Loading branch information
RomanGaignault authored Apr 16, 2024
1 parent 1ea85f4 commit 088d394
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 387 deletions.
12 changes: 1 addition & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,7 @@ build-and-lint:
- yarn build
- yarn lint
- node scripts/check-packages.js

test-performance:
extends:
- .base-configuration
- .test-allowed-branches
interruptible: true
script:
- yarn
- yarn build:bundle
- node ./scripts/deploy/deploy.js staging pull-request pull-request
- node scripts/performance/index.js
- node scripts/report-bundle-size/index.js

build-bundle:
extends:
Expand Down
16 changes: 4 additions & 12 deletions scripts/deploy/deploy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
'use strict'

const { printLog, runMain } = require('../lib/execution-utils')
const { fetchPR, LOCAL_BRANCH } = require('../lib/git-utils')
const { command } = require('../lib/command')

const {
buildRootUploadPath,
buildDatacenterUploadPath,
buildBundleFolder,
buildBundleFileName,
buildPullRequestUploadPath,
packages,
} = require('./lib/deployment-utils')

Expand All @@ -30,23 +27,20 @@ const AWS_CONFIG = {
/**
* Deploy SDK files to CDN
* Usage:
* node deploy.js staging|prod staging|canary|pull-request|vXXX root,pull-request,us1,eu1,...
* node deploy.js staging|prod staging|canary|vXXX root,us1,eu1,...
*/
const env = process.argv[2]
const version = process.argv[3]
const uploadPathTypes = process.argv[4].split(',')

runMain(async () => {
runMain(() => {
const awsConfig = AWS_CONFIG[env]
let cloudfrontPathsToInvalidate = []
for (const { packageName } of packages) {
const bundleFolder = buildBundleFolder(packageName)
for (const uploadPathType of uploadPathTypes) {
let uploadPath
if (uploadPathType === 'pull-request') {
const PR_NUMBER = (await fetchPR(LOCAL_BRANCH)).number
uploadPath = buildPullRequestUploadPath(packageName, PR_NUMBER)
} else if (uploadPathType === 'root') {
if (uploadPathType === 'root') {
uploadPath = buildRootUploadPath(packageName, version)
} else {
uploadPath = buildDatacenterUploadPath(uploadPathType, packageName, version)
Expand All @@ -64,9 +58,7 @@ function uploadToS3(awsConfig, bundlePath, uploadPath) {
const accessToS3 = generateEnvironmentForRole(awsConfig.accountId, 'build-stable-browser-agent-artifacts-s3-write')

const browserCache =
version === 'staging' || version === 'canary' || version === 'pull-request'
? 15 * ONE_MINUTE_IN_SECOND
: 4 * ONE_HOUR_IN_SECOND
version === 'staging' || version === 'canary' ? 15 * ONE_MINUTE_IN_SECOND : 4 * ONE_HOUR_IN_SECOND
const cacheControl = `max-age=${browserCache}, s-maxage=60`

printLog(`Upload ${bundlePath} to s3://${awsConfig.bucketName}/${uploadPath}`)
Expand Down
5 changes: 0 additions & 5 deletions scripts/deploy/lib/deployment-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ const buildDatacenterUploadPath = (datacenter, packageName, version, extension =
// ex: datadog-rum.js
const buildBundleFileName = (packageName, extension = 'js') => `datadog-${packageName}.${extension}`

// ex: pull-request/2781/datadog-rum.js
function buildPullRequestUploadPath(packageName, version, extension = 'js') {
return `pull-request/${version}/datadog-${packageName}.${extension}`
}
// ex: packages/rum/bundle
const buildBundleFolder = (packageName) => `packages/${packageName}/bundle`

Expand All @@ -27,5 +23,4 @@ module.exports = {
buildDatacenterUploadPath,
buildBundleFileName,
buildBundleFolder,
buildPullRequestUploadPath,
}
38 changes: 1 addition & 37 deletions scripts/lib/git-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,7 @@ const os = require('os')
const fs = require('fs')

const { command } = require('../lib/command')
const { getGithubDeployKey, getGithubAccessToken } = require('./secrets')
const { fetchHandlingError } = require('./execution-utils')

const GITHUB_TOKEN = getGithubAccessToken()

async function fetchPR(localBranch) {
const response = await fetchHandlingError(
`https://api.github.com/repos/DataDog/browser-sdk/pulls?head=DataDog:${localBranch}`,
{
method: 'GET',
headers: {
Authorization: `token ${GITHUB_TOKEN}`,
},
}
)
const pr = response.body ? await response.json() : null
if (pr && pr.length > 1) {
throw new Error('Multiple pull requests found for the branch')
}
return pr ? pr[0] : null
}

function getLastCommonCommit(baseBranch) {
try {
command`git fetch --depth=100 origin ${baseBranch}`.run()
const commandOutput = command`git merge-base origin/${baseBranch} HEAD`.run()
// SHA commit is truncated to 8 characters as bundle sizes commit are exported in short format to logs for convenience and readability.
return commandOutput.trim().substring(0, 8)
} catch (error) {
throw new Error('Failed to get last common commit', { cause: error })
}
}
const { getGithubDeployKey } = require('./secrets')

function initGitConfig(repository) {
const homedir = os.homedir()
Expand All @@ -52,9 +21,4 @@ function initGitConfig(repository) {

module.exports = {
initGitConfig,
fetchPR,
getLastCommonCommit,
BASE_BRANCH: process.env.MAIN_BRANCH,
LOCAL_BRANCH: process.env.CI_COMMIT_REF_NAME,
GITHUB_TOKEN,
}
29 changes: 0 additions & 29 deletions scripts/performance/bundle-size/compute-bundle-size.js

This file was deleted.

64 changes: 0 additions & 64 deletions scripts/performance/cpu-performance/compute-cpu-performance.js

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/performance/fetch-performance-metrics.js

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/performance/index.js

This file was deleted.

Loading

0 comments on commit 088d394

Please sign in to comment.