From e49d277096a8fa6432195e1131faf3a47cebf66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20L=C3=B3pez=20de=20la=20Franca=20Beltran?= <5459617+joanlopez@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:01:23 +0100 Subject: [PATCH] Switch from 'build' to 'dist' (#92) * Switch from 'build' to 'dist' * Update release gh workflow * Redirect diff output to /dev/null --- .eslintignore | 2 +- .github/workflows/all.yml | 16 ++++++++++++---- .github/workflows/release.yml | 4 ++-- .gitignore | 3 ++- CONTRIBUTING.md | 6 +++--- README.md | 7 ++----- {build => dist}/aws.js | 0 {build => dist}/aws.js.LICENSE.txt | 0 {build => dist}/aws.js.map | 0 {build => dist}/event-bridge.js | 0 {build => dist}/event-bridge.js.LICENSE.txt | 0 {build => dist}/event-bridge.js.map | 0 {build => dist}/index.js | 0 {build => dist}/index.js.LICENSE.txt | 0 {build => dist}/index.js.map | 0 {build => dist}/kinesis.js | 0 {build => dist}/kinesis.js.LICENSE.txt | 0 {build => dist}/kinesis.js.map | 0 {build => dist}/kms.js | 0 {build => dist}/kms.js.LICENSE.txt | 0 {build => dist}/kms.js.map | 0 {build => dist}/lambda.js | 0 {build => dist}/lambda.js.LICENSE.txt | 0 {build => dist}/lambda.js.map | 0 {build => dist}/s3.js | 0 {build => dist}/s3.js.LICENSE.txt | 0 {build => dist}/s3.js.map | 0 {build => dist}/secrets-manager.js | 0 {build => dist}/secrets-manager.js.LICENSE.txt | 0 {build => dist}/secrets-manager.js.map | 0 {build => dist}/signature.js | 0 {build => dist}/signature.js.map | 0 {build => dist}/sqs.js | 0 {build => dist}/sqs.js.LICENSE.txt | 0 {build => dist}/sqs.js.map | 0 {build => dist}/ssm.js | 0 {build => dist}/ssm.js.LICENSE.txt | 0 {build => dist}/ssm.js.map | 0 examples/event-bridge.js | 2 +- examples/kinesis.js | 2 +- examples/kms.js | 2 +- examples/lambda.js | 2 +- examples/s3-multipart.js | 2 +- examples/s3.js | 2 +- examples/secrets-manager.js | 2 +- examples/signature-presign.js | 2 +- examples/signature-sign.js | 2 +- examples/sqs.js | 2 +- examples/ssm.js | 2 +- tests/index.js | 2 +- tests/internal/event-bridge.js | 2 +- tests/internal/kinesis.js | 2 +- tests/internal/kms.js | 2 +- tests/internal/lambda.js | 2 +- tests/internal/s3.js | 2 +- tests/internal/secrets-manager.js | 2 +- tests/internal/signature.js | 2 +- tests/internal/sqs.js | 2 +- tests/internal/ssm.js | 2 +- webpack.config.js | 2 +- 60 files changed, 44 insertions(+), 38 deletions(-) rename {build => dist}/aws.js (100%) rename {build => dist}/aws.js.LICENSE.txt (100%) rename {build => dist}/aws.js.map (100%) rename {build => dist}/event-bridge.js (100%) rename {build => dist}/event-bridge.js.LICENSE.txt (100%) rename {build => dist}/event-bridge.js.map (100%) rename {build => dist}/index.js (100%) rename {build => dist}/index.js.LICENSE.txt (100%) rename {build => dist}/index.js.map (100%) rename {build => dist}/kinesis.js (100%) rename {build => dist}/kinesis.js.LICENSE.txt (100%) rename {build => dist}/kinesis.js.map (100%) rename {build => dist}/kms.js (100%) rename {build => dist}/kms.js.LICENSE.txt (100%) rename {build => dist}/kms.js.map (100%) rename {build => dist}/lambda.js (100%) rename {build => dist}/lambda.js.LICENSE.txt (100%) rename {build => dist}/lambda.js.map (100%) rename {build => dist}/s3.js (100%) rename {build => dist}/s3.js.LICENSE.txt (100%) rename {build => dist}/s3.js.map (100%) rename {build => dist}/secrets-manager.js (100%) rename {build => dist}/secrets-manager.js.LICENSE.txt (100%) rename {build => dist}/secrets-manager.js.map (100%) rename {build => dist}/signature.js (100%) rename {build => dist}/signature.js.map (100%) rename {build => dist}/sqs.js (100%) rename {build => dist}/sqs.js.LICENSE.txt (100%) rename {build => dist}/sqs.js.map (100%) rename {build => dist}/ssm.js (100%) rename {build => dist}/ssm.js.LICENSE.txt (100%) rename {build => dist}/ssm.js.map (100%) diff --git a/.eslintignore b/.eslintignore index 685d12f..1924f06 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ .cache/ -build/ +dist/ public/ node_modules/ diff --git a/.github/workflows/all.yml b/.github/workflows/all.yml index dd90499..e1f06ed 100644 --- a/.github/workflows/all.yml +++ b/.github/workflows/all.yml @@ -17,6 +17,17 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install npm packages + run: npm install + + - name: Verify the build is up to date + run: | + npm run webpack -- --output-path="${RUNNER_TEMP}/dist" + if ! diff -r "${RUNNER_TEMP}/dist" dist > /dev/null; then + echo "Build is out of date, please run 'npm run webpack' and commit the changes" + exit 1 + fi + - name: Install Go uses: actions/setup-go@v4 with: @@ -31,8 +42,5 @@ jobs: - name: Wait for the localstack scripts to have been applied run: sleep 30 - - name: Install npm packages - run: npm install - - name: Test - run: npm run webpack && npm run ci-test + run: npm run ci-test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d317a6..9902682 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,11 +22,11 @@ jobs: run: | set -x VERSION="${GITHUB_REF##*/}" - npm run webpack && tar -zcf "k6-jslib-aws-${VERSION}.tar.gz" -C build . + npm run webpack && tar -zcf "k6-jslib-aws-${VERSION}.tar.gz" -C dist . - name: Create release with assets env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -x VERSION="${GITHUB_REF##*/}" - gh release create "${VERSION}" "k6-jslib-aws-${VERSION}.tar.gz" "build/*" --target "${GITHUB_SHA}" --title "${VERSION}" \ No newline at end of file + gh release create "${VERSION}" "k6-jslib-aws-${VERSION}.tar.gz" "dist/*" --target "${GITHUB_SHA}" --title "${VERSION}" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 661015b..77d4eae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -/volume \ No newline at end of file +/volume +build/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bca7102..a72cac1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,9 +39,9 @@ If the jslib-aws does not support the service you need yet, the best way to get 1. The service should have tests. 2. The service should have documentation. 3. The service should be re-exported in the `src/index.ts` file. -4. The service should be exposed in the `aws.js` file in the `build` directory when running the `npm run webpack` command. -5. The service should produce a dedicated `{service-name}.js` file in the `build` directory when running the `npm run webpack` command. -6. The service should produce source map files for the dedicated `{service-name}.js` file and the `aws.js` file in the `build` directory when running the `npm run webpack` command. +4. The service should be exposed in the `aws.js` file in the `dist` directory when running the `npm run webpack` command. +5. The service should produce a dedicated `{service-name}.js` file in the `dist` directory when running the `npm run webpack` command. +6. The service should produce source map files for the dedicated `{service-name}.js` file and the `aws.js` file in the `dist` directory when running the `npm run webpack` command. #### Steps diff --git a/README.md b/README.md index bba7b42..dbe45a3 100644 --- a/README.md +++ b/README.md @@ -417,16 +417,13 @@ The scope of this library has been kept minimal and limited to the use cases we, npm install # Bundle it in preparation for a publication -npm run-script webpack +npm run webpack # Run the tests npm test ``` -### Deploying new versions - -1. Build. -2. Use the `./dist/aws.js` to make a PR to [jslib.k6.io](https://github.com/grafana/jslib.k6.io). +For further details, take a look at [CONTRIBUTING.md](CONTRIBUTING.md). ## Maintainers diff --git a/build/aws.js b/dist/aws.js similarity index 100% rename from build/aws.js rename to dist/aws.js diff --git a/build/aws.js.LICENSE.txt b/dist/aws.js.LICENSE.txt similarity index 100% rename from build/aws.js.LICENSE.txt rename to dist/aws.js.LICENSE.txt diff --git a/build/aws.js.map b/dist/aws.js.map similarity index 100% rename from build/aws.js.map rename to dist/aws.js.map diff --git a/build/event-bridge.js b/dist/event-bridge.js similarity index 100% rename from build/event-bridge.js rename to dist/event-bridge.js diff --git a/build/event-bridge.js.LICENSE.txt b/dist/event-bridge.js.LICENSE.txt similarity index 100% rename from build/event-bridge.js.LICENSE.txt rename to dist/event-bridge.js.LICENSE.txt diff --git a/build/event-bridge.js.map b/dist/event-bridge.js.map similarity index 100% rename from build/event-bridge.js.map rename to dist/event-bridge.js.map diff --git a/build/index.js b/dist/index.js similarity index 100% rename from build/index.js rename to dist/index.js diff --git a/build/index.js.LICENSE.txt b/dist/index.js.LICENSE.txt similarity index 100% rename from build/index.js.LICENSE.txt rename to dist/index.js.LICENSE.txt diff --git a/build/index.js.map b/dist/index.js.map similarity index 100% rename from build/index.js.map rename to dist/index.js.map diff --git a/build/kinesis.js b/dist/kinesis.js similarity index 100% rename from build/kinesis.js rename to dist/kinesis.js diff --git a/build/kinesis.js.LICENSE.txt b/dist/kinesis.js.LICENSE.txt similarity index 100% rename from build/kinesis.js.LICENSE.txt rename to dist/kinesis.js.LICENSE.txt diff --git a/build/kinesis.js.map b/dist/kinesis.js.map similarity index 100% rename from build/kinesis.js.map rename to dist/kinesis.js.map diff --git a/build/kms.js b/dist/kms.js similarity index 100% rename from build/kms.js rename to dist/kms.js diff --git a/build/kms.js.LICENSE.txt b/dist/kms.js.LICENSE.txt similarity index 100% rename from build/kms.js.LICENSE.txt rename to dist/kms.js.LICENSE.txt diff --git a/build/kms.js.map b/dist/kms.js.map similarity index 100% rename from build/kms.js.map rename to dist/kms.js.map diff --git a/build/lambda.js b/dist/lambda.js similarity index 100% rename from build/lambda.js rename to dist/lambda.js diff --git a/build/lambda.js.LICENSE.txt b/dist/lambda.js.LICENSE.txt similarity index 100% rename from build/lambda.js.LICENSE.txt rename to dist/lambda.js.LICENSE.txt diff --git a/build/lambda.js.map b/dist/lambda.js.map similarity index 100% rename from build/lambda.js.map rename to dist/lambda.js.map diff --git a/build/s3.js b/dist/s3.js similarity index 100% rename from build/s3.js rename to dist/s3.js diff --git a/build/s3.js.LICENSE.txt b/dist/s3.js.LICENSE.txt similarity index 100% rename from build/s3.js.LICENSE.txt rename to dist/s3.js.LICENSE.txt diff --git a/build/s3.js.map b/dist/s3.js.map similarity index 100% rename from build/s3.js.map rename to dist/s3.js.map diff --git a/build/secrets-manager.js b/dist/secrets-manager.js similarity index 100% rename from build/secrets-manager.js rename to dist/secrets-manager.js diff --git a/build/secrets-manager.js.LICENSE.txt b/dist/secrets-manager.js.LICENSE.txt similarity index 100% rename from build/secrets-manager.js.LICENSE.txt rename to dist/secrets-manager.js.LICENSE.txt diff --git a/build/secrets-manager.js.map b/dist/secrets-manager.js.map similarity index 100% rename from build/secrets-manager.js.map rename to dist/secrets-manager.js.map diff --git a/build/signature.js b/dist/signature.js similarity index 100% rename from build/signature.js rename to dist/signature.js diff --git a/build/signature.js.map b/dist/signature.js.map similarity index 100% rename from build/signature.js.map rename to dist/signature.js.map diff --git a/build/sqs.js b/dist/sqs.js similarity index 100% rename from build/sqs.js rename to dist/sqs.js diff --git a/build/sqs.js.LICENSE.txt b/dist/sqs.js.LICENSE.txt similarity index 100% rename from build/sqs.js.LICENSE.txt rename to dist/sqs.js.LICENSE.txt diff --git a/build/sqs.js.map b/dist/sqs.js.map similarity index 100% rename from build/sqs.js.map rename to dist/sqs.js.map diff --git a/build/ssm.js b/dist/ssm.js similarity index 100% rename from build/ssm.js rename to dist/ssm.js diff --git a/build/ssm.js.LICENSE.txt b/dist/ssm.js.LICENSE.txt similarity index 100% rename from build/ssm.js.LICENSE.txt rename to dist/ssm.js.LICENSE.txt diff --git a/build/ssm.js.map b/dist/ssm.js.map similarity index 100% rename from build/ssm.js.map rename to dist/ssm.js.map diff --git a/examples/event-bridge.js b/examples/event-bridge.js index 444b8d9..2948fe6 100644 --- a/examples/event-bridge.js +++ b/examples/event-bridge.js @@ -1,4 +1,4 @@ -import { AWSConfig, EventBridgeClient } from '../build/event-bridge.js'; +import { AWSConfig, EventBridgeClient } from '../dist/event-bridge.js'; const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/kinesis.js b/examples/kinesis.js index 857e0bc..46eaf15 100644 --- a/examples/kinesis.js +++ b/examples/kinesis.js @@ -1,4 +1,4 @@ -import { AWSConfig, KinesisClient } from '../build/kinesis.js' +import { AWSConfig, KinesisClient } from '../dist/kinesis.js' import encoding from 'k6/encoding' import { fail } from 'k6' diff --git a/examples/kms.js b/examples/kms.js index 1ca912f..ad14005 100644 --- a/examples/kms.js +++ b/examples/kms.js @@ -1,6 +1,6 @@ import exec from 'k6/execution' -import { AWSConfig, KMSClient } from '../build/kms.js' +import { AWSConfig, KMSClient } from '../dist/kms.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/lambda.js b/examples/lambda.js index 2dc18a5..8a0a6c4 100644 --- a/examples/lambda.js +++ b/examples/lambda.js @@ -1,4 +1,4 @@ -import { AWSConfig, LambdaClient } from '../build/lambda.js' +import { AWSConfig, LambdaClient } from '../dist/lambda.js' import { check } from 'k6'; const awsConfig = new AWSConfig({ diff --git a/examples/s3-multipart.js b/examples/s3-multipart.js index e1e0389..e5928b6 100644 --- a/examples/s3-multipart.js +++ b/examples/s3-multipart.js @@ -1,7 +1,7 @@ import crypto from 'k6/crypto' import exec from 'k6/execution' -import { AWSConfig, S3Client } from '../build/s3.js' +import { AWSConfig, S3Client } from '../dist/s3.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/s3.js b/examples/s3.js index ae6529f..d0cf473 100644 --- a/examples/s3.js +++ b/examples/s3.js @@ -1,6 +1,6 @@ import exec from 'k6/execution' -import { AWSConfig, S3Client } from '../build/s3.js' +import { AWSConfig, S3Client } from '../dist/s3.js' const testFile = open('./bonjour.txt', 'r') diff --git a/examples/secrets-manager.js b/examples/secrets-manager.js index 62668d0..1adcb3d 100644 --- a/examples/secrets-manager.js +++ b/examples/secrets-manager.js @@ -1,6 +1,6 @@ import exec from 'k6/execution' -import { AWSConfig, SecretsManagerClient } from '../build/secrets-manager.js' +import { AWSConfig, SecretsManagerClient } from '../dist/secrets-manager.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/signature-presign.js b/examples/signature-presign.js index 1da86bf..61c5c02 100644 --- a/examples/signature-presign.js +++ b/examples/signature-presign.js @@ -5,7 +5,7 @@ import { AWSConfig, SignatureV4, AMZ_CONTENT_SHA256_HEADER, -} from '../build/aws.js' +} from '../dist/aws.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/signature-sign.js b/examples/signature-sign.js index cd40260..6135000 100644 --- a/examples/signature-sign.js +++ b/examples/signature-sign.js @@ -1,6 +1,6 @@ import http from 'k6/http' -import { AWSConfig, SignatureV4 } from '../build/signature.js' +import { AWSConfig, SignatureV4 } from '../dist/signature.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/sqs.js b/examples/sqs.js index d7a6838..6df1989 100644 --- a/examples/sqs.js +++ b/examples/sqs.js @@ -1,6 +1,6 @@ import exec from 'k6/execution' -import { AWSConfig, SQSClient } from '../build/sqs.js' +import { AWSConfig, SQSClient } from '../dist/sqs.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/examples/ssm.js b/examples/ssm.js index d260819..3d108e7 100644 --- a/examples/ssm.js +++ b/examples/ssm.js @@ -1,6 +1,6 @@ import exec from 'k6/execution' -import { AWSConfig, SystemsManagerClient } from '../build/ssm.js' +import { AWSConfig, SystemsManagerClient } from '../dist/ssm.js' const awsConfig = new AWSConfig({ region: __ENV.AWS_REGION, diff --git a/tests/index.js b/tests/index.js index 10824e1..7ea2685 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,6 +1,6 @@ import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js' -import { AWSConfig } from '../build/aws.js' +import { AWSConfig } from '../dist/aws.js' import { s3TestSuite } from './internal/s3.js' import { secretsManagerTestSuite } from './internal/secrets-manager.js' diff --git a/tests/internal/event-bridge.js b/tests/internal/event-bridge.js index ba10b3d..e604aa4 100644 --- a/tests/internal/event-bridge.js +++ b/tests/internal/event-bridge.js @@ -1,5 +1,5 @@ import { asyncDescribe } from './helpers.js' -import { EventBridgeClient } from '../../build/event-bridge.js' +import { EventBridgeClient } from '../../dist/event-bridge.js' export async function eventBridgeTestSuite(data) { const eventBridge = new EventBridgeClient(data.awsConfig) diff --git a/tests/internal/kinesis.js b/tests/internal/kinesis.js index f02003b..35febd0 100644 --- a/tests/internal/kinesis.js +++ b/tests/internal/kinesis.js @@ -1,5 +1,5 @@ import { asyncDescribe } from './helpers.js' -import { KinesisClient } from '../../build/kinesis.js' +import { KinesisClient } from '../../dist/kinesis.js' import encoding from 'k6/encoding' import { sleep } from 'k6' diff --git a/tests/internal/kms.js b/tests/internal/kms.js index ffc2502..596cad5 100644 --- a/tests/internal/kms.js +++ b/tests/internal/kms.js @@ -1,5 +1,5 @@ import { asyncDescribe } from './helpers.js' -import { KMSClient } from '../../build/kms.js' +import { KMSClient } from '../../dist/kms.js' export async function kmsTestSuite(data) { const kmsClient = new KMSClient(data.awsConfig) diff --git a/tests/internal/lambda.js b/tests/internal/lambda.js index ea8c7a8..d4c7c11 100644 --- a/tests/internal/lambda.js +++ b/tests/internal/lambda.js @@ -1,5 +1,5 @@ import { asyncDescribe } from './helpers.js' -import { LambdaClient } from '../../build/lambda.js' +import { LambdaClient } from '../../dist/lambda.js' export async function lambdaTestSuite(data) { const lambdaClient = new LambdaClient(data.awsConfig) diff --git a/tests/internal/s3.js b/tests/internal/s3.js index 470640d..a65c0e8 100644 --- a/tests/internal/s3.js +++ b/tests/internal/s3.js @@ -1,6 +1,6 @@ import { asyncDescribe } from './helpers.js' -import { S3Client, S3ServiceError } from '../../build/s3.js' +import { S3Client, S3ServiceError } from '../../dist/s3.js' export async function s3TestSuite(data) { const s3Client = new S3Client(data.awsConfig) diff --git a/tests/internal/secrets-manager.js b/tests/internal/secrets-manager.js index 9d397c5..c515240 100644 --- a/tests/internal/secrets-manager.js +++ b/tests/internal/secrets-manager.js @@ -2,7 +2,7 @@ import { asyncDescribe } from './helpers.js' import { SecretsManagerClient, SecretsManagerServiceError, -} from '../../build/secrets-manager.js' +} from '../../dist/secrets-manager.js' export async function secretsManagerTestSuite(data) { const secretsManagerClient = new SecretsManagerClient(data.awsConfig) diff --git a/tests/internal/signature.js b/tests/internal/signature.js index aca8cf8..18b0393 100644 --- a/tests/internal/signature.js +++ b/tests/internal/signature.js @@ -14,7 +14,7 @@ import { HOST_HEADER, SIGNING_ALGORITHM_IDENTIFIER, UNSIGNED_PAYLOAD, -} from '../../build/signature.js' +} from '../../dist/signature.js' import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.0/index.js' diff --git a/tests/internal/sqs.js b/tests/internal/sqs.js index 1bdbc1c..470cff6 100644 --- a/tests/internal/sqs.js +++ b/tests/internal/sqs.js @@ -1,6 +1,6 @@ import { asyncDescribe } from './helpers.js' import { b64encode } from 'k6/encoding' -import { SQSClient, SQSServiceError } from '../../build/sqs.js' +import { SQSClient, SQSServiceError } from '../../dist/sqs.js' export async function sqsTestSuite(data) { const sqsClient = new SQSClient(data.awsConfig) diff --git a/tests/internal/ssm.js b/tests/internal/ssm.js index 1057223..8ab7e9a 100644 --- a/tests/internal/ssm.js +++ b/tests/internal/ssm.js @@ -1,5 +1,5 @@ import { asyncDescribe } from './helpers.js' -import { SystemsManagerClient, SystemsManagerServiceError } from '../../build/ssm.js' +import { SystemsManagerClient, SystemsManagerServiceError } from '../../dist/ssm.js' export async function ssmTestSuite(data) { const systemsManagerClient = new SystemsManagerClient(data.awsConfig) diff --git a/webpack.config.js b/webpack.config.js index 7858e13..fbfade5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -25,7 +25,7 @@ module.exports = { signature: path.resolve(__dirname, 'src/signature.ts'), }, output: { - path: path.resolve(__dirname, 'build'), + path: path.resolve(__dirname, 'dist'), libraryTarget: 'commonjs', filename: '[name].js', },