Skip to content

Commit

Permalink
Merge pull request #1 from GoogleCloudPlatform/main
Browse files Browse the repository at this point in the history
Merge all new changes from the official Google repository.
  • Loading branch information
sethrwebster authored Sep 15, 2023
2 parents 002b61a + 7274c78 commit c0b521b
Show file tree
Hide file tree
Showing 84 changed files with 13,761 additions and 57,108 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git
**/node_modules/
**/Dockerfile
**/dist/
16 changes: 16 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Global owners
* @GoogleCloudPlatform/opentelemetry-ops
9 changes: 9 additions & 0 deletions .github/trusted-contribution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Config reference:
# https://github.com/googleapis/repo-automation-bots/tree/main/packages/trusted-contribution

trustedContributors:
- renovate-bot
annotations:
# Automatically run Cloud Build tests
- type: comment
text: /gcbrun
18 changes: 6 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14, 16]
node: [14, 16, 18, 19]
include:
# use latest npm by default
- npm-version: latest
# overrides for node 10 and 12
- node: 10
npm-version: ^7
- node: 12
npm-version: ^8
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -26,19 +21,18 @@ jobs:
# TODO: remove once node 14 is dropped
- name: Upgrade to latest npm to support lockfile v2
run: npm install -g npm@${{ matrix.npm-version }}
- run: npm install --ignore-scripts
- run: npx lerna bootstrap --no-ci
- run: npm install
- run: npm test
- run: npm run codecov
if: matrix.node == 14
if: matrix.node == 19

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 15
node-version: 19
- run: npm install
- run: npm run lint

Expand All @@ -51,9 +45,9 @@ jobs:
for f in $(git ls-files "**package-lock.json")
do
lockfileVersion=$(jq ".lockfileVersion" $f)
if [ $lockfileVersion -ne 2 ]
if [ $lockfileVersion -lt 2 ]
then
>&2 echo "package-lock.json files should have lockfileVersion 2, but $f has version $lockfileVersion"
>&2 echo "package-lock.json files should have at least lockfileVersion 2, but $f has version $lockfileVersion"
exit 1
fi
done
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ node_modules/
npm-debug.log
.nyc_output/
build/
dist/

#backup files
*--
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OpenTelemetry Google Cloud Trace Exporter allows the user to send collected trac

### Getting Started

