Skip to content

Commit

Permalink
Merge branch 'main' into aj/java21
Browse files Browse the repository at this point in the history
  • Loading branch information
astuyve committed Dec 7, 2023
2 parents 4e866c5 + a45b80c commit 72f9be1
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 76 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/build_serverless.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: build_serverless

on:
push:
branches:
- "master"
pull_request:
on: [push, pull_request]

jobs:
check-formatting:
Expand All @@ -15,16 +11,16 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 16

- name: Cache Node modules
id: cache-node-modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
Expand All @@ -40,7 +36,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Cloud Formation Linter with Latest Version
uses: scottbrenner/cfn-lint-action@v2
Expand All @@ -58,12 +54,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 16

- name: Cache Node modules
id: cache-node-modules
Expand All @@ -86,20 +82,20 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14, 16, 18, 20]

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Cache Node modules
id: cache-node-modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
Expand Down
63 changes: 32 additions & 31 deletions serverless/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion serverless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datadog-serverless-macro",
"version": "0.7.2",
"version": "0.9.0",
"description": "Cloudformation macro to automatically instrument python and node functions with datadog tracing",
"repository": "https://github.com/DataDog/datadog-cloudformation-macro",
"author": "Datadog",
Expand Down
12 changes: 6 additions & 6 deletions serverless/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ if [ "$PROD_RELEASE" = true ] ; then
exit 1
fi

# Make sure we are on master
# Make sure we are on main
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ $BRANCH != "master" ]; then
echo "Not on master, aborting"
if [ $BRANCH != "main" ]; then
echo "Not on main, aborting"
exit 1
fi

Expand All @@ -66,7 +66,7 @@ if [ "$PROD_RELEASE" = true ] ; then
fi

# Get the latest code
git pull origin master
git pull origin main

# Bump version number
echo "Bumping the current version number to the desired"
Expand All @@ -76,14 +76,14 @@ if [ "$PROD_RELEASE" = true ] ; then
# Commit version number changes to git
git add src/ template.yml README.md package.json
git commit -m "Bump version from ${CURRENT_VERSION} to ${VERSION}"
git push origin master
git push origin main

# Create a github release
echo "Release serverless-macro-${VERSION} to github"
go get github.com/github/hub
./tools/build_zip.sh "${VERSION}"

hub release create -a .macro/serverless-macro-${VERSION}.zip -m "serverless-macro-${VERSION}" serverless-macro-${VERSION}
gh release create serverless-macro${VERSION} .macro/serverless-macro-${VERSION}.zip --generate-notes
TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro/latest.yml"
MACRO_SOURCE_URL="https://github.com/DataDog/datadog-cloudformation-macro/releases/download/serverless-macro-${VERSION}/serverless-macro-${VERSION}.zip'"
else
Expand Down
3 changes: 2 additions & 1 deletion serverless/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ export function validateParameters(config: Configuration) {
"datadoghq.eu",
"us3.datadoghq.com",
"us5.datadoghq.com",
"ap1.datadoghq.com",
"ddog-gov.com",
];
if (config.site !== undefined && !siteList.includes(config.site.toLowerCase())) {
errors.push(
"Warning: Invalid site URL. Must be either datadoghq.com, datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, or ddog-gov.com.",
"Warning: Invalid site URL. Must be either datadoghq.com, datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, or ddog-gov.com.",
);
}
if (config.extensionLayerVersion !== undefined) {
Expand Down
2 changes: 2 additions & 0 deletions serverless/src/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const runtimeLookup: { [key: string]: RuntimeType } = {
"nodejs14.x": RuntimeType.NODE,
"nodejs16.x": RuntimeType.NODE,
"nodejs18.x": RuntimeType.NODE,
"nodejs20.x": RuntimeType.NODE,
"python2.7": RuntimeType.PYTHON,
"python3.6": RuntimeType.PYTHON,
"python3.7": RuntimeType.PYTHON,
Expand All @@ -63,6 +64,7 @@ function runtimeToLayerName(runtime: string, architecture: string): string | und
"nodejs14.x": "Datadog-Node14-x",
"nodejs16.x": "Datadog-Node16-x",
"nodejs18.x": "Datadog-Node18-x",
"nodejs20.x": "Datadog-Node20-x",
};

const pythonLookup: { [key: string]: string } = {
Expand Down
5 changes: 3 additions & 2 deletions serverless/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Transform: AWS::Serverless-2016-10-31
Mappings:
Constants:
DatadogServerlessMacro:
Version: 0.7.2
Version: 0.9.0

Parameters:
FunctionName:
Expand Down Expand Up @@ -56,6 +56,7 @@ Resources:
- Ref: FunctionName
- Ref: AWS::NoValue
Description: Processes a CloudFormation template to install Datadog Lambda layers for Python and Node.js Lambda functions.
Timeout: 10
Handler: src/index.handler
Runtime: nodejs16.x
CodeUri:
Expand Down Expand Up @@ -117,7 +118,7 @@ Resources:
Properties:
Description: Copies Datadog CloudFormation macro zip to the destination S3 bucket
Handler: index.handler
Runtime: python3.7
Runtime: python3.11
Timeout: 300
InlineCode: |
import json
Expand Down
21 changes: 20 additions & 1 deletion serverless/test/env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ describe("validateParameters", () => {
const errors = validateParameters(params);
expect(
errors.includes(
"Warning: Invalid site URL. Must be either datadoghq.com, datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, or ddog-gov.com.",
"Warning: Invalid site URL. Must be either datadoghq.com, datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, or ddog-gov.com.",
),
).toBe(true);
});
Expand Down Expand Up @@ -707,6 +707,25 @@ describe("validateParameters", () => {
const errors = validateParameters(params);
expect(errors.includes("`apiKey` and `apiKMSKey` should not be set at the same time.")).toBe(true);
});

it("works with ap1", () => {
const params = {
addLayers: true,
apiKey: "1234",
flushMetricsToLogs: true,
logLevel: "info",
site: "ap1.datadoghq.com",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
};

const errors = validateParameters(params);
console.log({ errors });
expect(errors.length).toEqual(0);
});
});

