Improved Testability of Queries #950
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
# Pipeline for Nebula Logger | |
name: Build | |
env: | |
CLR_ICU_VERSION_OVERRIDE: 50.2 | |
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: true | |
SF_DISABLE_AUTOUPDATE: true | |
SF_LOG_LEVEL: debug | |
SF_SKIP_NEW_VERSION_CHECK: true | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- .github/workflows/** | |
- config/scratch-orgs/** | |
- nebula-logger/** | |
- sfdx-project.json | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
- .github/workflows/** | |
- config/scratch-orgs/** | |
- nebula-logger/** | |
- sfdx-project.json | |
jobs: | |
code-quality-tests: | |
name: 'Run Code Quality Tests' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Check for changes in core directory' | |
uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
core: | |
- './nebula-logger/core/**' | |
- name: 'Authorize Dev Hub' | |
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.draft == false) && (steps.changes.outputs.core == 'true') }} | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Verify package version number is updated' | |
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.draft == false) && (steps.changes.outputs.core == 'true') }} | |
run: npm run package:version:number:verify | |
- name: 'Verify LWC with ESLint' | |
run: npm run scan:lwc | |
- name: 'Verify Apex with SFDX Scanner' | |
run: | | |
npm run sf:plugins:link:scanner | |
npm run scan:apex | |
# TODO - uncomment - temporarily commented-out due to an issue with apexdocs in the pipeline | |
# - name: 'Verify docs are updated' | |
# run: npm run docs:verify | |
- name: 'Verify formatting with Prettier' | |
run: npm run prettier:verify | |
lwc-jest-tests: | |
name: 'Run LWC Jest Tests' | |
needs: [code-quality-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Run LWC Tests' | |
run: npm run test:lwc | |
- name: 'Upload LWC code coverage to Codecov.io' | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
flags: LWC | |
token: ${{ secrets.CODECOV_TOKEN }} | |
advanced-scratch-org-tests: | |
environment: 'Advanced Scratch Org' | |
name: 'Run Advanced Scratch Org Tests' | |
needs: [code-quality-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/advanced-scratch-def.json --wait 20 --set-default --json | |
# https://help.salesforce.com/s/articleView?id=000394906&type=1 | |
- name: 'Install OmniStudio managed package v250.7.1 (Summer ‘24 release)' | |
run: npx sf package install --package 04t4W000002Z6oC --security-type AdminsOnly --wait 30 --no-prompt | |
# To ensure that all of the Apex classes in the core directory have 75+ code coverage, | |
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests` | |
- name: 'Validate Core Source in Scratch Org' | |
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests | |
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata | |
- name: 'Deploy All Source to Scratch Org' | |
run: npx sf project deploy start --source-dir ./nebula-logger/ | |
- name: 'Deploy Test Metadata' | |
run: npx sf project deploy start --source-dir ./config/scratch-orgs/ | |
- name: 'Assign Logger Admin Permission Set' | |
run: npm run permset:assign:admin | |
- name: 'Validate Custom Metadata Records' | |
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex | |
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session. | |
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously. | |
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). | |
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of | |
# integration testing to ensure that everything works with or without an active session. | |
- name: 'Run Apex Tests Asynchronously' | |
run: npm run test:apex:nocoverage | |
- name: 'Run Apex Tests Synchronously' | |
run: npm run test:apex:nocoverage -- --synchronous | |
- name: 'Delete Scratch Org' | |
run: npx sf org delete scratch --no-prompt | |
if: ${{ always() }} | |
base-scratch-org-tests: | |
environment: 'Base Scratch Org' | |
name: 'Run Base Scratch Org Tests' | |
needs: [code-quality-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/base-scratch-def.json --wait 20 --set-default --json | |
# To ensure that all of the Apex classes in the core directory have 75+ code coverage, | |
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests` | |
- name: 'Validate Core Source in Scratch Org' | |
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests | |
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata | |
- name: 'Deploy All Source to Scratch Org' | |
run: npx sf project deploy start --source-dir ./nebula-logger/ | |
- name: 'Assign Logger Admin Permission Set' | |
run: npm run permset:assign:admin | |
- name: 'Validate Custom Metadata Records' | |
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex | |
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session. | |
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously. | |
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). | |
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of | |
# integration testing to ensure that everything works with or without an active session. | |
- name: 'Run Apex Tests Asynchronously' | |
run: npm run test:apex:nocoverage | |
- name: 'Run Apex Tests Synchronously' | |
run: npm run test:apex:nocoverage -- --synchronous | |
- name: 'Delete Scratch Org' | |
run: npx sf org delete scratch --no-prompt | |
if: ${{ always() }} | |
event-monitoring-scratch-org-tests: | |
environment: 'Event Monitoring Scratch Org' | |
name: 'Run Event Monitoring Scratch Org Tests' | |
needs: [code-quality-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/event-monitoring-scratch-def.json --wait 20 --set-default --json | |
# To ensure that all of the Apex classes in the core directory have 75+ code coverage, | |
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests` | |
- name: 'Validate Core Source in Scratch Org' | |
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests | |
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata | |
- name: 'Deploy All Source to Scratch Org' | |
run: npx sf project deploy start --source-dir ./nebula-logger/ | |
- name: 'Assign Logger Admin Permission Set' | |
run: npm run permset:assign:admin | |
- name: 'Validate Custom Metadata Records' | |
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex | |
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session. | |
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously. | |
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). | |
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of | |
# integration testing to ensure that everything works with or without an active session. | |
- name: 'Run Apex Tests Asynchronously' | |
run: npm run test:apex:nocoverage | |
- name: 'Run Apex Tests Synchronously' | |
run: npm run test:apex:nocoverage -- --synchronous | |
- name: 'Delete Scratch Org' | |
run: npx sf org delete scratch --no-prompt | |
if: ${{ always() }} | |
experience-cloud-scratch-org-tests: | |
environment: 'Experience Cloud Scratch Org' | |
name: 'Run Experience Cloud Scratch Org Tests' | |
needs: [code-quality-tests, advanced-scratch-org-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/experience-cloud-scratch-def.json --wait 20 --set-default --json | |
# To ensure that all of the Apex classes in the core directory have 75+ code coverage, | |
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests` | |
- name: 'Validate Core Source in Scratch Org' | |
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests | |
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata | |
- name: 'Deploy All Source to Scratch Org' | |
run: npx sf project deploy start --source-dir ./nebula-logger/ | |
- name: 'Deploy Test Experience Sites Metadata' | |
run: npx sf project deploy start --source-dir ./config/scratch-orgs/experience-cloud/ | |
- name: 'Assign Logger Admin Permission Set' | |
run: npm run permset:assign:admin | |
- name: 'Validate Custom Metadata Records' | |
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex | |
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session. | |
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously. | |
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). | |
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of | |
# integration testing to ensure that everything works with or without an active session. | |
- name: 'Run Apex Tests Asynchronously' | |
run: npm run test:apex:nocoverage | |
- name: 'Run Apex Tests Synchronously' | |
run: npm run test:apex:nocoverage -- --synchronous | |
- name: 'Delete Scratch Org' | |
run: npx sf org delete scratch --no-prompt | |
if: ${{ always() }} | |
omnistudio-scratch-org-tests: | |
environment: 'OmniStudio Scratch Org' | |
name: 'Run OmniStudio Scratch Org Tests' | |
needs: [code-quality-tests, base-scratch-org-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/omnistudio-scratch-def.json --wait 20 --set-default --json | |
# https://help.salesforce.com/s/articleView?id=000394906&type=1 | |
- name: 'Install OmniStudio managed package v250.7.1 (Summer ‘24 release)' | |
run: npx sf package install --package 04t4W000002Z6oC --security-type AdminsOnly --wait 30 --no-prompt | |
# To ensure that all of the Apex classes in the core directory have 75+ code coverage, | |
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests` | |
- name: 'Validate Core Source in Scratch Org' | |
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests | |
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata | |
- name: 'Deploy All Source to Scratch Org' | |
run: npx sf project deploy start --source-dir ./nebula-logger/ | |
- name: 'Deploy Test OmniStudio Metadata' | |
run: npx sf project deploy start --source-dir ./config/scratch-orgs/omnistudio/ | |
- name: 'Assign Logger Admin Permission Set' | |
run: npm run permset:assign:admin | |
- name: 'Validate Custom Metadata Records' | |
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex | |
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session. | |
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously. | |
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). | |
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of | |
# integration testing to ensure that everything works with or without an active session. | |
- name: 'Run Apex Tests Asynchronously' | |
run: npm run test:apex:nocoverage | |
- name: 'Run Apex Tests Synchronously' | |
run: npm run test:apex:nocoverage -- --synchronous | |
- name: 'Delete Base Scratch Org' | |
run: npx sf org delete scratch --no-prompt | |
if: ${{ always() }} | |
platform-cache-scratch-org-tests: | |
environment: 'Platform Cache Scratch Org' | |
name: 'Run Platform Cache Scratch Org Tests' | |
needs: [code-quality-tests, event-monitoring-scratch-org-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --duration-days 1 --definition-file ./config/scratch-orgs/platform-cache-scratch-def.json --wait 20 --set-default --json | |
# To ensure that all of the Apex classes in the core directory have 75+ code coverage, | |
# deploy only the core directory & run all of its tests as part of the deployment, using `--test-level RunLocalTests` | |
- name: 'Validate Core Source in Scratch Org' | |
run: npx sf project deploy validate --concise --source-dir ./nebula-logger/core/ --test-level RunLocalTests | |
# Now that the core directory has been deployed & tests have passed, deploy all of the metadata | |
- name: 'Deploy All Source to Scratch Org' | |
run: npx sf project deploy start --source-dir ./nebula-logger/ | |
- name: 'Assign Logger Admin Permission Set' | |
run: npm run permset:assign:admin | |
- name: 'Validate Custom Metadata Records' | |
run: npx sf apex run --file ./scripts/build/validate-custom-metadata-records.apex | |
# Nebula Logger has functionality that queries the AuthSession object when the current user has an active session. | |
# The code should work with or without an active session, so the pipeline runs the tests twice - asynchronously and synchronously. | |
# This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). | |
# This data is also mocked during tests, but running the Apex tests sync & async serves within the pipeline acts as an extra level of | |
# integration testing to ensure that everything works with or without an active session. | |
- name: 'Run Apex Tests Asynchronously' | |
run: npm run test:apex:nocoverage | |
- name: 'Run Apex Tests Synchronously' | |
run: npm run test:apex:nocoverage -- --synchronous | |
- name: 'Delete Scratch Org' | |
run: npx sf org delete scratch --no-prompt | |
if: ${{ always() }} | |
create-managed-package-beta: | |
if: ${{ github.ref != 'refs/heads/main' }} | |
environment: 'Base Scratch Org' | |
name: 'Create Managed Package Beta' | |
needs: | |
[ | |
code-quality-tests, | |
lwc-jest-tests, | |
advanced-scratch-org-tests, | |
base-scratch-org-tests, | |
event-monitoring-scratch-org-tests, | |
experience-cloud-scratch-org-tests, | |
omnistudio-scratch-org-tests, | |
platform-cache-scratch-org-tests | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Beta Managed Package Version' | |
run: npm run package:version:create:managed | |
create-unlocked-package-release-candidate: | |
if: ${{ github.ref != 'refs/heads/main' }} | |
environment: 'Base Scratch Org' | |
name: 'Create Core Package Release Candidate' | |
needs: [create-managed-package-beta] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Create Scratch Org' | |
run: npx sf org create scratch --no-namespace --no-track-source --alias base_package_subscriber_scratch_org --duration-days 1 --definition-file ./config/scratch-orgs/base-scratch-def.json --wait 20 --set-default --json | |
- name: 'Create & Install Package Version' | |
run: npx pwsh ./scripts/build/create-and-install-package-version.ps1 -targetpackagealias '"Nebula Logger - Core"' -targetreadme ./README.md -targetusername base_package_subscriber_scratch_org | |
# This is the only place in Nebula Logger's pipeline where the `LoggerCore` test suite runs & the results are sent to Codecov.io. | |
# This is specifically done in the base scratch org, using only the `LoggerCore test` suite, in order to help validate that the core metadata | |
# provides sufficient code coverage for teams that deploy Nebula Logger's metadata directly to their org, instead of installing one of Nebula Logger's 2GP packages. | |
# 1. Many teams cannot use one of the 2GP packages for various reasons, including company policies, security concerns, etc., | |
# and being able to deploy the core metadata is something that should be supported. | |
# 2. And even though the pipeline runs the `extra-tests` directory to validate logging works correctly in various types of scratch orgs, | |
# for teams that are trying to deploy Nebula Logger's metadata, it's critical that the core tests have sufficient code coverage to be deployed to a prod org. | |
# - In the past, this has not always been the case, resulting in some teams having deployment issues & project delays due to the low code coverage | |
# that was (formerly) provided by some of the core tests classes. | |
# - In orgs that do not have some optional Salesforce features enabled/available (e.g., orgs without Experience Cloud, OmniStudio, Platform Cache, etc.), | |
# the code coverage can be especially low, so using the base scratch org acts | |
# | |
# So now only the core test suite's results, from a base scratch org, are used for reporting code coverage, even though the project's overall code coverage | |
# is much higher when using the `extra-tests` directory. | |
- name: 'Get Core Test Suite Code Coverage' | |
run: npm run test:apex:suite:core | |
# This is the only scratch org that's used for uploading code coverage | |
- name: 'Upload Apex test code coverage to Codecov.io' | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
flags: Apex | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# The metadata API / sf CLI support deploying metadata using package manifest XML files - see docs for more details: | |
# Docs: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/manifest_samples.htm | |
# _Some_ people (@jongpie) dislike using manifest files, and find them to be unnecessary for most teams/projects/implementations. | |
# | |
# | |
# | |
# But sometimes................. | |
# ........... | |
# .......just............ | |
#.........occassionally......... | |
# ......... | |
#..................ooooooooooooooooccassionally......... | |
# .......................... | |
# ....... every....... | |
# ...................once in a while..... | |
# ........... | |
# ......... | |
# .....somewhere..... | |
# ....................... | |
# ........... | |
# ............. | |
# ................... | |
# ...........there are a few brave individuals.... | |
# ............... | |
# .....tasked with the impossible task.... | |
# ......... | |
# ................ | |
# ......... | |
# ......... | |
# ... Deploy a crazy amount of stuff to production.......... | |
# ................................... | |
# .......all at once....... | |
# ........................... | |
# .................... | |
# ...........WITHOUT............................................ | |
# ................A..................... | |
# ..................PROPER................... | |
# .......................PIPELINE!!!!!!!........?! | |
# ... | |
# ... | |
# ... | |
# 💀💀💀💀😱😱😱😭😭😭😭 | |
# ... | |
# ... | |
# ... | |
# ... | |
# ... | |
# ... | |
# So, let's auto-generate an up-to-date package manifest XML file and store it in the repo, | |
# juuuuuuust in case another fellow Salesforce nerd ever needs them.... | |
# .............. | |
# ................... | |
# ............... | |
# ..... | |
# .........and may the force...... | |
# ........................ | |
# .......be with you.......... | |
# .................... | |
# ..... | |
# ... | |
# TODO Add some extra steps to try to deploy to the scratch org, using the manifest file, to ensure it works | |
- name: 'Generate core package metadata manifest file' | |
run: | | |
npm run package:manifest:generate:core | |
git add ./nebula-logger/core.package.xml | |
git commit -m "Generated updated package.xml manifest file for core unlocked package version" | |
- name: 'Commit New Package Version' | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action Bot" | |
# npm run sf:plugins:link:bummer | |
echo y | npx sf plugins install @jongpie/sfdx-bummer-plugin --force | |
npx sf bummer:package:aliases:sort | |
npx prettier --write ./sfdx-project.json | |
git add ./sfdx-project.json | |
git commit -m "Created new core unlocked package version" | |
git push | |
promote-package-versions: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
name: 'Promote Package Versions' | |
needs: | |
[ | |
code-quality-tests, | |
lwc-jest-tests, | |
advanced-scratch-org-tests, | |
base-scratch-org-tests, | |
event-monitoring-scratch-org-tests, | |
experience-cloud-scratch-org-tests, | |
omnistudio-scratch-org-tests, | |
platform-cache-scratch-org-tests | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout source code' | |
uses: actions/checkout@v4 | |
- name: 'Restore node_modules cache' | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.cache-name }}- | |
npm- | |
- name: 'Install npm dependencies' | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'Authorize Dev Hub' | |
shell: bash | |
run: | | |
npx sf version | |
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | |
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub | |
env: | |
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }} | |
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }} | |
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }} | |
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }} | |
- name: 'Promote package versions' | |
run: npx pwsh ./scripts/build/promote-readme-packages.ps1 |