This exporter package assumes your application is [already instrumented](https://github.com/open-telemetry/opentelemetry-js/blob/main/getting-started/README.md) with the OpenTelemetry SDK. Once you are ready to export OpenTelemetry data, you can add this exporter to your application:
This exporter package assumes your application is [already instrumented](https://opentelemetry.io/docs/instrumentation/js/getting-started/) with the OpenTelemetry SDK. Once you are ready to export OpenTelemetry data, you can add this exporter to your application:

```sh
npm install --save @google-cloud/opentelemetry-cloud-trace-exporter
Expand Down
56 changes: 56 additions & 0 deletions cloudbuild-e2e-cloud-functions-gen2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0 #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
# Cloud Functions doesn't play nice with lerna monorepos, so build tarballs of the local
# dependencies and include them in the source zip.
- name: node:16-alpine
id: build
script: |
set -x
# install dev deps and tools for the monorepo
apk add zip jq
# bootstrap and compile only the packages needed for e2e test server
npm install --workspace=./e2e-test-server
npx lerna@^7 run compile --scope=@google-cloud/e2e-test-server --include-dependencies
# builds a small self contained bundle with @vercel/ncc under dist/
cd e2e-test-server
# --external will avoid bundling functions-framework. Needed so we only have one copy of
# global variables in that package when GCF executes it.
npm run bundle -- --external @google-cloud/functions-framework
# create a new fake package.json in dist/ and zip it up into a source zip for Cloud
# Functions
cd dist
cp ../fake.package.json package.json
zip -qr function-source.zip .
# Run the test
- name: $_TEST_RUNNER_IMAGE
id: run-tests-cloud-functions
dir: /
env: ["PROJECT_ID=$PROJECT_ID"]
args:
- cloud-functions-gen2
- --functionsource=/workspace/e2e-test-server/dist/function-source.zip
- --runtime=nodejs16
- --entrypoint=cloudFunctionHandler

logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
timeout: 20m
substitutions:
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.17.0
_TEST_SERVER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-js-e2e-test-server:${SHORT_SHA}
37 changes: 37 additions & 0 deletions cloudbuild-e2e-cloud-run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0 #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
# Wait for the image to exist
- name: "docker"
id: wait-for-image
entrypoint: "sh"
timeout: 10m
env: ["_TEST_SERVER_IMAGE=${_TEST_SERVER_IMAGE}"]
args:
- e2e-test-server/wait-for-image.sh

# Run the test
- name: $_TEST_RUNNER_IMAGE
id: run-tests-cloud-run
dir: /
env: ["PROJECT_ID=$PROJECT_ID"]
args:
- cloud-run
- --image=$_TEST_SERVER_IMAGE

logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
timeout: 20m
substitutions:
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.17.0
_TEST_SERVER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-js-e2e-test-server:${SHORT_SHA}
39 changes: 39 additions & 0 deletions cloudbuild-e2e-gae.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
# Wait for the image to exist
- name: "docker"
id: wait-for-image
entrypoint: "sh"
timeout: 10m
env: ["_TEST_SERVER_IMAGE=${_TEST_SERVER_IMAGE}"]
args:
- e2e-test-server/wait-for-image.sh

# Run the test
- name: $_TEST_RUNNER_IMAGE
id: run-tests-gae
dir: /
env: ["PROJECT_ID=$PROJECT_ID"]
args:
- gae
- --image=$_TEST_SERVER_IMAGE
- --runtime=node

logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
timeout: 20m
substitutions:
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.17.0
_TEST_SERVER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-js-e2e-test-server:${SHORT_SHA}
2 changes: 1 addition & 1 deletion cloudbuild-e2e-gce.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ steps:
logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
timeout: 20m
substitutions:
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.15.0
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.17.0
_TEST_SERVER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-js-e2e-test-server:${SHORT_SHA}
2 changes: 1 addition & 1 deletion cloudbuild-e2e-gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ steps:
logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
timeout: 20m
substitutions:
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.15.0
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.17.0
_TEST_SERVER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-js-e2e-test-server:${SHORT_SHA}
2 changes: 1 addition & 1 deletion cloudbuild-e2e-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ steps:
logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
timeout: 20m
substitutions:
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.15.0
_TEST_RUNNER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-e2e-testing:0.17.0
_TEST_SERVER_IMAGE: gcr.io/${PROJECT_ID}/opentelemetry-operations-js-e2e-test-server:${SHORT_SHA}
6 changes: 1 addition & 5 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,4 @@ Guidelines](https://opensource.google/conduct/).

## Running the tests

The command `npm test` tests code the same way that our CI will test it.
This is a convenience command for a number of steps, which can run separately if needed:

- `npm run compile` compiles the code, checking for type errors.
- `npm run bootstrap` Bootstrap the packages in the current Lerna repo. Installs all of their dependencies and links any cross-dependencies.
After checking out the repo, run `npm install`. Then run `npm test` to test code the same way that our CI will test it.
2 changes: 1 addition & 1 deletion docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ are not, re-run the command without `--conventional-commits` and lerna will
interactively ask you to input the correct bumps. You may need to do this when
first releasing a 0.X package as 1.0.0.

## Run `npm install`
## Run `npm install && npm run compile`

Don't forget this step! This will build everything and regenerate the
`src/version.ts` files in each subpackage.
Expand Down
2 changes: 1 addition & 1 deletion e2e-test-server/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "./node_modules/gts/"
"extends": "../node_modules/gts/"
}
36 changes: 10 additions & 26 deletions e2e-test-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,19 @@

# Build relative to root of repository i.e. `docker build --file Dockerfile --tag=$tag ..`

FROM node:19-alpine as node-base
FROM node:20-alpine as node-base
ENV SRC="/src"
RUN npm install -g npm@^7
USER node
WORKDIR $SRC

FROM node-base as build-base
USER root
RUN chown node:node $SRC
USER node
# copy local dependencies
COPY --chown=node:node packages/ packages/
COPY --chown=node:node scripts/ scripts/
COPY --chown=node:node lerna.json package.json package-lock.json ./
# copy package.json
COPY --chown=node:node e2e-test-server/package.json e2e-test-server/package-lock.json e2e-test-server/
# bootstrap without compile
RUN npx lerna bootstrap --ignore-scripts
# compile everything BUT e2e-test-server
RUN npx lerna run compile --ignore @google-cloud/e2e-test-server
# dereference lerna symlinks so we don't need to copy out the whole monorepo
RUN TMPDIR=$(mktemp -d) && \
cp --dereference --recursive e2e-test-server/node_modules/@google-cloud $TMPDIR/ && \
rm -rf e2e-test-server/node_modules/@google-cloud && \
mv $TMPDIR/@google-cloud e2e-test-server/node_modules/@google-cloud
COPY . ./
# bootstrap and compile only the packages needed for e2e test server
RUN npm install --workspace=./e2e-test-server
RUN npx lerna@^7 run compile --scope=@google-cloud/e2e-test-server --include-dependencies
# builds a small self contained bundle with @vercel/ncc under dist/
RUN cd e2e-test-server && npm run bundle

FROM node-base
COPY --from=build-base --chown=node:node $SRC/e2e-test-server $SRC/e2e-test-server/
WORKDIR $SRC/e2e-test-server
COPY --chown=node:node e2e-test-server/ ./
RUN npm run compile
ENTRYPOINT ["node", "build/src/index.js"]
USER node
COPY --from=build-base --chown=node:node $SRC/e2e-test-server/dist ./
ENTRYPOINT ["node", "index.js"]
10 changes: 10 additions & 0 deletions e2e-test-server/fake.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "cloud-functions-dist",
"version": "1.0.0",
"description": "A fake package.json used for the zip bundle sent to Cloud Functions",
"main": "index.js",
"dependencies": {
"@google-cloud/functions-framework": "3.2.0"
}
}
Loading

0 comments on commit c0b521b

Please sign in to comment.