forked from apex-enterprise-patterns/fflib-apex-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/include-mocks-and-ext' into feature/ortoo
- Loading branch information
Showing
5 changed files
with
187 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Deploy and Run all Unit Tests | ||
on: | ||
push: | ||
branches: | ||
- '**/*' | ||
- main | ||
pull_request: | ||
types: [ opened ] | ||
branches: | ||
- '**/*' | ||
- main | ||
jobs: | ||
create-org-and-deploy: | ||
runs-on: ubuntu-latest | ||
env: | ||
DEVHUB_ORG_ALIAS: OrtooISV | ||
ORG_ALIAS_PREFIX: 'FFLIB' | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Salesforce SFDX CLI Action | ||
uses: sfdx-actions/setup-sfdx@v1 | ||
|
||
# Update ./config/project-scratch-def.json | ||
|
||
- name: Update project-scratch-def.json orgName | ||
uses: jossef/action-set-json-field@6e6d7e639f24b3955ef682815317b5613ac6ca12 | ||
with: | ||
file: ./config/project-scratch-def.json | ||
field: orgName | ||
value: "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" | ||
|
||
- name: Update project-scratch-def.json description | ||
uses: jossef/action-set-json-field@6e6d7e639f24b3955ef682815317b5613ac6ca12 | ||
with: | ||
file: ./config/project-scratch-def.json | ||
field: description | ||
value: "${{ github.repository }} , Org Alias ${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}. Created by ${{ github.actor }}" | ||
|
||
- name: Show project-scratch-def.json | ||
run: 'cat ./config/project-scratch-def.json' | ||
|
||
# sfdx-project.json file should be ok as is | ||
|
||
- name: Show sfdx-project.json | ||
run: 'cat ./sfdx-project.json' | ||
|
||
# Dev Hub needed to create scratch org | ||
|
||
- name: Create DevHub Auth File | ||
run: echo "${{ secrets.AUTH_SECRET_ISV }}" > devhub_auth_file.txt | ||
|
||
- name: Authorise Dev Hub Org | ||
run: sfdx auth:sfdxurl:store -f devhub_auth_file.txt -d -a ${{ env.DEVHUB_ORG_ALIAS }} | ||
|
||
# Create Scratch Org | ||
|
||
- name: Run script CreateScratchOrgWithNamespaceOnlyHeadless.sh | ||
run: ./scripts/std_batch/CreateScratchOrgWithNamespaceOnlyHeadless.sh "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" | ||
shell: sh | ||
|
||
# Push code to org | ||
|
||
- name: Deploy FFLIB to Org | ||
run: sfdx force:source:deploy -p sfdx-source --targetusername "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" | ||
|
||
# Run Apex Unit Tests | ||
|
||
- name: Run All Unit Tests | ||
run: ./scripts/std_batch/RunApexUnitTests.sh "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" | ||
shell: bash | ||
|
||
# Get Apex Code Coverage Numbers | ||
|
||
- name: Get Apex Code Coverage | ||
run: ./scripts/std_batch/GetApexCodeCoverage.sh "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" | ||
shell: sh | ||
|
||
# Delete Scratch Org | ||
|
||
- name: Delete Scratch Org | ||
if: ${{ always() }} | ||
run: sfdx force:org:delete --noprompt --targetusername "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" |
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
scripts/std_batch/CreateScratchOrgWithNamespaceOnlyHeadless.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
|
||
# chmod u+x CreateScratchOrgWithNamespaceOnlyHeadless.sh | ||
# run in Terminal window of SFDX project with ./scripts/std_batch/CreateScratchOrgWithNamespaceOnlyHeadless.sh OrtooQassignScratch | ||
|
||
# CREATE SCRATCH ORG WITH NAMESPACE AND GENERATE PASSWORD | ||
# | ||
echo "Scratch Org Creation With Namespace ONLY (no data loaded) started." | ||
|
||
ORG_ALIAS="OrtooQassignScratch" | ||
|
||
if [ $# = 1 ]; then | ||
ORG_ALIAS=$1 | ||
else | ||
echo | ||
echo "Script requires one parameter" | ||
echo "1. Org Alias for created org. e.g. OrtooQassignScratch" | ||
echo | ||
echo "**** Remember to update config/project-scratch-def.json file as appropriate." | ||
echo " Include your public facing IP Address to prevent two-factor authentication." | ||
echo " Update Business Hours if necessary." | ||
echo | ||
echo "**** Remember to update sfdx-project.json file with Namespace to be used." | ||
echo | ||
exit 1 | ||
fi | ||
|
||
echo | ||
echo "Using $ORG_ALIAS for Org alias" | ||
echo | ||
|
||
echo "1. create" | ||
sfdx force:org:create -f config/project-scratch-def.json --setalias "$ORG_ALIAS" --durationdays 3 --setdefaultusername --loglevel fatal | ||
if [ $? = 0 ]; then | ||
echo "Created Scratch Org with alias $ORG_ALIAS" | ||
else | ||
echo | ||
echo "Non zero exit code: $?" | ||
echo "Exiting script" | ||
exit 1 | ||
fi | ||
|
||
echo "2. password generation" | ||
sfdx force:user:password:generate -u "$ORG_ALIAS" | ||
if [ $? = 0 ]; then | ||
echo "Password generated" | ||
else | ||
echo | ||
echo "Non zero exit code: $?" | ||
echo "Exiting script" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
echo "3. display Org details" | ||
sfdx force:org:display -u "$ORG_ALIAS" | ||
if [ $? = 0 ]; then | ||
echo "Org details displayed" | ||
else | ||
echo | ||
echo "Non zero exit code: $?" | ||
echo "Exiting script" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
echo | ||
echo "Scratch Org Creation With Namespace ONLY completed." | ||
echo | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ORG_ALIAS="OrtooQassignScratch" | ||
|
||
if [ $# = 1 ]; then | ||
ORG_ALIAS=$1 | ||
else | ||
echo | ||
echo "Script requires one parameter" | ||
echo "1. Org Alias for created org. e.g. OrtooQassignScratch" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
sfdx force:data:soql:query -u "$ORG_ALIAS" -t -q "SELECT SUM(NumLinesUncovered), SUM(NumLinesCovered) FROM ApexCodeCoverageAggregate" | grep -o -E '[0-9]+' | xargs | while read -r uncovered covered remainder ; do | ||
totallines=$(expr $covered + $uncovered) | ||
coveredtimeshundred=$(expr $covered \* 100) | ||
percentage=$(expr $coveredtimeshundred / $totallines) | ||
echo "Uncovered: $uncovered, Covered: $covered, Percentage: $percentage%" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
ORG_ALIAS="OrtooQassignScratch" | ||
|
||
if [ $# = 1 ]; then | ||
ORG_ALIAS=$1 | ||
else | ||
echo | ||
echo "Script requires one parameter" | ||
echo "1. Org Alias for created org. e.g. OrtooQassignScratch" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
( set -o pipefail; SFDX_IMPROVED_CODE_COVERAGE='true' SFDX_MAX_QUERY_LIMIT=200000 sfdx force:apex:test:run -u "$ORG_ALIAS" -r human --codecoverage --wait 30 | grep -v ' Pass ' | grep -v '^[a-zA-Z0-9]\{18\}\s\s' | grep -v 'UNCOVERED' | grep -v 'Apex Code Coverage' | grep -v ' ─────── ───────────────' | grep -v '─────────────────────────────────────────────────────────────────────────────────────────────────────────────' ) |