From 202d10a068e6436bb0cd828185e84044880e19c7 Mon Sep 17 00:00:00 2001 From: Lincoln Rychecky Date: Wed, 21 Aug 2024 14:33:02 -0600 Subject: [PATCH 1/4] update actions --- .github/workflows/apex-tests-pr.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/apex-tests-pr.yml b/.github/workflows/apex-tests-pr.yml index 8533bbf..7261ab1 100644 --- a/.github/workflows/apex-tests-pr.yml +++ b/.github/workflows/apex-tests-pr.yml @@ -11,10 +11,6 @@ on: jobs: build: runs-on: ubuntu-latest - - uses: actions/setup-node@v1 - with: - node-version: '21.x' - steps: - name: Checkout repository uses: actions/checkout@v2 From 64404815a2a3442717512a4ef5053692770c465d Mon Sep 17 00:00:00 2001 From: Lincoln Rychecky Date: Wed, 21 Aug 2024 14:38:22 -0600 Subject: [PATCH 2/4] reformat --- .github/workflows/apex-tests-pr.yml | 67 +++++++++++++++-------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/.github/workflows/apex-tests-pr.yml b/.github/workflows/apex-tests-pr.yml index 7261ab1..ad628ed 100644 --- a/.github/workflows/apex-tests-pr.yml +++ b/.github/workflows/apex-tests-pr.yml @@ -4,42 +4,43 @@ on: workflow_dispatch: inputs: branch: - description: 'Branch to run the tests on' + description: "Branch to run the tests on" required: true - default: 'main' + default: "main" jobs: build: runs-on: ubuntu-latest + steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Salesforce CLI - run: | - npm install sfdx-cli - node_modules/sfdx-cli/bin/run --version - node_modules/sfdx-cli/bin/run plugins --core - - # Store Secret for debhub - - name: Populate auth file with DEVHUB_SFDX_URL secrets - shell: bash - run: | - echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt - secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}') - if [ $secretFileSize == 1 ]; then - echo "DEVHUB_SFDX_URL secret is empty or not set. Is this workflow running on a fork? Exiting..."; - exit 1; - fi - - - name: Authenticate to Dev Hub - run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d - - - name: Create Scratch Org - run: sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratchOrg - - - name: Push Source to Scratch Org - run: sfdx force:source:push -u MyScratchOrg - - - name: Run Apex Tests - run: sfdx force:apex:test:run -u MyScratchOrg --wait 10 --resultformat human --codecoverage \ No newline at end of file + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Salesforce CLI + run: | + npm install sfdx-cli + node_modules/sfdx-cli/bin/run --version + node_modules/sfdx-cli/bin/run plugins --core + + # Store Secret for debhub + - name: Populate auth file with DEVHUB_SFDX_URL secrets + shell: bash + run: | + echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt + secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}') + if [ $secretFileSize == 1 ]; then + echo "DEVHUB_SFDX_URL secret is empty or not set. Is this workflow running on a fork? Exiting..."; + exit 1; + fi + + - name: Authenticate to Dev Hub + run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d + + - name: Create Scratch Org + run: sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratchOrg + + - name: Push Source to Scratch Org + run: sfdx force:source:push -u MyScratchOrg + + - name: Run Apex Tests + run: sfdx force:apex:test:run -u MyScratchOrg --wait 10 --resultformat human --codecoverage From 2c8325a12fe21769950df6cecac2bf0df1bd767d Mon Sep 17 00:00:00 2001 From: Lincoln Rychecky Date: Wed, 21 Aug 2024 14:39:01 -0600 Subject: [PATCH 3/4] reformat --- .github/workflows/apex-tests-pr.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/apex-tests-pr.yml b/.github/workflows/apex-tests-pr.yml index ad628ed..a110a2d 100644 --- a/.github/workflows/apex-tests-pr.yml +++ b/.github/workflows/apex-tests-pr.yml @@ -16,12 +16,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Install Salesforce CLI - run: | - npm install sfdx-cli - node_modules/sfdx-cli/bin/run --version - node_modules/sfdx-cli/bin/run plugins --core - # Store Secret for debhub - name: Populate auth file with DEVHUB_SFDX_URL secrets shell: bash From b60937cad9b52e30a44a74ed8730ee343dc516b7 Mon Sep 17 00:00:00 2001 From: Lincoln Rychecky Date: Wed, 21 Aug 2024 14:40:14 -0600 Subject: [PATCH 4/4] update --- .github/workflows/apex-tests-pr.yml | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/apex-tests-pr.yml b/.github/workflows/apex-tests-pr.yml index a110a2d..1c8d39f 100644 --- a/.github/workflows/apex-tests-pr.yml +++ b/.github/workflows/apex-tests-pr.yml @@ -1,12 +1,12 @@ name: Salesforce CI on: - workflow_dispatch: - inputs: - branch: - description: "Branch to run the tests on" - required: true - default: "main" + push: + branches: + - main + pull_request: + branches: + - main jobs: build: @@ -16,19 +16,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - # Store Secret for debhub - - name: Populate auth file with DEVHUB_SFDX_URL secrets - shell: bash - run: | - echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt - secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}') - if [ $secretFileSize == 1 ]; then - echo "DEVHUB_SFDX_URL secret is empty or not set. Is this workflow running on a fork? Exiting..."; - exit 1; - fi + - name: Install Salesforce CLI + uses: forcedotcom/sfdx-action@v1 + with: + version: latest - name: Authenticate to Dev Hub - run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d + run: sfdx auth:jwt:grant --clientid ${{ secrets.SF_CLIENT_ID }} --jwtkeyfile assets/server.key --username ${{ secrets.SF_DEV_HUB_USERNAME }} --instanceurl https://login.salesforce.com --setdefaultdevhubusername - name: Create Scratch Org run: sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratchOrg