Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into issues/1441
Browse files Browse the repository at this point in the history
  • Loading branch information
azlam-abdulsalam authored Nov 24, 2023
2 parents 3630e31 + 300fde5 commit ef66d81
Show file tree
Hide file tree
Showing 202 changed files with 19,969 additions and 144,087 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/buildPackages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
registry-url: https://registry.npmjs.org/

- name: 'Set Git Config'
Expand All @@ -41,7 +45,7 @@ jobs:
- name: 'Install Dependencies'
run: npm i
run: pnpm i


- name: 'Build All Packages'
Expand Down
69 changes: 57 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
push:
branches:
- main
- feat/docker-test
paths-ignore:
- 'docs/**'
- '**.md'
Expand Down Expand Up @@ -52,6 +53,20 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.DOCKER_SECRET }}
needs: [ build ]

build-docker-lite:
name: 'build sfp lite docker image'
uses: ./.github/workflows/sfpowerscripts-build-docker.yml
with:
job-environment: 'build-docker'
suffix-tag: ${{ github.run_id }}
repo: 'dxatscale'
dockerFileName: 'sfp-lite'
image: 'sfp-lite-rc'
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.DOCKER_SECRET }}
needs: [ build ]

#Promotion Stages

Expand Down Expand Up @@ -81,6 +96,19 @@ jobs:
token: ${{ secrets.DOCKER_SECRET }}
needs: [ build-docker ]

alpha-docker-lite:
name: 'promote docker lite to alpha'
uses: ./.github/workflows/sfpowerscripts-promote-docker.yml
with:
job-environment: 'sfpowerscripts-alpha-docker'
repo: 'dxatscale'
new-tag: alpha
image: 'sfp-lite-rc'
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.DOCKER_SECRET }}
needs: [ build-docker-lite ]


sfpowerscripts-beta:
name: 'sfpowerscripts beta'
Expand All @@ -100,11 +128,25 @@ jobs:
job-environment: 'sfpowerscripts-beta-docker'
repo: 'dxatscale'
new-tag: beta
image: 'sfpowerscripts-rc'
image: 'sfp-lite-rc'
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.DOCKER_SECRET }}
needs: [ build-docker ]

beta-docker-lite:
name: 'promote docker light to beta'
uses: ./.github/workflows/sfpowerscripts-promote-docker.yml
with:
job-environment: 'sfpowerscripts-beta-docker'
repo: 'dxatscale'
new-tag: beta
image: 'sfpowerscripts-rc'
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.DOCKER_SECRET }}
needs: [ build-docker-lite ]




Expand All @@ -119,17 +161,6 @@ jobs:
npm-token: ${{ secrets.NPM_TOKEN }}
needs: [ build ]

sfp-prod:
name: 'sfp prod'
uses: ./.github/workflows/promotePackage.yml
with:
version: 'latest'
pathToPackageJson: 'packages/sfp-cli/package.json'
environment: sfp-prod
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
needs: [ build ]

prod-docker:
name: 'copy rc docker to prod'
uses: ./.github/workflows/sfpowerscripts-copy-docker.yml
Expand All @@ -142,4 +173,18 @@ jobs:
cosign_password: ${{ secrets.COSIGN_PASSWORD }}
needs: [ build-docker ]

prod-docker-lite:
name: 'copy rc lite docker to prod'
uses: ./.github/workflows/sfpowerscripts-copy-docker.yml
with:
job-environment: 'sfpowerscripts-prod-docker'
image: sfp-lite-rc
image-as: sfp-lite
secrets:
username: ${{ secrets.DOCKER_USERNAME }}
token: ${{ secrets.DOCKER_SECRET }}
signing_secret: ${{ secrets.SIGNING_SECRET }}
cosign_password: ${{ secrets.COSIGN_PASSWORD }}
needs: [ build-docker-lite ]


11 changes: 8 additions & 3 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- uses: pnpm/action-setup@v2
with:
version: 8

