Skip to content

Commit 689b27a

Browse files
committed
Circleci project setup (#1)
* Multiple fixes in failing tests * Avoid infinite loops when creating sObjects types that refer to themselves. For that purpose, a cache was introduced so that references can be extracted from it and avoid creating a new object, which kicks off the infinite recursion. * Fix bug when trying to create an sObject because of a reference, but that sObject type is non-createable. * API token logic needed for integ tests * Add JWT tool needed for integ tests * Add logic to retrieve Salesforce API token * Add CLI tool to create/delete webhooks * Add Integration Tests * Add CircleCI setup * Add list of SObjects to test * Multiple fixes in SObjectFactory * Reduce range of random components to avoid formatting numbers like `100,000` (which in most cases are not valid names) * Fix typo for `Username` SObject type * Fix random strings to start with letter and to only contain alphanumeric chars * Adapt tests to ChangeEvent entities * Split list of SObjects based on change events * Add metadata templates for change data capture * Add verified list of sobjects for each type of event * CircleCI and integ tests cleanup * Apply prettier settings * Remove ChangeEvent types for now * Add unit tests * Add coverage * CircleCI NPM publish setup
1 parent 7e35e67 commit 689b27a

File tree

80 files changed

+7304
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+7304
-292
lines changed

.circleci/config.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
version: 2
2+
3+
general:
4+
branches:
5+
only:
6+
- dev
7+
- master
8+
9+
defaults: &defaults
10+
working_directory: ~/repo
11+
docker:
12+
- image: circleci/node:lts-buster
13+
14+
jobs:
15+
build_and_test:
16+
<<: *defaults
17+
18+
environment:
19+
KEYS_DIR: '/tmp/keys'
20+
DX_CLI_URL: 'https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz'
21+
22+
steps:
23+
- checkout
24+
25+
- restore_cache:
26+
keys:
27+
- v1-dependencies-{{ checksum "package-lock.json" }}
28+
- v1-dependencies-
29+
30+
- run:
31+
name: Node Dependencies
32+
command: |
33+
npm install
34+
35+
- save_cache:
36+
paths:
37+
- node_modules
38+
key: v1-dependencies-{{ checksum "package-lock.json" }}
39+
40+
- persist_to_workspace:
41+
root: ~/repo
42+
paths: .
43+
44+
- run:
45+
name: Build Package
46+
command: |
47+
npm run build
48+
49+
- run:
50+
name: Unit Tests
51+
command: |
52+
npm test
53+
54+
- run:
55+
name: Salesforce CLI
56+
command: |
57+
mkdir sfdx
58+
wget -qO- ${DX_CLI_URL} | tar xJ -C sfdx --strip-components 1
59+
./sfdx/install
60+
sfdx
61+
mkdir tmp
62+
63+
- run:
64+
name: Other Dependencies
65+
command: |
66+
wget -q -O jq 'https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64'
67+
chmod +x jq
68+
sudo mv jq /bin
69+
70+
- run:
71+
name: Create Cert and Key Files
72+
command: |
73+
mkdir -p ${KEYS_DIR}
74+
echo ${SERVER_CRT_BASE64} | base64 -d > ${KEYS_DIR}/server.crt
75+
echo ${SERVER_KEY_ENC_BASE64} | base64 -d > ${KEYS_DIR}/server.key.enc
76+
openssl enc \
77+
-nosalt \
78+
-aes-256-cbc \
79+
-d \
80+
-in ${KEYS_DIR}/server.key.enc \
81+
-out ${KEYS_DIR}/server.key \
82+
-base64 \
83+
-K ${DECRYPTION_KEY} \
84+
-iv ${DECRYPTION_IV}
85+
86+
- run:
87+
name: Setup Org
88+
command: |
89+
sfdx force:auth:jwt:grant \
90+
--clientid ${HUB_CONSUMER_KEY} \
91+
--jwtkeyfile ${KEYS_DIR}/server.key \
92+
--username ${HUB_SFDC_USER} \
93+
--setdefaultdevhubusername \
94+
-a hub
95+
96+
- run:
97+
name: Integration Tests
98+
working_directory: test/integ
99+
no_output_timeout: 270m
100+
environment:
101+
SALESFORCE_API_VERSION: '50.0'
102+
TEST_REPORTS_DIR_BASE: test_reports
103+
command: |
104+
sfdx config:set defaultusername=${HUB_SFDC_USER}
105+
./deploy_and_test_apex.sh
106+
107+
- store_test_results:
108+
working_directory: test/integ
109+
path: test/integ/test_reports
110+
111+
publish:
112+
<<: *defaults
113+
114+
steps:
115+
- checkout
116+
117+
- restore_cache:
118+
keys:
119+
- v1-dependencies-{{ checksum "package-lock.json" }}
120+
- v1-dependencies-
121+
122+
- add_ssh_keys:
123+
fingerprints:
124+
- 'eb:79:6a:d5:94:92:0f:75:b8:29:75:8c:56:bd:4a:f2'
125+
126+
- run:
127+
name: Update Package Version
128+
command: |
129+
npm version --no-git-tag-version version $CIRCLE_TAG -m "[skip ci] Update package version: %s"
130+
git push origin master
131+
132+
- run:
133+
name: Publish NPM Package
134+
command: |
135+
echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
136+
npm publish
137+
138+
workflows:
139+
version: 2
140+
ci-cd:
141+
jobs:
142+
- build_and_test:
143+
filters:
144+
branches:
145+
only:
146+
- dev
147+
- master
148+
- publish:
149+
requires:
150+
- build_and_test
151+
filters:
152+
branches:
153+
ignore: /.*/
154+
tags:
155+
only: /^\d+\.\d+\.\d+$/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
22
node_modules
3+
.nyc_output

.mocharc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": ["esm", "handlebars-loader"],
3+
"spec": "test/unit/**/*.test.js",
4+
"timeout": 10000
5+
}

.nycrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"all": true,
3+
"include": ["src/**/*.js"],
4+
"require": ["esm"],
5+
"reporter": "text",
6+
"check-coverage": true,
7+
"lines": 100,
8+
"functions": 100,
9+
"branches": 100,
10+
"statements": 100
11+
}

0 commit comments

Comments
 (0)