Skip to content

Commit e507a5b

Browse files
Added architecture doc and updated author in package.json
1 parent 8971cc6 commit e507a5b

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

Architecture.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Architecture for Upload Custom Code Action
2+
3+
## Overview
4+
At it's heart, this action is a script that takes as inputs some
5+
custom code and some parameters regarding where the custom code
6+
should be uploaded to. It uses these parameters to update the
7+
appropriate project or experiment with the custom code via the
8+
Optimizely [REST API](https://docs.developers.optimizely.com/web/docs/rest-api-introduction).
9+
10+
## How does it work?
11+
`index.js` serves as the main entrypoint into the script and any
12+
errors ultimately bubble up to there and are outputted to Github's
13+
action mechanism (`core.setOutput`).
14+
15+
The real fun starts in the `run` function inside of `main.js`.
16+
17+
At a high level, `run`:
18+
1. Parses the passed in parameters
19+
2. Fetches the appropriate entity (either a project or experiment) from Optimizely
20+
3. Updates the entity with the custom code
21+
4. Sends the updated entity back to Optimizely
22+
23+
If at any point errors are encountered, abort and bubble those up to `index.js`.
24+
25+
If completely successful, report out to Github's action mechanism
26+
that we were successful.
27+
28+
### Helper Folder and Files
29+
* `Env` contains functions used to parse the parameters. All
30+
verification of parameter values are done here.
31+
32+
* `Utils` contains a number of utility functions used in the script.
33+
* The most important ones are `generateProjectData` and `generateExpData`
34+
which serve as entry points to updating the entity's custom code.
35+
* Keep in mind that these functions are highly dependent on the
36+
Optimizely REST API's response formats. If the REST API is updated
37+
to return data in a different object, these functions must be
38+
updated as well.
39+
40+
* `Constants` as the name implies simply contains some constants.
41+
42+
## Testing
43+
Tests are run using mocha, sinon, and chai. Run them with `npm test`.
44+
* The test setup is in `test_setup.js`.
45+
* The bigger pieces of test data are in `test_data.js`.
46+
47+
Each function is unit tested and each code file (except `index.js`)
48+
has a corresponding `test.js` file that contains unit tests for the
49+
functions in that file.
50+
51+
## Linting
52+
Linting is handled by ESLint. See `.eslintrc.js` for the configuration.
53+
54+
Linting is run automatically as a pre-commit hook.
55+
56+
## Updating and Deploying
57+
1. Clone the Repo and make your code updates.
58+
2. Generate a new action package with `npm run-script build`.
59+
3. Commit and push a PR to Github. Get it approved and merged
60+
into main.
61+
4. Create a release on Github with a new tag based on the new
62+
semver version number.
63+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"url": "git+https://github.com/optimizely/upload-custom-code-action.git"
1414
},
1515
"keywords": [],
16-
"author": "",
16+
"author": "Optimizely",
1717
"bugs": {
1818
"url": "https://github.com/optimizely/upload-custom-code-action/issues"
1919
},

0 commit comments

Comments
 (0)