Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ steps:
agents:
queue: v1
command:
- git config --global --add safe.directory $(pwd)
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
- yarn install --frozen-lockfile
- yarn test
Expand All @@ -19,18 +20,20 @@ steps:
s3_bucket_name: "segment-buildkite-cache"
save: true
- docker#v3.3.0:
image: circleci/node:12.18-browsers
image: cimg/node:20.18-browsers
user: root
environment:
- NPM_TOKEN
- CHROME-BIN=google-chrome
- CHROME_BIN=google-chrome

- label: ":hammer: Build and Test Master"
key: "build_master"
branches: "master"
agents:
queue: v1
command:
- apt-get update && apt-get install -y git
- git config --global --add safe.directory $(pwd)
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
- yarn install --frozen-lockfile
- yarn test-master
Expand All @@ -41,17 +44,19 @@ steps:
s3_bucket_name: "segment-buildkite-cache"
save: true
- docker#v3.3.0:
image: circleci/node:12.18-browsers
image: cimg/node:20.18-browsers
user: root
environment:
- NPM_TOKEN
- CHROME-BIN=google-chrome
- CHROME_BIN=google-chrome

- label: "SauceLabs"
key: "sauce_labs"
branches: "!master"
soft_fail: true
command:
- apt-get update && apt-get install -y git
- git config --global --add safe.directory $(pwd)
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
- yarn install --ignore-engines
- yarn test:ci
Expand All @@ -73,6 +78,8 @@ steps:
branches: "master"
soft_fail: true
command:
- apt-get update && apt-get install -y git
- git config --global --add safe.directory $(pwd)
- npm config set "//registry.npmjs.org/:_authToken" $${NPM_TOKEN}
- yarn install --ignore-engines
- yarn test-master:ci
Expand Down Expand Up @@ -116,4 +123,4 @@ steps:
- ssh://git@github.com/segmentio/cache-buildkite-plugin#v1.0.0:
key: "v1-cache-dev-{{ checksum 'yarn.lock' }}"
paths: ["node_modules/"]
s3_bucket_name: "segment-buildkite-cache"
s3_bucket_name: "segment-buildkite-cache"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"test-master:ci": "lerna run --concurrency 1 --stream test:ci -- --log-level error",
"compile": "webpack --config webpack.config.integrations.js && webpack --config webpack.config.middleware.js",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && rm -rf build && yarn compile",
"dev": "concurrently \"yarn --cwd tester serve\" \"webpack --config webpack.config.tester.js --watch\""
"dev": "export NODE_OPTIONS=--openssl-legacy-provider && concurrently \"yarn --cwd tester serve\" \"webpack --config webpack.config.tester.js --watch\""
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"aws-sdk": "^2.760.0",
"@aws-sdk/client-s3": "3.988.0",
"babel-loader": "^8.2.2",
"chai": "4.2.0",
"compression-webpack-plugin": "^6.0.1",
Expand Down
62 changes: 30 additions & 32 deletions scripts/upload-assets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const S3 = require('aws-sdk/clients/s3');
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
const fs = require('fs-extra');
const path = require('path');
const logUpdate = require('log-update');
Expand Down Expand Up @@ -48,11 +48,13 @@ async function uploadAssets() {
throw new Error('Local Path required');
}

const s3 = new S3({
accessKeyId,
secretAccessKey,
sessionToken,
region: 'us-west-2'
const s3 = new S3Client({
region: 'us-west-2',
credentials: {
accessKeyId,
secretAccessKey,
sessionToken
}
});

const absolutePaths = await getFiles(localPath);
Expand Down Expand Up @@ -95,7 +97,7 @@ async function uploadAssets() {
options.CacheControl = 'public,max-age=31536000,immutable';
}

return s3.putObject(options).promise();
return s3.send(new PutObjectCommand(options));
};

const uploads = relativeFiles.map(async fileName => {
Expand Down Expand Up @@ -159,30 +161,26 @@ async function uploadAssets() {

await Promise.all(uploads);

await s3 // upload "latest" manifest file
.putObject({
Bucket: bucket,
Key: key('/manifest-latest.json'),
Body: zlib.gzipSync(JSON.stringify(manifest)),
ContentEncoding: process.env.CONTENT_ENCODING,
CacheControl: 'public, max-age=120',
GrantRead: cfCanonicalUserIdsParsed,
GrantFullControl: `id=${platformCanonicalUserId}`,
ContentType: 'application/json'
})
.promise();

await s3 // upload hash manifest file
.putObject({
Bucket: bucket,
Key: key(`/manifest-${sha}.json`),
Body: zlib.gzipSync(JSON.stringify(manifest)),
ContentEncoding: process.env.CONTENT_ENCODING,
GrantRead: cfCanonicalUserIdsParsed,
GrantFullControl: `id=${platformCanonicalUserId}`,
ContentType: 'application/json'
})
.promise();
await s3.send(new PutObjectCommand({ // upload "latest" manifest file
Bucket: bucket,
Key: key('/manifest-latest.json'),
Body: zlib.gzipSync(JSON.stringify(manifest)),
ContentEncoding: process.env.CONTENT_ENCODING,
CacheControl: 'public, max-age=120',
GrantRead: cfCanonicalUserIdsParsed,
GrantFullControl: `id=${platformCanonicalUserId}`,
ContentType: 'application/json'
}));

await s3.send(new PutObjectCommand({ // upload hash manifest file
Bucket: bucket,
Key: key(`/manifest-${sha}.json`),
Body: zlib.gzipSync(JSON.stringify(manifest)),
ContentEncoding: process.env.CONTENT_ENCODING,
GrantRead: cfCanonicalUserIdsParsed,
GrantFullControl: `id=${platformCanonicalUserId}`,
ContentType: 'application/json'
}));
}

(async function main() {
Expand All @@ -193,4 +191,4 @@ async function uploadAssets() {
console.error(err);
process.exit(1);
}
})();
})();
Loading