Skip to content

Commit

Permalink
Merge branch 'main' into tm-bunyan-example-dep-ver
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm authored Dec 11, 2023
2 parents 98ccef8 + 196aa2d commit 34bbd2a
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 85 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/test-all-versions.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@ jobs:
env:
PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
outputs:
args: ${{ steps.lerna-args.outputs.args }}
args: ${{ steps.npm-workspace-args.outputs.args }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Need lerna to list all packages
- name: Install lerna
run: npm install -g [email protected]
- name: Parse labels into lerna scope arguments
id: lerna-args
- name: Parse labels into npm workspace arguments
id: npm-workspace-args
run: |
OUTPUT=`node scripts/parse-lerna-scopes.mjs "$PR_LABELS"`
OUTPUT=`node scripts/pr-labels-to-npm-workspace-args.mjs "$PR_LABELS"`
echo "args=$OUTPUT" >> $GITHUB_OUTPUT
tav:
uses: ./.github/workflows/test-all-versions.yml
needs: parse-labels
with:
lerna-args: ${{ needs.parse-labels.outputs.args }}
npm-workspace-args: ${{ needs.parse-labels.outputs.args }}
if: ${{ needs.parse-labels.outputs.args != '' }}
2 changes: 1 addition & 1 deletion .github/workflows/test-all-versions.push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
tav:
uses: ./.github/workflows/test-all-versions.yml
with:
lerna-args: ""
npm-workspace-args: ""
9 changes: 3 additions & 6 deletions .github/workflows/test-all-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
- cron: "30 4 * * *"
workflow_dispatch:
inputs:
lerna-args:
npm-workspace-args:
type: string
workflow_call:
inputs:
lerna-args:
npm-workspace-args:
required: true
type: string

Expand Down Expand Up @@ -115,9 +115,6 @@ jobs:
node-version: ${{ matrix.node }}
- name: Set MySQL variables
run: mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --host=${MYSQL_HOST} --port=${MYSQL_PORT} -e "SET GLOBAL log_output='TABLE'; SET GLOBAL general_log = 1;" mysql
- name: Legacy Peer Dependencies for npm 7
if: matrix.node == '16'
run: npm config set legacy-peer-deps=true
- name: Update npm to a version that supports workspaces (v7 or later)
if: ${{ matrix.node < 16 }}
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
Expand All @@ -126,4 +123,4 @@ jobs:
- name: Build
run: npm run compile
- name: Run test-all-versions
run: npx lerna run test-all-versions ${{ inputs.lerna-args }} ${{ matrix.lerna-extra-args }} --stream --concurrency 1
run: npm run --if-present --workspaces test-all-versions ${{ inputs.npm-workspace-args }}
7 changes: 2 additions & 5 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ jobs:
node-version: ${{ matrix.node }}
- name: Set MySQL variables
run: mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --host=${MYSQL_HOST} --port=${MYSQL_PORT} -e "SET GLOBAL log_output='TABLE'; SET GLOBAL general_log = 1;" mysql
- name: Legacy Peer Dependencies for npm 7
if: matrix.node == '16'
run: npm config set legacy-peer-deps=true
- name: Update npm to a version that supports workspaces (v7 or later)
if: ${{ matrix.node < 16 }}
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
Expand All @@ -135,10 +132,10 @@ jobs:
run: npm run compile
- name: Unit tests (Full)
if: matrix.code-coverage
run: npm run test -- ${{ matrix.lerna-extra-args }}
run: npm run test
- name: Unit tests (Delta)
if: ${{ !matrix.code-coverage }}
run: npm run test:ci:changed -- ${{ matrix.lerna-extra-args }}
run: npm run test:ci:changed
- name: Build examples
run: npm run compile:examples
- name: Report Coverage
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"test": "lerna run test",
"test:ci:changed": "lerna run test --since origin/main",
"test:browser": "lerna run test:browser --concurrency 1",
"test-all-versions": "npm run --if-present --workspaces test-all-versions",
"bump": "lerna publish",
"changelog": "lerna-changelog",
"lint": "lerna run lint",
Expand Down
12 changes: 7 additions & 5 deletions plugins/node/opentelemetry-instrumentation-aws-sdk/.tav.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
"aws-sdk":
# there are so many version to test, it can take forever.
# we will just sample few of them
versions: ">=2.1266.0 || 2.1262.0 || 2.1219.0 || 2.1048.0 || 2.1012.0 || 2.647.0 || 2.308.0"
# A small subset of releases in the range [2.308.0, 3) to reduce testing time.
versions: "2.308.0 || 2.548.0 || 2.785.0 || 2.1025.0 || 2.1265.0 || 2.1506.0 || >=2.1508.0"
commands:
- npm run test

"@aws-sdk/client-s3":
versions: ">=3.223.0 || 3.218.0 || 3.216.0 || 3.154.0 || 3.107.0 || 3.54.0 || 3.6.1"
# A small subset of releases in the range [3.6.1, 4) to reduce testing time.
# - 3.377.0 was a bad release (see issue #1828).
versions: "3.6.1 || 3.53.0 || 3.163.0 || 3.266.0 || 3.354.0 || 3.458.0 || >=3.462.0"
commands:
- npm run test

"@aws-sdk/client-sqs":
versions: ">=3.216.0 || 3.171.0 || 3.58.0 || 3.54.0 || 3.43.0 || 3.24.0"
# A small subset of releases in the range [3.24.0, 4) to reduce testing time.
versions: "3.24.0 || 3.85.0 || 3.194.0 || 3.278.0 || 3.357.0 || 3.461.0 || >=3.462.0"
commands:
- npm run test
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ describe('instrumentation-aws-sdk-v3', () => {
);
});

