To ensure that the Trace Agent works cross-platform, we use TypeScript build scripts located in the scripts
directory. The entry point to these scripts is index.ts
. The usage of this file is ts-node -p ./scripts ./scripts/index.ts [command1] [...moreCommands]
(assuming that you are running in the repository root directory.)
The list of possible build commands is enumerated as case
statements in index.ts
, in addition to npm-*
commands. See index.ts
for more details.
npm run script
is an alias for ts-node -p ./scripts ./scripts/index.ts
.
For example, to compile all scripts and then initialize test fixtures, the command to use would be one of:
# Option 1
ts-node -p ./scripts ./scripts/index.ts npm-compile-all init-test-fixtures
# Option 2
npm run script npm-compile-all init-test-fixtures
# Option 3
npm run compile-all
npm run script init-test-fixtures
They are equivalent.
The minimum list of commands needed to run unit tests are:
npm install
export GCLOUD_TRACE_NEW_CONTEXT=1 # This is required. See cloud-trace-nodejs #650
npm run compile
npm run init-test-fixtures
npm test # Or "npm run script run-unit-tests"
A convenient one-liner for this (after npm install
) is:
npm install
GCLOUD_TRACE_NEW_CONTEXT=1 npm run script npm-compile-all init-test-fixtures run-unit-tests
You will need to have mysql, postgres, redis, and mongo instances listening on their corresponding canonical ports. When running locally, you can use ./bin/docker-trace.sh start
to start docker images that does this for you.
The Trace Agent unit tests rely on installing traced modules fixed at distinct version ranges. See plugin-fixtures.json
for the list of fixtures.
We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles.
Please fill out either the individual or corporate Contributor License Agreement (CLA).
- If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an individual CLA.
- If you work for a company that wants to allow you to contribute your work, then you'll need to sign a corporate CLA.
Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.
- Submit an issue describing your proposed change to the repo in question.
- The repo owner will respond to your issue promptly.
- If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
- Fork the desired repo, develop and test your code changes.
- Submit a pull request.