-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed inaccessible methods in namespaced package (#12)
* Fixed #11 by updating CacheManager.cls to use global on the top-level class, the Cacheable interface, and several public static methods * Added pipeline for GitHub Actions * Added lint-staged.config.js and automated syncing of the version number in several files within the repo/metadata
- Loading branch information
Showing
14 changed files
with
9,694 additions
and
3,012 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
# Pipeline for Nebula Cache Manager | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- 'content/**' | ||
- 'docs/**' | ||
- 'examples/**' | ||
- 'packages/**' | ||
- '.forceignore' | ||
- '.gitignore' | ||
- '.prettierignore' | ||
- '.prettierrc' | ||
- 'CONTRIBUTING.md' | ||
- 'LICENSE' | ||
- 'package.json' | ||
- 'README.md' | ||
- './**/README.md' | ||
- 'sfdx-project.json' | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths-ignore: | ||
- 'content/**' | ||
- 'docs/**' | ||
- 'examples/**' | ||
- 'packages/**' | ||
- '.forceignore' | ||
- '.gitignore' | ||
- '.prettierignore' | ||
- '.prettierrc' | ||
- 'CONTRIBUTING.md' | ||
- 'LICENSE' | ||
- 'package.json' | ||
- 'README.md' | ||
- './**/README.md' | ||
- 'sfdx-project.json' | ||
|
||
jobs: | ||
code-quality-tests: | ||
name: 'Run Code Quality Tests' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout source code' | ||
uses: actions/checkout@v3 | ||
|
||
- name: 'Restore node_modules cache' | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
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: 'Verify Apex with SFDX Scanner' | ||
run: | | ||
npm run sfdx:plugins:link:scanner | ||
npm run scan:apex | ||
- name: 'Verify formatting with Prettier' | ||
run: npm run prettier:verify | ||
|
||
base-scratch-org-tests: | ||
name: 'Run Base Scratch Org Tests' | ||
needs: [code-quality-tests] | ||
runs-on: ubuntu-latest | ||
environment: 'Base Scratch Org' | ||
steps: | ||
- name: 'Checkout source code' | ||
uses: actions/checkout@v3 | ||
|
||
- name: 'Restore node_modules cache' | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
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: | | ||
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | ||
npx sfdx force:auth:jwt:grant --instanceurl ${{ env.DEV_HUB_AUTH_URL }} --clientid ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwtkeyfile ./jwt-server.key --setdefaultdevhubusername | ||
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 Base Scratch Org' | ||
run: npx sfdx force:org:create --durationdays 1 --definitionfile ./config/scratch-orgs/base-scratch-def.json --wait 20 --setdefaultusername --json | ||
|
||
- name: 'Deploy Source to Scratch Org' | ||
run: npx sfdx force:source:deploy --sourcepath ./nebula-cache-manager/ | ||
|
||
- name: 'Assign Cache Manager Admin Permission Set' | ||
run: npm run permset:assign:admin | ||
|
||
# Nebula Cache Manager has functionality that use the session partition of platform cache, which only works 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. | ||
# Running the Apex tests sync & async serves 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 sfdx force:org:delete --json --noprompt | ||
if: ${{ always() }} | ||
|
||
platform-cache-scratch-org-tests: | ||
name: 'Run Platform Cache Scratch Org Tests' | ||
needs: [code-quality-tests] | ||
runs-on: ubuntu-latest | ||
environment: 'Platform Cache Scratch Org' | ||
steps: | ||
- name: 'Checkout source code' | ||
uses: actions/checkout@v3 | ||
|
||
- name: 'Restore node_modules cache' | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
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: | | ||
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key | ||
npx sfdx force:auth:jwt:grant --instanceurl ${{ env.DEV_HUB_AUTH_URL }} --clientid ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwtkeyfile ./jwt-server.key --setdefaultdevhubusername | ||
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 Platform Cache Scratch Org' | ||
run: npx sfdx force:org:create --durationdays 1 --definitionfile ./config/scratch-orgs/platform-cache-scratch-def.json --wait 20 --setdefaultusername --json | ||
|
||
- name: 'Deploy Source to Scratch Org' | ||
run: npx sfdx force:source:deploy --sourcepath ./nebula-cache-manager/ | ||
|
||
- name: 'Assign Cache Manager Admin Permission Set' | ||
run: npm run permset:assign:admin | ||
|
||
# Nebula Cache Manager has functionality that use the session partition of platform cache, which only works 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. | ||
# Running the Apex tests sync & async serves 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 -- --synchronous | ||
|
||
- name: 'Upload Apex test code coverage to Codecov.io' | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
flags: Apex | ||
|
||
- name: 'Delete Platform Cache Scratch Org' | ||
run: npx sfdx force:org:delete --json --noprompt | ||
if: ${{ always() }} | ||
|
||
create-unlocked-package-versions: | ||
name: 'Create Package Versions' | ||
needs: [base-scratch-org-tests, platform-cache-scratch-org-tests] | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
noNamespacePackageVersionId: ${{ steps.createNoNamespace.outputs.noNamespacePackageVersionId }} | ||
withNamespacePackageVersionId: ${{ steps.createWithNamespace.outputs.withNamespacePackageVersionId }} | ||
steps: | ||
- name: 'Checkout source code' | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: 'Restore node_modules cache' | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: npm-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
npm-${{ env.cache-name }}- | ||
npm- | ||
- name: Set environment variables | ||
run: | | ||
echo 'SFDX_DISABLE_AUTOUPDATE=true' >> $GITHUB_ENV | ||
echo 'SFDX_DISABLE_SOURCE_MEMBER_POLLING=true' >> $GITHUB_ENV | ||
echo 'SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=true' >> $GITHUB_ENV | ||
# echo 'SFDX_DISABLE_TELEMETRY=true' >> $GITHUB_ENV | ||
|
||
- name: 'Install npm dependencies' | ||
if: steps.cache-npm.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: 'Authorize Dev Hub' | ||
shell: bash | ||
run: | | ||
echo '${{ env.DEV_HUB_JWT_SERVER_KEY }}' > ./jwt-server.key | ||
npx sfdx force:auth:jwt:grant --instanceurl ${{ env.DEV_HUB_AUTH_URL }} --clientid ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwtkeyfile ./jwt-server.key --setdefaultdevhubusername | ||
# rm ./jwt-server.key | ||
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 No-Namespace Package Version' | ||
id: createNoNamespace | ||
run: | | ||
noNamespacePackageVersionId=$(npx sfdx force:package:version:create --package "Nebula Cache Manager (no namespace)" --wait 120 --codecoverage --skipancestorcheck --installationkeybypass --json | jq --exit-status --raw-output ".result.SubscriberPackageVersionId") | ||
echo "noNamespacePackageVersionId=$noNamespacePackageVersionId" >> $GITHUB_ENV | ||
echo "noNamespacePackageVersionId=$noNamespacePackageVersionId" >> $GITHUB_OUTPUT | ||
echo "Created package version $noNamespacePackageVersionId" | ||
- name: 'Create Namespaced Package Version' | ||
id: createWithNamespace | ||
run: | | ||
withNamespacePackageVersionId=$(npx sfdx force:package:version:create --package "Nebula Cache Manager (Nebula namespace)" --wait 120 --codecoverage --skipancestorcheck --installationkeybypass --json | jq --exit-status --raw-output ".result.SubscriberPackageVersionId") | ||
echo "withNamespacePackageVersionId=$withNamespacePackageVersionId" >> $GITHUB_ENV | ||
echo "withNamespacePackageVersionId=$withNamespacePackageVersionId" >> $GITHUB_OUTPUT | ||
echo "Created package version $withNamespacePackageVersionId" | ||
- name: 'Create Platform Cache Scratch Org' | ||
run: npx sfdx force:org:create --definitionfile ./config/scratch-orgs/platform-cache-scratch-def.json --setdefaultusername --durationdays 1 | ||
|
||
- name: 'Install Namespaced Package Version' | ||
run: npx sfdx package:install --package ${{ env.withNamespacePackageVersionId }} --wait 20 | ||
|
||
- name: 'Install No-Namespace Package Version' | ||
run: npx sfdx package:install --package ${{ env.noNamespacePackageVersionId }} --wait 20 | ||
|
||
- name: 'Validate Namespaced Package Access' | ||
run: npx sfdx apex:run --file ./scripts/build/validate-access-to-no-namespace-package.apex | ||
|
||
- name: 'Validate No-Namespace Package Access' | ||
run: npx sfdx apex:run --file ./scripts/build/validate-access-to-namespaced-package.apex | ||
|
||
- name: 'Delete Platform Cache Scratch Org' | ||
run: npx sfdx force:org:delete --json --noprompt | ||
if: ${{ always() }} | ||
|
||
# - name: 'Commit New Package Versions' | ||
# run: | | ||
# git config --local user.email "[email protected]" | ||
# git config --local user.name "GitHub Action Bot" | ||
# # npm run sfdx:plugins:link:bummer | ||
# # npx sfdx bummer:package:aliases:sort | ||
# rm ./jwt-server.key | ||
# npx prettier --write ./sfdx-project.json | ||
# git add ./sfdx-project.json | ||
# git status | ||
# git commit -m "Created new package versions" | ||
# git push |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
'sfdx-project.json': () => { | ||
return `npm run package:version:number:sync`; | ||
}, | ||
'*.{cls,cmp,component,css,html,js,json,md,page,trigger,yaml,yml}': filenames => filenames.map(filename => `prettier --write '${filename}'`), | ||
'*.{cls,trigger}': () => { | ||
return [`npm run scan:apex`]; | ||
} | ||
}; |
Oops, something went wrong.