Skip to content

Commit

Permalink
πŸ‘· Reorganise scripts directory (#2059)
Browse files Browse the repository at this point in the history
* ♻️ group build scripts

* ♻️ group release scripts

* ♻️ group deploy scripts

* ♻️ group test scripts

* πŸ‘Œ separate lib from executables

* πŸ‘Œ move build-env to lib

* πŸ‘Œ colocate deployment utils with deploy scripts

* Trigger ci
  • Loading branch information
bcaudan committed Mar 21, 2023
1 parent 0f1868a commit 6c436f1
Show file tree
Hide file tree
Showing 29 changed files with 51 additions and 51 deletions.
36 changes: 18 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ unit:
script:
- yarn
- yarn test:unit
- ./scripts/codecov.sh
- ./scripts/test/codecov.sh
after_script:
- node ./scripts/export-test-result.js unit
- node ./scripts/test/export-test-result.js unit

e2e:
extends:
Expand All @@ -184,7 +184,7 @@ e2e:
- yarn
- yarn test:e2e
after_script:
- node ./scripts/export-test-result.js e2e
- node ./scripts/test/export-test-result.js e2e

check-licenses:
extends:
Expand All @@ -203,7 +203,7 @@ check-release:
script:
- yarn
- BUILD_MODE=release yarn build
- node scripts/check-release.js
- node scripts/release/check-release.js

unit-bs:
stage: browserstack
Expand All @@ -217,9 +217,9 @@ unit-bs:
junit: test-report/unit-bs/*.xml
script:
- yarn
- ./scripts/ci-bs.sh test:unit
- ./scripts/test/ci-bs.sh test:unit
after_script:
- node ./scripts/export-test-result.js unit-bs
- node ./scripts/test/export-test-result.js unit-bs

e2e-bs:
stage: browserstack
Expand All @@ -235,9 +235,9 @@ e2e-bs:
junit: test-report/e2e-bs/*.xml
script:
- yarn
- ./scripts/ci-bs.sh test:e2e
- ./scripts/test/ci-bs.sh test:e2e
after_script:
- node ./scripts/export-test-result.js e2e-bs
- node ./scripts/test/export-test-result.js e2e-bs

########################################################################################################################
# Deploy
Expand All @@ -252,8 +252,8 @@ deploy-staging:
- export BUILD_MODE=canary
- yarn
- yarn build:bundle
- node ./scripts/deploy.js staging staging root
- node ./scripts/upload-source-maps.js staging root
- node ./scripts/deploy/deploy.js staging staging root
- node ./scripts/deploy/upload-source-maps.js staging root

deploy-prod-canary:
stage: deploy:canary
Expand All @@ -264,8 +264,8 @@ deploy-prod-canary:
- export BUILD_MODE=canary
- yarn
- yarn build:bundle
- node ./scripts/deploy.js prod canary root
- node ./scripts/upload-source-maps.js canary root
- node ./scripts/deploy/deploy.js prod canary root
- node ./scripts/deploy/upload-source-maps.js canary root

deploy-prod-all-dcs:
stage: deploy
Expand All @@ -279,8 +279,8 @@ deploy-prod-all-dcs:
- VERSION=$(node -p -e "require('./lerna.json').version")
- yarn
- yarn build:bundle
- node ./scripts/deploy.js prod v${VERSION%%.*} us1,eu1,us3,us5,ap1
- node ./scripts/upload-source-maps.js v${VERSION%%.*} us1,eu1,us3,us5,ap1
- node ./scripts/deploy/deploy.js prod v${VERSION%%.*} us1,eu1,us3,us5,ap1
- node ./scripts/deploy/upload-source-maps.js v${VERSION%%.*} us1,eu1,us3,us5,ap1

deploy-prod-root:
stage: deploy
Expand All @@ -294,8 +294,8 @@ deploy-prod-root:
- VERSION=$(node -p -e "require('./lerna.json').version")
- yarn
- yarn build:bundle
- node ./scripts/deploy.js prod v${VERSION%%.*} root
- node ./scripts/upload-source-maps.js v${VERSION%%.*} root
- node ./scripts/deploy/deploy.js prod v${VERSION%%.*} root
- node ./scripts/deploy/upload-source-maps.js v${VERSION%%.*} root

publish-npm:
stage: deploy
Expand All @@ -306,7 +306,7 @@ publish-npm:
allow_failure: false
script:
- yarn
- ./scripts/publish-npm.sh
- ./scripts/deploy/publish-npm.sh

########################################################################################################################
# Notify
Expand Down Expand Up @@ -485,7 +485,7 @@ bump-chrome-version-scheduled:
before_script:
- eval $(ssh-agent -s)
script:
- node scripts/bump-chrome-driver-version.js
- node scripts/test/bump-chrome-driver-version.js
artifacts:
reports:
dotenv: build.env
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"test": "yarn test:unit:watch",
"test:unit": "karma start ./test/unit/karma.local.conf.js",
"test:unit:watch": "yarn test:unit --no-single-run",
"test:unit:bs": "node ./scripts/bs-wrapper.js karma start test/unit/karma.bs.conf.js",
"test:unit:bs": "node ./scripts/test/bs-wrapper.js karma start test/unit/karma.bs.conf.js",
"test:e2e": "yarn build && (cd test/app && rm -rf node_modules && yarn && yarn build) && wdio test/e2e/wdio.local.conf.js",
"test:e2e:bs": "yarn build && (cd test/app && rm -rf node_modules && yarn && yarn build) && node ./scripts/bs-wrapper.js wdio test/e2e/wdio.bs.conf.js",
"test:e2e:bs": "yarn build && (cd test/app && rm -rf node_modules && yarn && yarn build) && node ./scripts/test/bs-wrapper.js wdio test/e2e/wdio.bs.conf.js",
"test:compat:tsc": "scripts/cli check_typescript_compatibility",
"test:compat:ssr": "scripts/cli check_server_side_rendering_compatibility",
"rum-events-format:sync": "scripts/cli update_submodule && scripts/cli build_json2type && node scripts/generate-schema-types.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "run-p build:cjs build:esm",
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json && yarn replace-build-env cjs",
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json && yarn replace-build-env esm",
"replace-build-env": "node ../../scripts/replace-build-env.js"
"replace-build-env": "node ../../scripts/build/replace-build-env.js"
},
"devDependencies": {
"@types/sinon": "9.0.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:bundle": "rm -rf bundle && webpack --mode=production",
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json && yarn replace-build-env cjs",
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json && yarn replace-build-env esm",
"replace-build-env": "node ../../scripts/replace-build-env.js"
"replace-build-env": "node ../../scripts/build/replace-build-env.js"
},
"dependencies": {
"@datadog/browser-core": "4.35.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/rum-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "run-p build:cjs build:esm",
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json && yarn replace-build-env cjs",
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json && yarn replace-build-env esm",
"replace-build-env": "node ../../scripts/replace-build-env.js"
"replace-build-env": "node ../../scripts/build/replace-build-env.js"
},
"dependencies": {
"@datadog/browser-core": "4.35.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const glob = require('glob')
const buildEnv = require('./build-env')
const { printLog, runMain, modifyFile } = require('./utils')
const { printLog, runMain, modifyFile } = require('../lib/utils')
const buildEnv = require('../lib/build-env')

/**
* Replace BuildEnv in build files
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs')
const path = require('path')
const readline = require('readline')
const { printLog, printError, runMain, findBrowserSdkPackageJsonFiles } = require('./utils')
const { printLog, printError, runMain, findBrowserSdkPackageJsonFiles } = require('./lib/utils')

const LICENSE_FILE = 'LICENSE-3rdparty.csv'

Expand Down
4 changes: 2 additions & 2 deletions scripts/cli
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ cmd_release () {
}

cmd_version () {
node ./scripts/generate-changelog.js
node ./scripts/update-peer-dependency-versions.js
node ./scripts/release/generate-changelog.js
node ./scripts/release/update-peer-dependency-versions.js
# keep test app lockfile up to date
cd test/app
yarn upgrade
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy.js β†’ scripts/deploy/deploy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'

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

const ONE_MINUTE_IN_SECOND = 60
const ONE_HOUR_IN_SECOND = 60 * ONE_MINUTE_IN_SECOND
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict'

const path = require('path')
const { getSecretKey, command, printLog, runMain } = require('./utils')
const { getSecretKey, command, printLog, runMain } = require('../lib/utils')
const { SDK_VERSION } = require('../lib/build-env')
const {
buildRootUploadPath,
buildDatacenterUploadPath,
buildBundleFolder,
buildBundleFileName,
packages,
} = require('./deployment-utils')
const { SDK_VERSION } = require('./build-env')
} = require('./lib/deployment-utils')

/**
* Upload source maps to datadog
Expand Down
2 changes: 1 addition & 1 deletion scripts/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const webpack = require('webpack')
const logsConfig = require('../packages/logs/webpack.config')
const rumSlimConfig = require('../packages/rum-slim/webpack.config')
const rumConfig = require('../packages/rum/webpack.config')
const { printLog } = require('./utils')
const { printLog } = require('./lib/utils')

const port = 8080
const app = express()
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-schema-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs')
const path = require('path')
const { compileFromFile } = require('json-schema-to-typescript')
const prettier = require('prettier')
const { printLog, runMain } = require('./utils')
const { printLog, runMain } = require('./lib/utils')

const schemasDirectoryPath = path.join(__dirname, '../rum-events-format/schemas')
const prettierConfigPath = path.join(__dirname, '../.prettierrc.yml')
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-env.js β†’ scripts/lib/build-env.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const execSync = require('child_process').execSync
const lernaJson = require('../lerna.json')
const lernaJson = require('../../lerna.json')

/**
* Allows to define which sdk_version to send to the intake.
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils.js β†’ scripts/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function findBrowserSdkPackageJsonFiles() {
.trim()
.split('\n')
.map((manifestPath) => {
const absoluteManifestPath = path.join(__dirname, '..', manifestPath)
const absoluteManifestPath = path.join(__dirname, '../..', manifestPath)
return {
relativePath: manifestPath,
path: absoluteManifestPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const fs = require('fs')
const path = require('path')
const { version: releaseVersion } = require('../lerna.json')
const { findBrowserSdkPackageJsonFiles, printLog, runMain, command } = require('./utils')
const { version: releaseVersion } = require('../../lerna.json')
const { findBrowserSdkPackageJsonFiles, printLog, runMain, command } = require('../lib/utils')

runMain(() => {
checkGitTag()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const readFile = util.promisify(require('fs').readFile)

const emojiNameMap = require('emoji-name-map')

const lernaConfig = require('../lerna.json')
const { command, spawnCommand, printError, runMain, modifyFile } = require('./utils')
const lernaConfig = require('../../lerna.json')
const { command, spawnCommand, printError, runMain, modifyFile } = require('../lib/utils')

const CHANGELOG_FILE = 'CHANGELOG.md'
const CONTRIBUTING_FILE = 'CONTRIBUTING.md'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const lernaConfig = require('../lerna.json')
const { runMain, modifyFile } = require('./utils')
const lernaConfig = require('../../lerna.json')
const { runMain, modifyFile } = require('../lib/utils')

// This script updates the peer dependency versions between rum and logs packages to match the new
// version during a release.
Expand Down
2 changes: 1 addition & 1 deletion scripts/staging-ci/check-squash-into-staging.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { initGitConfig, command, printLog, printError, runMain } = require('../utils')
const { initGitConfig, command, printLog, printError, runMain } = require('../lib/utils')

const REPOSITORY = process.env.GIT_REPOSITORY
const CI_COMMIT_SHA = process.env.CI_COMMIT_SHA
Expand Down
2 changes: 1 addition & 1 deletion scripts/staging-ci/check-staging-merge.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { initGitConfig, command, printLog, printError, runMain } = require('../utils')
const { initGitConfig, command, printLog, printError, runMain } = require('../lib/utils')

const REPOSITORY = process.env.GIT_REPOSITORY
const CI_COMMIT_SHA = process.env.CI_COMMIT_SHA
Expand Down
2 changes: 1 addition & 1 deletion scripts/staging-ci/merge-into-staging.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { initGitConfig, command, printLog, printError, runMain } = require('../utils')
const { initGitConfig, command, printLog, printError, runMain } = require('../lib/utils')

const REPOSITORY = process.env.GIT_REPOSITORY
const CURRENT_STAGING_BRANCH = process.env.CURRENT_STAGING
Expand Down
2 changes: 1 addition & 1 deletion scripts/staging-ci/staging-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
runMain,
replaceCiFileVariable,
readCiFileVariable,
} = require('../utils')
} = require('../lib/utils')

const REPOSITORY = process.env.GIT_REPOSITORY
const MAIN_BRANCH = process.env.MAIN_BRANCH
Expand Down
2 changes: 1 addition & 1 deletion scripts/bs-wrapper.js β†’ scripts/test/bs-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// after killing it. There might be a better way of prematurely aborting the test command if we need
// to in the future.

const { spawnCommand, printLog, runMain, command, fetch } = require('./utils')
const { spawnCommand, printLog, runMain, command, fetch } = require('../lib/utils')

const AVAILABILITY_CHECK_DELAY = 30_000
const BS_USERNAME = process.env.BS_USERNAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
getSecretKey,
fetch,
CI_FILE,
} = require('./utils')
} = require('../lib/utils')

const REPOSITORY = process.env.GIT_REPOSITORY
const MAIN_BRANCH = process.env.MAIN_BRANCH
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { getSecretKey, command, printLog, runMain } = require('./utils')
const { getSecretKey, command, printLog, runMain } = require('../lib/utils')

/**
* Upload test result to datadog
Expand Down
2 changes: 1 addition & 1 deletion webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path')
const webpack = require('webpack')
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const buildEnv = require('./scripts/build-env')
const buildEnv = require('./scripts/lib/build-env')

const tsconfigPath = path.join(__dirname, 'tsconfig.webpack.json')

Expand Down

0 comments on commit 6c436f1

Please sign in to comment.