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.
Fixed issue with test in a non-namespaced environment Added a namespace, because the framework will always have one
- Loading branch information
1 parent
8109082
commit 8654fd2
Showing
7 changed files
with
170 additions
and
6 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,76 @@ | ||
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: 'FTST' | ||
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 force-app to Org | ||
run: sfdx force:source:deploy -p force-app --targetusername "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" | ||
|
||
# Run All Unit Tests | ||
|
||
- name: Run All Unit Tests | ||
run: sfdx force:apex:test:run -r human -u "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" --wait 20 --codecoverage | ||
|
||
# Delete Scratch Org | ||
|
||
- name: Delete Scratch Org | ||
run: sfdx force:org:delete --noprompt --targetusername "${{env.ORG_ALIAS_PREFIX}}${{github.run_number}}" |
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 |
---|---|---|
|
@@ -37,4 +37,5 @@ ehthumbs.db | |
$RECYCLE.BIN/ | ||
|
||
# Local environment variables | ||
.env | ||
.env | ||
.pmdCache |
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
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
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 30 --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