- name: 'Install Dependencies'
run: pnpm i
- run: npx lerna run build
- run: npx lerna run test -- --colors
- run: bash <(curl -s https://codecov.io/bash) -v
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/sfpowerscripts-build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
repo:
type: string
required: true
dockerFileName:
type: string
required: false
default: sfpowerscripts
image:
type: string
required: false
Expand Down Expand Up @@ -70,7 +74,7 @@ jobs:
id: docker_build
uses: docker/build-push-action@v2
with:
file: dockerfiles/sfpowerscripts.Dockerfile
file: dockerfiles/${{inputs.dockerFileName}}.Dockerfile
context: dockerfiles
push: true
labels: ${{ steps.meta.outputs.labels }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/sfpowerscripts-copy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ jobs:
- name: 'Get package version'
run: |
echo "PKG_VERSION=$(jq -r ".version" packages/sfpowerscripts-cli/package.json)" >> $GITHUB_ENV
echo "RELEASE_VERSION=$(jq -r ".release" packages/sfpowerscripts-cli/package.json| read input; echo "$(cut -c1-3 <<< "$input")-$(cut -d' ' -f2 <<< "$input")" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
RELEASE_NAME=$(jq -r ".release" packages/sfpowerscripts-cli/package.json)
RELEASE_NAME_AS_ARRAY=($RELEASE_NAME)
RELEASE_NAME=$(echo ${RELEASE_NAME_AS_ARRAY[0]} | cut -c1-3)${RELEASE_NAME_AS_ARRAY[1]}
echo "RELEASE_NAME=release-$RELEASE_NAME" >> $GITHUB_ENV
- name: 'Re expose secretes'
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/sfpowerscripts-promote-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ jobs:
- name: 'Get package version'
run: |
echo "PKG_VERSION=$(jq -r ".version" packages/sfpowerscripts-cli/package.json)" >> $GITHUB_ENV
echo "RELEASE_VERSION=$(jq -r ".release" packages/sfpowerscripts-cli/package.json| read input; echo "$(cut -c1-3 <<< "$input")-$(cut -d' ' -f2 <<< "$input")" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
RELEASE_NAME=$(jq -r ".release" packages/sfpowerscripts-cli/package.json)
RELEASE_NAME_AS_ARRAY=($RELEASE_NAME)
RELEASE_NAME=$(echo ${RELEASE_NAME_AS_ARRAY[0]} | cut -c1-3)${RELEASE_NAME_AS_ARRAY[1]}
echo "RELEASE_NAME=release-$RELEASE_NAME" >> $GITHUB_ENV
- name: 'Re expose secrets'
Expand Down
46 changes: 27 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[![DeepScan grade](https://deepscan.io/api/teams/10234/projects/12959/branches/208838/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=10234&pid=12959&bid=208838) [![CodeFactor](https://www.codefactor.io/repository/github/dxatscale/sfpowerscripts/badge/develop)](https://www.codefactor.io/repository/github/dxatscale/sfpowerscripts/overview/develop)

[![npm](https://img.shields.io/npm/v/@dxatscale/sfpowerscripts)](https://www.npmjs.com/package/@dxatscale/sfpowerscripts)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdxatscale%2Fsfpowerscripts.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdxatscale%2Fsfpowerscripts?ref=badge_shield) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5614/badge)](https://bestpractices.coreinfrastructure.org/projects/5614)

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)


[![Join slack](https://i.imgur.com/FZZmA3g.png)](https://launchpass.com/dxatscale)

<p align="center">
<img alt="sfpowerscripts" src="https://repository-images.githubusercontent.com/248449736/448f93b4-9883-48da-a75c-330f242bbf8c" width="480" height="400">
</p>

![Version](https://img.shields.io/npm/v/@dxatscale/sfpowerscripts.svg)
[![GitHub stars](https://img.shields.io/github/stars/dxatscale/sfpowerscripts)](https://gitHub.com/dxatscale/sfpowerscripts/stargazers/)
[![GitHub contributors](https://img.shields.io/github/contributors/dxatscale/sfpowerscripts.svg)](https://github.com/dxatscale/sfpowerscripts/graphs/contributors/)
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/dxatscale/sfpowerscripts/blob/master/LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

[![DeepScan grade](https://deepscan.io/api/teams/10234/projects/12959/branches/208838/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=10234&pid=12959&bid=208838)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdxatscale%2Fsfpowerscripts.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdxatscale%2Fsfpowerscripts?ref=badge_shield) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5614/badge)](https://bestpractices.coreinfrastructure.org/projects/5614)

[![Join slack](https://i.imgur.com/FZZmA3g.png)](https://launchpass.com/dxatscale)

A build system for package based development in Salesforce, delivered as a node cli that can be implemented in any CI/CD system of choice.Read more about the cli and details here - https://docs.dxatscale.io

Expand All @@ -26,9 +26,9 @@ A build system for package based development in Salesforce, delivered as a node
- Integrate with any CI/CD system of choice
- All commands are enabled with statsD, for collecting metrics about your pipeline.

There are lot more features to explore. Read more at https://docs.dxatscale.io
There are lot more features to explore. Read more at https://docs.dxatscale.io

The project is delivered as a <b>CLI</b> that can be deployed in any CI/CD system, The module is available in [NPM](https://www.npmjs.com/package/@dxatscale/sfpowerscripts) or can be
The project is delivered as a <b>CLI</b> that can be deployed in any CI/CD system, The module is available in [NPM](https://www.npmjs.com/package/@dxatscale/sfpowerscripts) or can be
used by using the [docker image](https://github.com/dxatscale/sfpowerscripts/pkgs/container/sfpowerscripts)


Expand All @@ -45,7 +45,15 @@ used by using the [docker image](https://github.com/dxatscale/sfpowerscripts/pkg

#### CI/CD Reference Implementation

Getting started guides for popular CI/CD platforms along with reference pipelines are available [here](https://docs.dxatscale.io/reference-implementation/github)
Getting started guides for popular CI/CD platforms along with reference pipelines are available [here](https://docs.dxatscale.io/implementing-your-ci-cd/github)

#### Installing sfpowerscripts locally

sfpowerscripts can be installed on your local device using npm

```
npm i -g @dxatscale/sfpowerscripts
```


#### Docker
Expand All @@ -54,12 +62,12 @@ Docker images for sfpowerscripts are available at [GitHub Container Registry](ht

We recommend using the sfpowerscripts docker image to avoid breakages in your CI/CD pipelines due to updates in sfpowerscripts or any of its dependencies such as the SFDX CLI.

#### Build Instructions
To build sfpowerscripts execute the following on the terminal:
#### Build Instructions
To build sfpowerscripts execute the following on the terminal:
```
npm i -g lerna #Install Lerna Globally
cd <sfpowerscrips directory> # Navigate to the checked out directory
npm i
cd <sfpowerscripts directory> # Navigate to the checked out directory
pnpm i
lerna run build
```

Expand All @@ -72,7 +80,7 @@ lerna run test
To debug and test plugin

```
cd sfpowerscripts-cli
cd packages/sfpowerscripts-cli
npm link
```

Expand All @@ -83,7 +91,7 @@ List of Maintainers are available in the [link](https://docs.dxatscale.io/about-

#### Where do I reach for queries?

Please create an issue in the repo for bugs or utilize GitHub Discussions for other queries. Join our [Slack Community](https://launchpass.com/dxatscale) as well.
Please create an issue in the repo for bugs or utilize GitHub Discussions for other queries. Join our [Slack Community](https://launchpass.com/dxatscale) as well.


## License
Expand Down
14 changes: 7 additions & 7 deletions decision records/001-sfpowerscripts-artifact-customsettings.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Migrate sfpowerscripts artifact to utilize custom settings instead of a custom object

* Status: Accepted <!-- optional -->
* Status: Accepted <!-- optional -->
* Deciders: Azlam, Alan <!-- optional -->
* Date: <!-- optional -->
* Date: <!-- optional -->

Issue [Issue #476](https://github.com/dxatscale/sfpowerscripts/issues/476) <!-- optional -->

Expand All @@ -13,11 +13,11 @@ sfpowerscripts artifacts is an unlocked package that keeps track of all the pack
To solve this, these records should be stored in custom settings, which are preserved during refreshes. The cli should support utilising custom settings to store these records with a backward compatibility layer, so that none of the data gets lost while the migration is underway


## Decision
## Decision


This migration will be done in the following manner in the intermiediate release
- CLI commands to check for the existense of sfpowerscripts_artifact_c object and any associate records on every run
This migration will be done in the following manner in the intermediate release
- CLI commands to check for the existence of sfpowerscripts_artifact_c object and any associate records on every run
- If associated records are found, proceed to migrate all the existing records into the newly created custom setting object
- Delete all the records in sfpowerscripts_artifact_c object.
- Utilize custom settings moving forward
Expand All @@ -27,9 +27,9 @@ An upgrade to sfpowerscripts_package will be pushed to all the users who are uti
On a subsequent release, the custom object will be deprecated and CLI commands will remove the associated check and migration code


## Conseuqences <!-- optional -->
## Consequences <!-- optional -->

There will be a slight delay during deploy command, as it has to check for the existense. But once this migration is over it will be provide better accuracy and tie it back to the exact version of the package even when the org is refreshed from another one.
There will be a slight delay during deploy command, as it has to check for the existence. But once this migration is over it will be provide better accuracy and tie it back to the exact version of the package even when the org is refreshed from another one.


<!-- markdownlint-disable-file MD013 -->
6 changes: 3 additions & 3 deletions decision records/validate/001-automated-apex-testing-retry.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ During validate stage, sfpowerscripts triggers apex testing for each package and
- For Source Package, each individual apex class have more than 75% of coverage or more
- For Unlocked Packages, each package has an overall coverage of more than 75% of coverage or more

These tests are by default triggered asynchronously (in parallel), with a request to calculate coverage as well. Most projects however find it really difficult to get all the test of package to execute synchronously. After confirming with Salesforce Product team, tests are always triggered synchronously during Package Validation (build) or during deployment (source packages). Executing tests synchronously is extremely consuming on packages with larger number of test classes.
These tests are by default triggered asynchronously (in parallel), with a request to calculate coverage as well. Most projects however find it really difficult to get all the test of package to execute synchronously. After confirming with Salesforce Product team, tests are always triggered synchronously during Package Validation (build) or during deployment (source packages). Executing tests synchronously is extremely time consuming on packages with larger number of test classes.

There are also situations where bulk of the apex test in a package can be executed asynchronously with a few test cases that need to be triggered in synchronous mode.

A recently surfaced issue (#836), have uncovered coverage calculation becoming erratic randomly. This is attributed to the fact that asynchronous tests may trigger parallel compilation of classes under test and code coverage calculation is skipped.

## Decision

sfpowerscripts will collect all the test classes that failed in an asynchronous run due to 'UNABLE_TO_LOCK_ROW' or 'Your request exceeded the time limit for processing' and trigger these tests in synchronous mode.
sfpowerscripts will collect all the test classes that failed in an asynchronous run due to 'UNABLE_TO_LOCK_ROW', 'Your request exceeded the time limit for processing', 'LIMIT_EXCEEDED', 'Too many concurrent Apex compilations during resource mitigation', or an 'Internal Salesforce Error' and trigger these tests in synchronous mode.

sfpowerscripts will also figure out any tests classes that were not able to contribute to code coverage and execute them synchronously. As the current test api has limitation on how tests could be triggered synchronously (only one test class is allowed), sfpowerscripts will change the mode of the org to 'Disable Parallel Testing' by changing the apex setting as mentioned [ here](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_apexsettings.htm). sfpowerscripts will utilize jsforce update (http://jsforce.github.io/jsforce/doc/Metadata.html) to update this setting on the fly.
Once the setting is succesfully toggled, it will proceed to execute these tests using asynchronous payload, which is equivalent to triggering test classes synchronously. The coverage results are then converged and new coverage value is calculated
Once the setting is successfully toggled, it will proceed to execute these tests using asynchronous payload, which is equivalent to triggering test classes synchronously. The coverage results are then converged and new coverage value is calculated

The retry is only attempted once and provided there is no other failures in the first run other than the issues mentioned above
Loading

0 comments on commit ef66d81

Please sign in to comment.