Skip to content

Commit

Permalink
feat: switch to sf CLI (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil authored Jun 5, 2023
1 parent 5f2eb6d commit 9261dbb
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 84 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci-pr-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# Install npm dependencies for Prettier and Jest
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
run: HUSKY=0 npm ci

# Lint LWC / Aura
- name: 'Lint Lightning Web Components / Aura Components'
Expand All @@ -62,10 +62,10 @@ jobs:
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install sfdx-cli --location=global
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
sfdx --version
sf --version
# Checkout the source code
- name: 'Checkout source code'
Expand All @@ -75,7 +75,7 @@ jobs:
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: |
echo ${{ secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt
echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}')
if [ $secretFileSize == 1 ]; then
echo "Missing DEVHUB_SFDX_URL secret. Is this workflow running on a fork?";
Expand All @@ -84,27 +84,27 @@ jobs:
# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d

# Create scratch org
- name: 'Create scratch org'
run: sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1 release=Preview
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1 release=Preview

# Deploy source to scratch org
- name: 'Push source to scratch org'
run: sfdx force:source:push
run: sf project deploy start

# Assign permissionset
- name: 'Assign permissionset to default user'
run: sfdx force:user:permset:assign -n Visualforce_to_LWC
run: sf org assign permset -n Visualforce_to_LWC

# Import sample data
- name: 'Import sample data'
run: sfdx force:data:tree:import -p ./data/sample-data-plan.json
run: sf data tree import -p ./data/sample-data-plan.json

# Run Apex tests in scratch org
- name: 'Run Apex tests'
run: sfdx force:apex:test:run -c -r human -d ./tests/apex -w 20
run: sf apex test run -c -r human -d ./tests/apex -w 20

# Upload code coverage data
- name: 'Upload code coverage for Apex to Codecov.io'
Expand All @@ -115,7 +115,7 @@ jobs:
# Housekeeping
- name: 'Delete scratch org'
if: always()
run: sfdx force:org:delete -p -u scratch-org
run: sf org delete scratch -p -o scratch-org

trigger-packaging:
runs-on: trailheadapps-Ubuntu
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# Install npm dependencies for Prettier and Jest
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
run: HUSKY=0 npm ci

# Prettier formatting
- name: 'Code formatting verification with Prettier'
Expand Down Expand Up @@ -114,10 +114,10 @@ jobs:
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install sfdx-cli --location=global
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
sfdx --version
sf --version
# Checkout the source code
- name: 'Checkout source code'
Expand All @@ -127,7 +127,7 @@ jobs:
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: |
echo ${{ secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt
echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}')
if [ $secretFileSize == 1 ]; then
echo "Missing DEVHUB_SFDX_URL secret. Is this workflow running on a fork?";
Expand All @@ -136,27 +136,27 @@ jobs:
# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d

# Create scratch org
- name: 'Create scratch org'
run: sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1

# Deploy source to scratch org
- name: 'Push source to scratch org'
run: sfdx force:source:push
run: sf project deploy start

# Assign permissionset
- name: 'Assign permissionset to default user'
run: sfdx force:user:permset:assign -n Visualforce_to_LWC
run: sf org assign permset -n Visualforce_to_LWC

# Import sample data
- name: 'Import sample data'
run: sfdx force:data:tree:import -p ./data/sample-data-plan.json
run: sf data tree import -p ./data/sample-data-plan.json

# Run Apex tests in scratch org
- name: 'Run Apex tests'
run: sfdx force:apex:test:run -c -r human -d ./tests/apex -w 20
run: sf apex test run -c -r human -d ./tests/apex -w 20

# Upload code coverage data
- name: 'Upload code coverage for Apex to Codecov.io'
Expand All @@ -167,7 +167,7 @@ jobs:
# Housekeeping
- name: 'Delete scratch org'
if: always()
run: sfdx force:org:delete -p -u scratch-org
run: sf org delete scratch -p -o scratch-org

trigger-packaging:
runs-on: trailheadapps-Ubuntu
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# Install npm dependencies for Prettier and Jest
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
run: HUSKY=0 npm ci

# Prettier formatting
- name: 'Code formatting verification with Prettier'
Expand Down Expand Up @@ -66,10 +66,10 @@ jobs:
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install sfdx-cli --location=global
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
sfdx --version
sf --version
# Checkout the source code
- name: 'Checkout source code'
Expand All @@ -79,7 +79,7 @@ jobs:
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: |
echo ${{ secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt
echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}')
if [ $secretFileSize == 1 ]; then
echo "Missing DEVHUB_SFDX_URL secret. Is this workflow running on a fork?";
Expand All @@ -88,27 +88,27 @@ jobs:
# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d

# Create scratch org
- name: 'Create scratch org'
run: sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1

# Deploy source to scratch org
- name: 'Push source to scratch org'
run: sfdx force:source:push
run: sf project deploy start

# Assign permissionset
- name: 'Assign permissionset to default user'
run: sfdx force:user:permset:assign -n Visualforce_to_LWC
run: sf org assign permset -n Visualforce_to_LWC

# Import sample data
- name: 'Import sample data'
run: sfdx force:data:tree:import -p ./data/sample-data-plan.json
run: sf data tree import -p ./data/sample-data-plan.json

# Run Apex tests in scratch org
- name: 'Run Apex tests'
run: sfdx force:apex:test:run -c -r human -d ./tests/apex -w 20
run: sf apex test run -c -r human -d ./tests/apex -w 20

# Upload code coverage data
- name: 'Upload code coverage for Apex to Codecov.io'
Expand All @@ -119,7 +119,7 @@ jobs:
# Housekeeping
- name: 'Delete scratch org'
if: always()
run: sfdx force:org:delete -p -u scratch-org
run: sf org delete scratch -p -o scratch-org

trigger-packaging:
runs-on: trailheadapps-Ubuntu
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/packaging-pr-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install sfdx-cli --location=global
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
sfdx --version
sf --version
# Checkout the source code
- name: 'Checkout source code'
Expand All @@ -27,7 +27,7 @@ jobs:
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: |
echo ${{ secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt
echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}')
if [ $secretFileSize == 1 ]; then
echo "Missing DEVHUB_SFDX_URL secret. Is this workflow running on a fork?";
Expand All @@ -36,7 +36,7 @@ jobs:
# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d

# Remove auth file
- name: 'Remove auth file'
Expand All @@ -47,14 +47,14 @@ jobs:
id: createPackageVersion
run: |
set +e
json=$(sfdx force:package:version:create -p vf2lwc -x -w 20 -f config/project-scratch-def.json --json)
json=$(sf package version create -p vf2lwc -x -w 20 -f config/project-scratch-def.json --json)
echo $json
status=$(echo $json | jq '.status')
if [ $status == "0" ]; then
packageVersionId=$(echo $json | jq -r '.result.SubscriberPackageVersionId')
echo "packageVersionId=$packageVersionId" >> $GITHUB_OUTPUT
else
echo "sfdx force:package:version:create failed"
echo "Failed to create package version"
fi
exit $status
Expand All @@ -66,13 +66,13 @@ jobs:

# Create scratch org
- name: 'Create scratch org'
run: sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1 release=Preview
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1 release=Preview

# Install new package in scratch org
- name: 'Install new package version in scratch org'
run: sfdx force:package:install -p ${{ steps.createPackageVersion.outputs.packageVersionId }} -w 10 -u scratch-org -r
run: sf package install -p ${{ steps.createPackageVersion.outputs.packageVersionId }} -w 10 -o scratch-org -r

# Housekeeping
- name: 'Delete scratch org'
if: always()
run: sfdx force:org:delete -p -u scratch-org
run: sf org delete scratch -p -o scratch-org
18 changes: 9 additions & 9 deletions .github/workflows/packaging-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
npm install sfdx-cli --location=global
npm install @salesforce/cli --location=global
nodeInstallPath=$(npm config get prefix)
echo "$nodeInstallPath/bin" >> $GITHUB_PATH
sfdx --version
sf --version
# Checkout the source code
- name: 'Checkout source code'
Expand All @@ -27,7 +27,7 @@ jobs:
- name: 'Populate auth file with DEVHUB_SFDX_URL secret'
shell: bash
run: |
echo ${{ secrets.DEVHUB_SFDX_URL}} > ./DEVHUB_SFDX_URL.txt
echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}')
if [ $secretFileSize == 1 ]; then
echo "Missing DEVHUB_SFDX_URL secret. Is this workflow running on a fork?";
Expand All @@ -36,7 +36,7 @@ jobs:
# Authenticate dev hub
- name: 'Authenticate Dev Hub'
run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d
run: sf org login sfdx-url -f ./DEVHUB_SFDX_URL.txt -a devhub -d

# Remove auth file
- name: 'Remove auth file'
Expand All @@ -47,14 +47,14 @@ jobs:
id: createPackageVersion
run: |
set +e
json=$(sfdx force:package:version:create -p vf2lwc -x -w 20 -f config/project-scratch-def.json --json)
json=$(sf package version create -p vf2lwc -x -w 20 -f config/project-scratch-def.json --json)
echo $json
status=$(echo $json | jq '.status')
if [ $status == "0" ]; then
packageVersionId=$(echo $json | jq -r '.result.SubscriberPackageVersionId')
echo "packageVersionId=$packageVersionId" >> $GITHUB_OUTPUT
else
echo "sfdx force:package:version:create failed"
echo "Failed to create package version"
fi
exit $status
Expand All @@ -66,13 +66,13 @@ jobs:

# Create scratch org
- name: 'Create scratch org'
run: sfdx force:org:create -f config/project-scratch-def.json -a scratch-org -s -d 1
run: sf org create scratch -f config/project-scratch-def.json -a scratch-org -d -y 1

# Install new package in scratch org
- name: 'Install new package version in scratch org'
run: sfdx force:package:install -p ${{ steps.createPackageVersion.outputs.packageVersionId }} -w 10 -u scratch-org -r
run: sf package install -p ${{ steps.createPackageVersion.outputs.packageVersionId }} -w 10 -o scratch-org -r

# Housekeeping
- name: 'Delete scratch org'
if: always()
run: sfdx force:org:delete -p -u scratch-org
run: sf org delete scratch -p -o scratch-org
Loading

0 comments on commit 9261dbb

Please sign in to comment.