Skip to content

Commit

Permalink
Merge pull request #1 from rudderlabs/test-action
Browse files Browse the repository at this point in the history
test action
sivashanmukh authored Apr 27, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents aa477bb + fe57fe4 commit bdc972c
Showing 6 changed files with 80 additions and 877 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Test

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
request:
@@ -13,7 +19,7 @@ jobs:
uses: ./
with:
metaPath: './code/meta.json'
email: 'sayan+10@rudderlabs.com'
accessKey: ${{ secrets.ACCESS_KEY }}
serverEndpoint: 'https://1a3bd53e8df2.ngrok.io'
email: 'test1619427853838@rudderlabs.com'
accessKey: '1rhrWotHszP3eVma57BzAP67QWA'
serverEndpoint: 'https://aa88e07d9346.ngrok.io'
uploadTestArtifact: true
6 changes: 3 additions & 3 deletions code/expected.json
Original file line number Diff line number Diff line change
@@ -3,14 +3,14 @@
"revenue": 0,
"price": 0,
"profit": 0,
"city": "kolkata",
"country": "India",
"city": "no data found",
"country": "no data found",
"street": "no data found"
},
{
"revenue": 0,
"price": 20,
"profit": 0,
"profit": 20,
"city": "no data found",
"country": "no data found",
"street": "no data found"
20 changes: 16 additions & 4 deletions code/meta.json
Original file line number Diff line number Diff line change
@@ -2,23 +2,35 @@
"transformations": [
{
"file": "./code/code.js",
"name": "action-T13",
"description": "action-T13",
"name": "action-T14",
"description": "action-T14",
"type": "transformation",
"test-input-file": "./code/events.json",
"expected-output": "./code/expected.json"
},
{
"file": "./code/code_2.js",
"name": "action-T13_2",
"name": "action-T14_2",
"description": "action-T13_2",
"type": "transformation"
},
{
"file": "./code/code_3.js",
"name": "action-T13_3",
"name": "action-T14_3",
"description": "action-T13_3",
"type": "transformation"
}
],
"libraries": [
{
"file": "./code/lib1.js",
"name": "getFinanceData13",
"description": "action-T13-lib"
},
{
"file": "./code/lib2.js",
"name": "getUserAddress13",
"description": "action-T13_2-lib"
}
]
}
898 changes: 40 additions & 858 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/apiCalls.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const axios = require("axios");
const core = require("@actions/core");
const serverEndpoint = core.getInput("serverEndpoint");
const serverEndpoint = core.getInput("serverEndpoint") || 'https://api.rudderstack.com';
const createTransformerEndpoint = `${serverEndpoint}/transformations`;
const createLibraryEndpoint = `${serverEndpoint}/libraries`;
const testEndpoint = `${serverEndpoint}/transformations/libraries/test`;
17 changes: 10 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -96,7 +96,6 @@ async function testAndPublish() {
}
transformationDict[res.data.versionId] = { ...tr, id: res.data.id };
}

core.info("transformations create/update done!");

for (let i = 0; i < libraries.length; i++) {
@@ -115,7 +114,6 @@ async function testAndPublish() {
}
libraryDict[res.data.versionId] = { ...lib, id: res.data.id };
}

core.info("libraries create/update done!");

let transformationTest = [];
@@ -171,8 +169,13 @@ async function testAndPublish() {
fs.mkdirSync(testOutputDir);
}
for (let i = 0; i < successResults.length; i++) {
let transformerVersionID = successResults[i].transformerVersionID;
if (!transformationDict.hasOwnProperty(transformerVersionID) || !transformationDict[transformerVersionID].hasOwnProperty("expected-output")) {
continue;
}

let expectedOutputfile =
transformationDict[successResults[i].transformerVersionID][
transformationDict[transformerVersionID][
"expected-output"
];
let expectedOutput = expectedOutputfile
@@ -182,11 +185,11 @@ async function testAndPublish() {
let apiOutput = successResults[i].result.output;

let transformationName =
transformationDict[successResults[i].transformerVersionID].name;
transformationDict[transformerVersionID].name;

fs.writeFileSync(
`${testOutputDir}/${transformationName}_output.json`,
JSON.stringify(apiOutput)
JSON.stringify(apiOutput, null, 2)
);
testOutputFiles.push(
`${testOutputDir}/${transformationName}_output.json`
@@ -199,13 +202,13 @@ async function testAndPublish() {
if (!isEqual(expectedOutput, apiOutput)) {
errorResults.push(
`Transformer name: ${
transformationDict[successResults[i].transformerVersionID].name
transformationDict[transformerVersionID].name
} test outputs don't match`
);

fs.writeFileSync(
`${testOutputDir}/${transformationName}_diff.json`,
JSON.stringify(detailedDiff(expectedOutput, apiOutput))
JSON.stringify(detailedDiff(expectedOutput, apiOutput), null, 2)
);

testOutputFiles.push(

0 comments on commit bdc972c

Please sign in to comment.