Skip to content

Commit

Permalink
Setup Scratch org in v60
Browse files Browse the repository at this point in the history
rsoesemann committed Feb 14, 2024
1 parent c1d79e9 commit 2a3fda4
Showing 4 changed files with 23 additions and 26 deletions.
5 changes: 2 additions & 3 deletions force-app/main/default/classes/AddErrorInsights_Test.cls
Original file line number Diff line number Diff line change
@@ -11,9 +11,8 @@ private class AddErrorInsights_Test {

Test.startTest();
new HttpMock()
.post('/v1/completions',
new OpenAiCompletions.Response()
.withChoice('Check the Power cord'), 200)
.post('/v1/chat/completions',
new OpenAiCompletions.Response().withChoice('Check the Power cord'), 200)
.mock();


4 changes: 4 additions & 0 deletions force-app/main/default/classes/OpenAiCompletions.cls
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ public with sharing class OpenAiCompletions {
choices.add(choice);
return this;
}

public Response withChoice(String message) {
return withChoice(new Message().content(message));
}
}


38 changes: 16 additions & 22 deletions scripts/createScratchOrg.sh
Original file line number Diff line number Diff line change
@@ -5,42 +5,36 @@ execute() {
$@ || exit
}

if [ -z "$secrets.DEV_HUB_URL" ]; then
if [ -z "$DEV_HUB_URL" ]; then
echo "set default devhub user"
execute sfdx force:config:set defaultdevhubusername=$DEV_HUB_ALIAS
fi
execute sf config set defaultdevhubusername=$DEV_HUB_ALIAS

echo "Deleting old scratch org"
sfdx force:org:delete -p -u $SCRATCH_ORG_ALIAS
echo "Deleting old scratch org"
sf force org delete --no-prompt --target-org $SCRATCH_ORG_ALIAS
fi

echo "Creating scratch ORG"
execute sfdx force:org:create -a $SCRATCH_ORG_ALIAS -s -f ./config/scratch-org-def.json -d 7
echo "Creating scratch org"
execute sf force org create --setalias $SCRATCH_ORG_ALIAS --setdefaultusername --definitionfile ./config/scratch-org-def.json --durationdays 30

echo "Install dependencies"
execute sfdx force:package:install --package 04t30000001DWL0AAO --publishwait 5 --wait 10 -u $SCRATCH_ORG_ALIAS
#IsvConsole execute sfdx force:package:install --package 04t5w000005hh7fAAA --publishwait 5 --wait 10 -u $SCRATCH_ORG_ALIAS
#Fmaexecute sfdx force:package:install --package 04t3h000004m8DkAAI --publishwait 5 --wait 10 -u $SCRATCH_ORG_ALIAS

echo "Pushing changes to scratch org"
execute sfdx force:source:push
execute sf force source push
# Will fail as your first have to go into the Org, turn Slack on and turn Slack for Apex on.

echo "Assigning permission"
execute sfdx force:user:permset:assign -n Admin
echo "Assigning permissions"
execute sf force user permset assign --perm-set-name Admin

echo "Make sure Org user is english"
sfdx force:data:record:update -s User -w "Name='User User'" -v "Languagelocalekey=en_US"
sf data update record --sobject User --where "Name='User User'" --values "Languagelocalekey=en_US"

echo "Create sample data"
execute sfdx force:apex:execute -f scripts/createSampleData.apex

echo "Running Apex Tests"
execute sfdx force:apex:test:run -l RunLocalTests -w 30 -c -r human

echo "Running CLI Scanner"
execute sfdx scanner:run --target "force-app" --pmdconfig "ruleset.xml"
execute sf apex run test --test-level RunLocalTests --wait 30 --code-coverage --result-format human

if [ -f "package.json" ]; then
echo "Running jest tests"
execute npm install
execute npm run test:unit
fi
echo "Running Salesforce Code Analyser"
sfdx scanner:run --format table --target force-app --engine "pmd" --pmdconfig "ruleset.xml"
sfdx scanner:run:dfa --format table --target force-app --projectdir force-app
2 changes: 1 addition & 1 deletion sfdx-project.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "56.0",
"sourceApiVersion": "60.0",
"packageAliases": {
"isv-cockpit": "0Ho1R000000GmaiSAC",
"lma": "04t30000001DWL0AAO",

0 comments on commit 2a3fda4

Please sign in to comment.