Skip to content

Commit e441f7b

Browse files
authored
Merge pull request #30 from maaaaarco/develop
Develop
2 parents 313f385 + 41f54f6 commit e441f7b

23 files changed

+705
-36
lines changed

.github/workflows/pr-validate.yml renamed to .github/workflows/pr-develop.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
name: PR Validate
1+
name: Pull Request to Develop
22

33
on:
44
pull_request:
55
branches: [ develop ]
66

77
jobs:
8-
validate_pr:
9-
# The type of runner that the job will run on
8+
validate_pull_request:
109
runs-on: ubuntu-latest
1110

1211
steps:
@@ -19,6 +18,10 @@ jobs:
1918
tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
2019
./sfdx-cli/install
2120
21+
- name: Install jq
22+
run: |
23+
sudo apt-get install jq
24+
2225
- name: Populate auth file
2326
shell: bash
2427
run: 'echo ${{secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt'
@@ -32,6 +35,12 @@ jobs:
3235
- name: Push source to scratch org
3336
run: 'sfdx force:source:push'
3437

38+
- name: Check code coverage
39+
run: |
40+
sfdx force:apex:test:run --codecoverage --resultformat json --synchronous --testlevel RunLocalTests --wait 10 > tests.json
41+
coverage=$(jq .result.summary.orgWideCoverage tests.json | grep -Eo "[[:digit:]]+")
42+
test $coverage -ge 75
43+
3544
- name: Delete scratch org
3645
if: always()
3746
run: 'sfdx force:org:delete -p -u ci_scratch'

.github/workflows/push-develop.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ jobs:
2727
run: 'sfdx force:auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d'
2828

2929
- name: Create new version
30-
run: 'sfdx force:package:version:create -x -p "Spaghetti CMD" -w 60'
30+
run: |
31+
sfdx force:package:version:create -x -p "Spaghetti CMD" -w 60 --codecoverage
32+
new_version_id=$(grep -o "04t[[:alnum:]]\{15\}" sfdx-project.json | tail -n1)
33+
echo "::set-env name=version_id::${new_version_id}"
34+
35+
- name: Check code coverage
36+
run: |
37+
test $(sfdx force:package:version:report -p "$version_id" --json | jq .result.HasPassedCodeCoverageCheck) = 'true'
3138
3239
- name: Install new version in Dev Hub
3340
run: |
34-
new_version_id=$(grep -o "04t[[:alnum:]]\{15\}" sfdx-project.json | tail -n1)
35-
sfdx force:package:install -p "$new_version_id" -u devhub --wait 10 --publishwait 10
41+
sfdx force:package:install -p "$version_id" -u devhub --wait 10 --publishwait 10
3642
3743
- name: Store new version id
3844
run: |
39-
new_version_id=$(grep -o "04t[[:alnum:]]\{15\}" sfdx-project.json | tail -n1)
40-
sed -i -e "s/04t[[:alnum:]]\{15\}/${new_version_id}/" README.md
45+
sed -i -e "s/04t[[:alnum:]]\{15\}/${version_id}/" README.md
4146
git config user.name "release[bot]"
4247
git config user.email "<>"
4348
git add README.md

