This repository contains an example of how to implement a continuous integration pipeline for a managed package project using GitHub Actions and CumulusCI.
There are three workflows that help implement CumulusCI flow:
- Feature Test
- Main
- Packaging Test
Feature Test deploys the repositories metadata to an org and runs tests against it.
Main uploads metadata to a packaging org and creates a new beta release.
Packaging Test installs the newly created beta version into an org and runs tests against it.
All GitHub action workflows have the same initial steps:
- Install the Salesforce CLI (
sfdx) - Setup Python
- Install CumulusCI
The workflows differ in the events that trigger them, as well as, the specific CumulusCI flows that are run.
.github/workflows/feature.yml
This workflow runs on all commits to any branch in the repository.
This workflow does two things:
- Runs the
ci_featureflow against adevorg. This flow deploys (unmanaged) metadata in the repository to an org and runs Apex tests. - Runs the
robottask against adevorg. This task executes all robot tests located underrobot/cci-ci-demo/tests/against aqa_org.
.github/workflows/main.yml
This workflow runs after the "Feature Test" workflow completes successfully against the main branch.
This workflow does two things:
- Deploys the metadata in the repository to the packaging org via the
ci_masterflow. - Uploads a managed beta release via the
release_betaflow.
Both of these flows are run against the packaging org.
.github/workflows/package_test.yml
This workflow runs after a new release tag is created in GitHub. (Tags are created by the prior workflow via the release_beta flow.)
This workflow does one thing:
- Runs the
ci_betaflow to install the latest Beta Release (created by the prior workflow) in abetaorg and run Apex tests.
This repository can easily be forked and used as a template for your own Salesforce managed package project.
You will need to add the following secrets to your projects repository:
-
CUMULUSCI_SERVICE_github- This is so that CumulusCI can access the GitHub API to do things like aggregate release notes, and automerge commits made tomainintofeature/branches. Set this secret with the following value:{"username": "github_username", "token":"github_personal_access_token","email":"email_address"} -
SFDX_AUTH_URL- TheSfdx Auth Urllisted when runningsfdx force:org:display --verbose -u <username>against your dev hub org. -
SFDX_CLIENT_ID- The client id for your connnected app in the packaging org. -
SFDX_HUB_KEY- Set to the private key associated with your connected app (the contents of yourserver.keyfile) in your packaging org.
You also need to set the value for the CUMULUSCI_ORG_packaging environment variable in workflows main.yml.
It should have the following structure:
{
"username": "first.last@something.com",
"instance_url": "https://something.my.salesforce.com"
}