-
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.
- Loading branch information
Showing
10 changed files
with
9,319 additions
and
1,745 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,276 @@ | ||
# 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 | ||
|
||
- 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_DISABLE_TELEMETRY=true" >> $GITHUB_ENV | ||
echo "SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=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: npm run package:version:create:nonamespace -- --branch "${{ inputs.branch }}" --tag ${{ github.sha }} | ||
|
||
- name: 'Create namespaced package version' | ||
id: createWithNamespace | ||
run: npm run package:version:create:withnamespace -- --branch "${{ inputs.branch }}" --tag ${{ github.sha }} | ||
|
||
# run: | | ||
# noNamespacePackageVersionId=$(npm run package:version:create:nonamespace -- --branch "${{ inputs.branch }}" --tag ${{ github.sha }} | jq -e -r ".result.SubscriberPackageVersionId") | ||
# echo "noNamespacePackageVersionId=$noNamespacePackageVersionId" >> $GITHUB_ENV | ||
# echo "noNamespacePackageVersionId=$noNamespacePackageVersionId" >> $GITHUB_OUTPUT | ||
|
||
# - name: 'Create namespaced package version' | ||
# id: createWithNamespace | ||
# run: | | ||
# withNamespacePackageVersionId=$(npm run package:version:create:nonamespace -- --branch "${{ inputs.branch }}" --tag ${{ github.sha }} | jq -e -r ".result.SubscriberPackageVersionId") | ||
# echo "withNamespacePackageVersionId=$withNamespacePackageVersionId" >> $GITHUB_ENV | ||
# echo "withNamespacePackageVersionId=$withNamespacePackageVersionId" >> $GITHUB_OUTPUT | ||
|
||
# - name: 'Create Platform Cache Scratch Org' | ||
# run: npx sfdx force:org:create -f config/scratch-orgs/platform-cache-scratch-def.json -a scratch-org -s -d 1 | ||
|
||
# - name: 'Install no-namespace package version' | ||
# run: npx sfdx force:package:install -p ${{ env.noNamespacePackageVersionId }} -u scratch-org -w 10 | ||
|
||
# - name: 'Install namespaced package version' | ||
# run: npx sfdx force:package:install -p ${{ env.withNamespacePackageVersionId }} -u scratch-org -w 10 | ||
|
||
# - 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 "action@github.com" | ||
git config --local user.name "GitHub Action Bot" | ||
npm run sfdx:plugins:link:bummer | ||
npx sfdx bummer:package:aliases:sort | ||
npx prettier --write ./sfdx-project.json | ||
git add ./sfdx-project.json | ||
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
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
17 changes: 17 additions & 0 deletions
17
nebula-cache-manager/core/permissionsets/CacheManagerAdmin.permissionset-meta.xml
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<classAccesses> | ||
<apexClass>CacheManager</apexClass> | ||
<enabled>true</enabled> | ||
</classAccesses> | ||
<customMetadataTypeAccesses> | ||
<enabled>true</enabled> | ||
<name>CacheConfiguration__mdt</name> | ||
</customMetadataTypeAccesses> | ||
<customMetadataTypeAccesses> | ||
<enabled>true</enabled> | ||
<name>CacheValue__mdt</name> | ||
</customMetadataTypeAccesses> | ||
<hasActivationRequired>false</hasActivationRequired> | ||
<label>Cache Manager: Admin</label> | ||
</PermissionSet> |
Oops, something went wrong.