If the jslib-aws does not support the service you need yet, the best way to get it to help is by contributing to it.
- The project uses the TypeScript language. TypeScript is a superset of the Javascript language and essentially adds static typing and functional constructs to the language. It compiles into Javascript, which is then used by the k6 runtime.
- The project files should be formatted using the Prettier tool. The project has a
.prettierrc.json
file containing the tool's configuration. - The project uses webpack to produce build files. Because k6 does not have native support typescript, and its Javascript runtime does not support the
import
statement, the project uses webpack to produce a file containing all the code that k6 scripts can use. The project has awebpack.config.js
file containing the tool's configuration. Each service is built into its dedicated file, and an overarchingaws.js
contains them for convenience. - To allow easier testing, files in the
src
directory are organized in a public/private structure. Files at the root of the folder are the public files; they import the content of the internal (private) directory and explicitly export the symbols that should be made available to the user. The internal files are the ones that contain the actual implementation of the service. The internal files are not exported and are not meant to be used directly by the user. - The project is tested in an end2end fashion using the k6 tool. The tests live in the
tests
directory. The tests are written in Javascript and use the k6 chai js jslib to test the functionality of the library. Thenpm test
command runs the test suites. The tests run in a docker container, and thedocker-compose.yml
file contains the configuration for the container. The docker-compose setup spins up a localstack setup, which emulates AWS locally, and the test script performs its assertions against it directly.
- The project uses the kebab-case naming convention for files and directories.
- The project uses the pascal-case naming convention for classes, interfaces, and types.
- Service client class names should be of the form
ServiceNameClient
, whereServiceName
is the name of the service, in pascal-case, or all capitalized if it is an acronym (as in:KMSClient
,S3Client
,SQSClient
, etc.).
- Create a new file in the
src/internal
directory. The file's name should be the service's name in kebab-case. For example, if you want to add support for theAWS Systems Manager
service, the file should be namedsystems-manager.ts
. - The file should expose a service client class following the above conventions. The class should inherit from
AWSClient
, and its constructor should take anAWSConfig
object as its only argument. - For each service operation (action) the author wishes to implement, the service class should implement a dedicated public method.
- Most service operations require signing requests using the AWS V4 signature process. The
SignatureV4
construct exposed in thesrc/internal/signature.ts
file allows signing requests to AWS services easily. Checkout the existing service implementations for examples of how to use it: in S3Client, and in SecretsManagerService for instance. - Tests verifying that the service class works as expected should be added in the
tests/internal
directory. The dedicated test file should follow the same naming convention as the service class file, except it should have the.js
extension. For example, if the service class file is namedsystems-manager.ts
, the test file should be calledsystems-manager.js
. - Test files should consists in a k6 script using the k6 chai js library, and exporting a single
{serviceName}TestSuite(data)
function. This function should consist of a set ofdescribe
statements containing the actual test assertions, as demonstrated in the existing s3 test suite. The test suite should be imported and called in thetests/internal/index.js
test script, which is the entry point for the test suite. - If the tests depend on a specific pre-existing state of the localstack setup, you can add a dedicated script in the
tests/internal/localstack_init
folder. Localstack will execute all the commands present in this script during its setup phase. - The
npm test
command runs the test suite. This command will build the project and run the tests against the spun-up localstack docker container. Thedocker-compose.yml
file contains the configuration for the container. - Once the tests pass, the
src/index.ts
file should export the service class in thesrc/index.ts
file so the user can use it. - To get the build system to produce a dedicated
- The service should have tests.
- The service should have documentation.
- The service should be re-exported in the
src/index.ts
file. - The service should be exposed in the
aws.js
file in thebuild
directory when running thenpm run webpack
command. - The service should produce a dedicated
{service-name}.js
file in thebuild
directory when running thenpm run webpack
command. - The service should produce source map files for the dedicated
{service-name}.js
file and theaws.js
file in thebuild
directory when running thenpm run webpack
command.
In a PR:
- Bump the version in the
package.json
file. - Run the
npm update
command to update thepackage-lock.json
file. - Run the
npm run webpack
command to ensure the build system produces the latest distributable files.
- Tag the latest main branch's commit with the new version, following the semantic versioning convention, prefixed with a
v
character, as in:v0.7.1
. - Create a dedicated GitHub version:
- Pointing to the tag created above
- Using the same name as the tag created above
- Including the build files included in the commit tagged above
- Open a PR on the jslib repository using the
build/
directory files following the new version instructions. - Make sure the k6 documentation website is updated to include the new version of the library:
- The documented API should reflect the new version.
- All the links to the library should point to the new version.