describe("checkForMultipleApiKeys", () => {
Expand Down
2 changes: 2 additions & 0 deletions serverless/test/layer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe("findLambdas", () => {
Node14Function: mockFunctionResource("nodejs14.x", ["x86_64"]),
Node16Function: mockFunctionResource("nodejs16.x", ["x86_64"]),
Node18Function: mockFunctionResource("nodejs18.x", ["x86_64"]),
Node20Function: mockFunctionResource("nodejs20.x", ["x86_64"]),
Python27Function: mockFunctionResource("python2.7", ["x86_64"]),
Python36Function: mockFunctionResource("python3.6", ["x86_64"]),
Python37Function: mockFunctionResource("python3.7", ["x86_64"]),
Expand All @@ -75,6 +76,7 @@ describe("findLambdas", () => {
mockLambdaFunction("Node14Function", "nodejs14.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node16Function", "nodejs16.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node18Function", "nodejs18.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Node20Function", "nodejs20.x", RuntimeType.NODE, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python27Function", "python2.7", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python36Function", "python3.6", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python37Function", "python3.7", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
Expand Down
53 changes: 36 additions & 17 deletions serverless/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3165,6 +3165,11 @@ [email protected]:
resolved "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz"
integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=

querystringify@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==

react-is@^17.0.1:
version "17.0.2"
resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz"
Expand Down Expand Up @@ -3232,6 +3237,11 @@ require-main-filename@^2.0.0:
resolved "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==

resolve-cwd@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz"
Expand Down Expand Up @@ -3330,21 +3340,21 @@ saxes@^5.0.1:
xmlchars "^2.2.0"

"semver@2 || 3 || 4 || 5", semver@^5.5.0:
version "5.7.1"
resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
version "5.7.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==

[email protected], semver@^7.2.1, semver@^7.3.2:
version "7.3.7"
resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

semver@^6.0.0, semver@^6.3.0:
version "6.3.0"
resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

set-blocking@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -3693,13 +3703,14 @@ to-regex@^3.0.1, to-regex@^3.0.2:
safe-regex "^1.1.0"

tough-cookie@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz"
integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==
version "4.1.3"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf"
integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==
dependencies:
psl "^1.1.33"
punycode "^2.1.1"
universalify "^0.1.2"
universalify "^0.2.0"
url-parse "^1.5.3"

tr46@^2.1.0:
version "2.1.0"
Expand Down Expand Up @@ -3797,10 +3808,10 @@ union-value@^1.0.0:
is-extendable "^0.1.1"
set-value "^2.0.1"

universalify@^0.1.2:
version "0.1.2"
resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
universalify@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0"
integrity sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==

unset-value@^1.0.0:
version "1.0.0"
Expand All @@ -3822,6 +3833,14 @@ urix@^0.1.0:
resolved "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz"
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=

url-parse@^1.5.3:
version "1.5.10"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1"
integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==
dependencies:
querystringify "^2.1.1"
requires-port "^1.0.0"

[email protected]:
version "0.10.3"
resolved "https://registry.npmjs.org/url/-/url-0.10.3.tgz"
Expand Down

0 comments on commit 72f9be1

Please sign in to comment.