it('sqs receive add messaging attributes and context', done => {
it('sqs receive add messaging attributes', done => {
nock(`https://sqs.${region}.amazonaws.com/`)
.matchHeader('content-type', 'application/x-www-form-urlencoded')
.post('/')
Expand Down Expand Up @@ -438,17 +438,45 @@ describe('instrumentation-aws-sdk-v3', () => {
'SQS'
);
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[SemanticAttributes.HTTP_STATUS_CODE]).toEqual(
200
);
done();
});
});

// Propagating span context to SQS ReceiveMessage promise handler is
// broken with `@aws-sdk/client-sqs` v3.316.0 and later.
// https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1477
it.skip('sqs receive context', done => {
nock(`https://sqs.${region}.amazonaws.com/`)
.matchHeader('content-type', 'application/x-www-form-urlencoded')
.post('/')
.reply(
200,
fs.readFileSync('./test/mock-responses/sqs-receive.xml', 'utf8')
);
nock(`https://sqs.${region}.amazonaws.com/`)
.matchHeader('content-type', 'application/x-amz-json-1.0')
.post('/')
.reply(
200,
fs.readFileSync('./test/mock-responses/sqs-receive.json', 'utf8')
);

const params = {
QueueUrl:
'https://sqs.us-east-1.amazonaws.com/731241200085/otel-demo-aws-sdk',
MaxNumberOfMessages: 3,
};
sqsClient.receiveMessage(params).then(res => {
const receiveCallbackSpan = trace.getSpan(context.active());
expect(receiveCallbackSpan).toBeDefined();
const attributes = (receiveCallbackSpan as unknown as ReadableSpan)
.attributes;
expect(attributes[SemanticAttributes.MESSAGING_OPERATION]).toMatch(
MessagingOperationValues.RECEIVE
);
expect(span.attributes[SemanticAttributes.HTTP_STATUS_CODE]).toEqual(
200
);
done();
});
});
Expand Down
56 changes: 0 additions & 56 deletions scripts/parse-lerna-scopes.mjs

This file was deleted.

23 changes: 23 additions & 0 deletions scripts/pr-labels-to-npm-workspace-args.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Formats `-w WORKSPACE` arguments for `npm run` from "pkg:"-prefixed labels.
* Takes a JSON string as an argument and returns the formatted args in stdout.
*
* arg: '["pkg:instrumentation-pino", "urgent", "pkg:instrumentation-fs"]'
* stdout: '-w @opentelemetry/instrumentation-pino -w @opentelemetry/instrumentation-fs'
*/

const labels = JSON.parse(process.argv[2]);

console.error('Labels:', labels);

const workspaces = labels
.filter((l) => {
return l.startsWith('pkg:');
})
.map((l) => {
return l.replace(/^pkg:/, '@opentelemetry/');
});

console.error('Workspaces:', workspaces);

console.log(workspaces.map((w) => { return `-w ${w}`; }).join(' '));

0 comments on commit 34bbd2a

Please sign in to comment.