Create, test, and publish JavaScript/Python transformations and libraries directly from your development repository.
4 minute read
RudderStack’s Transformation Action lets you create, update, test, and publish transformations and libraries written in JavaScript or Python - directly from your development repository. Internally, this action leverages the Transformations API.
This action is currently available for GitHub only.
Prerequisites
You will need the email address associated with your RudderStack workspace.
For production use cases, RudderStack recommends using a Service Access Token instead of Personal Access Token.
For security purposes, it is highly recommended to use GitHub secrets to store your Service Access Token.
Usage
See the sample workflow for more information on using the action.
name:RudderStack Transformer Test and Publishuses:rudderlabs/rudder-transformation-action@<current_action_version>with:metaPath:'./code/meta.json'email:'test@rudderlabs.com'accessToken:${{ secrets.ACCESS_TOKEN }}uploadTestArtifact:true
Specify the email address and Service Access Token obtained in the Prerequisites section in the email and accessToken fields respectively.
See FAQ for more information on the uploadTestArtifact parameter.
Action fields
Field
Description
metapathRequired
Path to the meta file that:
Lets the action know about what transformations/libraries to test based on the input events and the expected output.
Publishes the transformations/libraries if the test passes.
As mentioned above, a meta file lets the transformation action know what transformations or libraries to test depending on the input events and the expected output.
A generic meta file schema is shown below:
// Meta file schema
{"transformations":<arrayoftransformationschema>,"libraries":<arrayoflibraryschema>}
A sample meta file is shown below:
// example meta.json
{"transformations":[{"file":"./code/t1.js","name":"action-T1","language":"javascript","description":"action-T1","test-input-file":"./code/testevents.json","expected-output":"./code/expectedoutput.json"},{"file":"./code/t2.py","name":"action-T2","language":"pythonfaas","description":"action-T2","test-input-file":"./code/events.json","expected-output":"./code/expected.json"}],"libraries":[{"file":"./code/lib1.js","name":"lib1","language":"javascript","description":"action-lib1"},{"file":"./code/lib2.py","name":"getFinanceDataPy","language":"pythonfaas","description":"Python library to get finance data"}]}
The path mentioned in the file field should be relative to the base repository path.
Transformation schema
The transformations parameter in the meta file contains an array of transformation schemas. A single transformation schema contains the following parameters:
Parameter
Description
fileRequired
Path to the transformation code.
nameRequired
Transformation name.
languageRequired
Transformation language. Permissible values are javascript and pythonfaas.
description
Transformation description.
test-input-file
Path to the JSON file containing an array of events to test the transformation.
expected-output
Path to the JSON file containing the expected output for the above input, after running the transformation code.
Library schema
The libraries parameter in the meta file contains an array of library schemas. A single library schema contains the following parameters:
Parameter
Description
fileRequired
Path to the library code.
nameRequired
Library name that you must specify to import it in any transformation.
languageRequired
Library language. Permissible values are javascript and pythonfaas.
description
Library description.
FAQ
How do I use the uploadTestArtifact parameter?
When you set uploadTestArtifact to true in the transformation action, RudderStack:
Runs the transformation on the test events present in test-input-file.
Generates and stores the output in a test-outputs folder contained within a zipped artifact.
Validates the output against the contents of the file specified in expected-output.
Note that:
RudderStack stores the output from Step 1 in a [transformation name in camel case]_output.json file.
It stores the validation differences from Step 3 in the respective [transformation name in camel case]_diff.json file.
If you do not set uploadTestArtifact to true in the transformation action, RudderStack does not create the output zip containing the above files.
For more context, see the use case below.
Consider the following transformation schema:
// single transformationSchema
{"file":"./code/t1.js","name":"action-T1","language":"javascript","description":"action-T1","test-input-file":"./code/testevents.json","expected-output":"./code/expectedoutput.json"}
The workflow when you set uploadTestArtifact to true is as follows:
RudderStack runs the transformation action-T1(with its code present in t1.js) on the testevents.json file.
RudderStack then:
Generates and stores the output from Step 1 in a file named actionT1_output.json. This file is stored in a test-outputs folder contained within a zipped artifact.
Validates the output with the contents present in the expectedoutput.json file. It stores any differences in a file named actionT1_diff.json.
The test-outputs folder contains the two files - actionT1_output.json and actionT1_diff.json.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.