Skip to content

Commit

Permalink
Merge pull request #1 from Kevmo92/testing
Browse files Browse the repository at this point in the history
fix: testing
  • Loading branch information
Kevmo92 authored Dec 16, 2024
2 parents 666ebf5 + 35e8162 commit d2b651f
Show file tree
Hide file tree
Showing 23 changed files with 3,265 additions and 0 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/demo-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Demo CI Build

on:
pull_request:
branches:
- main

jobs:
CI-build-and-test:
runs-on: ubuntu-latest
steps:
- name: 🗃️ Checkout Repo 🗃️
uses: actions/checkout@v4

- name: 📦 Setup Node 📦
uses: actions/setup-node@v4
with:
node-version: "22"

- name: 📦 npm i 📦
shell: bash
run: npm i

- name: 📦 Setup Salesforce CLI 📦
shell: bash
run: npm i -g @salesforce/cli

- name: 📦 Create a 2gp Package Version 📦
id: create-package
shell: bash
run: |
echo "$DEVHUB_AUTH_URL" >auth_with_quotes.key
tr -d '\"' <auth_with_quotes.key >auth.key
sf org login sfdx-url -f auth.key -d
rm auth_with_quotes.key auth.key
sf package version create --json --skip-ancestor-check --version-number 0.1.0.NEXT --definition-file config/project-scratch-def.json --package KevmoDemo --installation-key-bypass --code-coverage --version-name "ver 0.1.0" | jq '.result' >package_version_report.json
job_id=$(jq -r '.Id' package_version_report.json)
while [[ "$job_status" != "Success" ]]; do
echo "⏱️ Waiting 15 seconds for job-status update from Salesforce. Plz hold 🎶"
sleep 15
sf package version create report --package-create-request-id "$job_id" --json > package_status_report.json
job_status=$(jq -r '.result[].Status' package_status_report.json)
if [[ "$job_status" = "Success" ]]; then
echo "✅ The job status is: $job_status"
elif [[ "$job_status" = "Error" ]]; then
echo "::error title='🚨 Package version create failed. 🥔'::$(sf package version create report --package-create-request-id "$job_id" --json)"
exit 1
else
echo "📞 The job-status is: $job_status"
fi
done
package_version_id=$(sf package version create report --package-create-request-id $job_id --json | jq -r '.result[].SubscriberPackageVersionId')
echo "version-id=$package_version_id" >> $GITHUB_OUTPUT
env:
DEVHUB_AUTH_URL: ${{ secrets.DEVHUB_AUTH_URL }}

- name: 🚀 Setup Scratch Org 🚀
id: setup-org
shell: bash
run: |
sf org create scratch -f config/project-scratch-def.json -y 1 -d -m
auth_url=$(sf org display --json --verbose | jq -r '.result.sfdxAuthUrl')
echo "auth-url=$auth_url" >> $GITHUB_OUTPUT
- name: Install Package Version to Scratch org
shell: bash
run: |
echo "$AUTH_URL" >auth_with_quotes.key
tr -d '\"' <auth_with_quotes.key >auth.key
sf auth sfdxurl store --sfdx-url-file auth.key --set-default
rm auth_with_quotes.key
sf org display --json | jq -r '.result' >org_info.json
export SF_USERNAME=$(jq -r '.username' org_info.json)
rm org_info.json
./scripts/installPackageSfCore.cjs
env:
AUTH_URL: ${{ steps.setup-org.outputs.auth-url }}
PACKAGE_VERSION_ID: ${{ steps.create-package.outputs.version-id }}

# - name: Install Package Version to Scratch org
# shell: bash
# run: |
# echo "$AUTH_URL" >auth_with_quotes.key
# tr -d '\"' <auth_with_quotes.key >auth.key
# sf auth sfdxurl store --sfdx-url-file auth.key --set-default
# rm auth_with_quotes.key

# sf org display --json | jq -r '.result' >org_info.json
# export SF_ACCESS_TOKEN=$(jq -r '.accessToken' org_info.json)
# export SF_INSTANCE_URL=$(jq -r '.instanceUrl' org_info.json)
# rm org_info.json

# node scripts/installPackageJsForce.js
# env:
# AUTH_URL: ${{ steps.setup-org.outputs.auth-url }}
# PACKAGE_VERSION_ID: ${{ steps.create-package.outputs.version-id }}

- name: 🧪 Force Apex Tests 🧪
shell: bash
run: |
sf project deploy start -d src/testSuites -w 120
sf apex run test --json --result-format tap -s AllTests -w 10
- name: Cleanup Scratch Org
shell: bash
if: always()
run: sf org delete scratch -p
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.sf
.sfdx
20 changes: 20 additions & 0 deletions config/project-scratch-def.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"country": "US",
"edition": "Partner Developer",
"features": [],
"hasSampleData": false,
"language": "English",
"orgName": "kevmo-demo",
"settings": {
"apexSettings": {
"enableAggregateCodeCoverageOnly": true,
"enableCompileOnDeploy": false
},
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"userManagementSettings": {
"permsetsInFieldCreation": true
}
}
}
Loading

0 comments on commit d2b651f

Please sign in to comment.