.github/workflows/push-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Promote latest version
3434
run: |
3535
version_id=$(grep -o "04t[[:alnum:]]\{15\}" sfdx-project.json | tail -n1)
36-
sfdx force:package:version:promote -p "$version_id"
36+
sfdx force:package:version:promote -p "$version_id" --noprompt
3737
3838
- name: Tag new release
3939
run: |

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Contributing
2+
3+
1. Familiarize yourself with the codebase
4+
1. Create a new issue before starting your project so that we can keep track of
5+
what you are trying to add/fix.
6+
1. Fork this repository.
7+
1. Edit the code in your fork.
8+
1. Send us a pull request when you are done. We'll review your code, suggest any
9+
needed changes, and merge it in.
10+
11+
## Branches
12+
13+
- We work in `develop`.
14+
- Every push on `develop` will create a new package version
15+
- We release from `master`.
16+
- Our work happens in _topic_ branches (feature and/or bug-fix).
17+
- feature as well as bug-fix branches are based on `develop`
18+
19+
20+
### Merging `develop` into `master`
21+
22+
- When a development cycle finishes, the content of the `develop` is merged into `master` branch.
23+
- The latest package version is then promoted to `released`

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![release](https://img.shields.io/badge/release-Summer_'20-g)
1+
![release](https://img.shields.io/badge/release-Winter_'21-g)
22

33
# Custom Metadata Loader
44
Create or Update Custom Metadata Type records from CSV file
@@ -12,6 +12,7 @@ Create or Update Custom Metadata Type records from CSV file
1212
- [CSV columns](#user-guide-csv-cols)
1313
- [Limitations](#user-guide-limitations)
1414
- [Demo](#demo)
15+
- [Contributing](#contributing)
1516
- [Credits](#credits)
1617

1718
# Installation options <a id="installation"></a>
@@ -21,15 +22,15 @@ Create or Update Custom Metadata Type records from CSV file
2122
</a>
2223

2324
## URL (recommended) <a id="installation-url"></a>
24-
- [Production/Developer](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t1t000002hza1AAA)
25-
- [Sandbox](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t1t000002hza1AAA)
25+
- [Production/Developer](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t1t000003HUFbAAO)
26+
- [Sandbox](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t1t000003HUFbAAO)
2627

2728
This approach is recommended since all components will be deployed using a namespace, removing the chance of failures due to conflicting API names.
2829

2930
## Unlocked package (recommended) <a id="installation-unlocked-pkg"></a>
3031
You can install this as an Unlocked Package, using the CLI, by running the following command:
3132
```bash
32-
sfdx force:package:install --package "04t1t000002hza1AAA" --targetusername YOUR_ORG_ALIAS --wait 10 --publishwait 10
33+
sfdx force:package:install --package "04t1t000003HUFbAAO" --targetusername YOUR_ORG_ALIAS --wait 10 --publishwait 10
3334
```
3435
This approach is recommended since all components will be deployed using a namespace, removing the chance of failures due to conflicting API names.
3536

@@ -72,12 +73,15 @@ This application does not impose any hard limit on the CSV file size or number o
7273

7374
If your CSV file contains more than 250 rows the application will automatically split it into smaller chunks of 250 rows each. Chunks will be loaded sequentially.
7475

75-
In June 11, 2020 the [Salesforce CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm) released a bunch of new commands to work with Custom Metadata Types. Among these there's one that allows records creation from a CSV file. Check them out [here](https://github.com/forcedotcom/cli/blob/master/releasenotes/v48.md#48181-june-11-2020).
76+
For more complex use cases consider that the [Salesforce CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm) has a bunch of commands to work with Custom Metadata Types. Check them out [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_cmdt.htm#cli_reference_force_cmdt).
7677

7778
# Demo <a id="demo"></a>
7879
YouTube video:
7980

8081
[![Demo Video](https://img.youtube.com/vi/abYr7B-5vsA/0.jpg)](https://www.youtube.com/watch?v=abYr7B-5vsA)
8182

83+
# Contribute <a id="contributing"></a>
84+
If you are interested in contributing, please take a look at the [CONTRIBUTING](CONTRIBUTING.md) guide.
85+
8286
# Credits <a id="credits"></a>
8387
- [Papa Parse](https://www.papaparse.com/) for its amazing Javascript CSV parser
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2020 Marco Zeuli
3+
* Licensed under MIT license.
4+
* For full license text, see LICENSE file in the repo root or https://opensource.org/licenses/MIT
5+
* If you would like to contribute https://github.com/maaaaarco/spaghetti-cmd-loader
6+
*/
7+
8+
/**
9+
* ConnectApi methods are not supported in data siloed tests.
10+
* This Delegate allows for testing without using the SeeAllData=true
11+
*/
12+
public inherited sharing class CMDConnectApiDelegate {
13+
/**
14+
* Creates new FeedItem
15+
* @return Created FeedItem
16+
*/
17+
public ConnectApi.FeedElement postFeedElement(
18+
Id networkId,
19+
ConnectApi.FeedItemInput feed
20+
) {
21+
return ConnectApi.ChatterFeeds.postFeedElement(networkId, feed);
22+
}
23+
24+
/**
25+
* Retrieves FeedItem records created in the current day
26+
* @param parentId Parent Id of FeedItem records
27+
* @return A list of FeedItem or an empty list
28+
*/
29+
public List<FeedItem> getTodayFeedItems(Id parentId){
30+
return [
31+
SELECT Body
32+
FROM FeedItem
33+
WHERE ParentId = :UserInfo.getUserId() AND CreatedDate = TODAY
34+
LIMIT 1000
35+
];
36+
}
37+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>50.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@IsTest
2+
private class CMDConnectApiDelegateTest {
3+
@IsTest
4+
static void getTodayFeedItemsReturnsCorrectly() {
5+
List<FeedItem> res = new CMDConnectApiDelegate().getTodayFeedItems(UserInfo.getUserId());
6+
System.assertNotEquals(null, res);
7+
}
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>50.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>48.0</apiVersion>
3+
<apiVersion>50.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>

0 commit comments

Comments
 (0)