Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions .github/workflows/nightly.yaml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/pr-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: 'PR Validation - Auto Triggered'

on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main
- release/**

workflow_dispatch:

jobs:
validate-selfhosted:
if: ${{ contains(github.event.pull_request.labels.*.name, 'long-run') }}
uses: ./.github/workflows/validate.yaml
with:
runner-type: 'self-hosted'
timeout: 640

validate-githubhosted:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'long-run') }}
uses: ./.github/workflows/validate.yaml
with:
runner-type: 'github-hosted'
timeout: 480

# static-check:
# name: 'See if Static Analysis should run'
# runs-on: ubuntu-latest

# outputs:
# all-changed-files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}

# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Get all changed files for this PR
# id: changed-files
# uses: tj-actions/changed-files@v42
# with:
# files_ignore_from_source_file: changed-files-ignore-list.txt
# separator: ","

# - name: List changed files, skipping this job if there are no files to analyze
# run: |
# if [ "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" == "" ]; then
# echo 'No files eligible for scanning were changed. Skipping Static Analysis.'
# exit 0
# else
# echo ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
# fi

# static:
# name: 'Run Static Analysis'
# runs-on: ubuntu-latest
# needs: static-check
# if: needs.static-check.outputs.all-changed-files != ''

# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Install Salesforce CLI & Salesforce Code Analyzer
# run: |
# echo "Installing Salesforce CLI & Salesforce Code Analyzer"

# - name: Run Salesforce Code Analyzer
# id: run-code-analyzer
# # uses: forcedotcom/run-code-analyzer@v1
# run: |
# echo "Running Salesforce Code Analyzer"

# - name: Check the outputs to determine whether to fail
# if: |
# steps.run-code-analyzer.outputs.exit-code > 0 ||
# steps.run-code-analyzer.outputs.num-sev1-violations > 0
# run: exit 1
234 changes: 95 additions & 139 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -1,152 +1,108 @@
name: 'PR Review Comment'
# Based on Flxbl (formerly DX@Scale) CI/CD Template for GitHub
#
# To know more about flxbl, visit https://docs.flxbl.io
# To know more on sfpowerscripts, visit- https://docs.flxbl.io/sfp

# This pipeline is used to validate an incoming change using a scratch org fetched from the CI pool

name: 'PR Validation - Auto Triggered'

on:
issue_comment:
types: [created, edited]
workflow_call:
inputs:
runner-type:
description: 'Runner type (self-hosted or GitHub-hosted)'
required: true
type: string
timeout:
description: 'Job timeout in minutes'
required: false
default: 480
type: number

# permissions:
# contents: read # Allows the workflow to read repository contents, required for checkout and other read operations
# pull-requests: write # This is required to delete a label from the PR


# Ensures that multiple validation job runs do not execute concurrently on the same PR.
# If a new run is triggered, any in-progress run for the same group is canceled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
sfp-validate-pool:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: >
github.event.issue.pull_request &&
(
contains(github.event.comment.body, '/quick-validation') ||
contains(github.event.comment.body, '/full-validation')
)
steps:
- name: Fetch Branch Name
id: fetch-branch-name
uses: xt0rted/pull-request-comment-branch@v2
validate:
name: 'Validate Changed Packages'
timeout-minutes: ${{ inputs.timeout }}
runs-on: ${{ inputs.runner-type == 'github-hosted' && 'ubuntu-latest' || fromJSON('["group=${{ vars.RUNNER_GROUP_LATEST }}", "labels=self-hosted"]') }}
# container:
# image: ${{ vars.SFP_IMAGE }}
# credentials:
# username: ${{ github.repository_owner }}
# password: ${{ secrets.ACCESS_TOKEN }}

- name: Check out code from ${{ steps.fetch-branch-name.outputs.head_ref }}
uses: actions/checkout@v3
steps:
- uses: actions/checkout@v4
with:
ref: ${{ steps.fetch-branch-name.outputs.head_ref }}
fetch-depth: 0

- name: Process PR Comment
id: process-comment
# New step: Scan sfdx-project.json for "replaceWithFile" entries and check if files exist
- name: 'Check replaceWithFile existence in sfdx-project.json'
id: check-replaceWithFile
run: |
COMMENT_ID="${{ github.event.comment.id }}"
COMMENT_BODY="${{ github.event.comment.body }}"
echo "COMMENT_ID: $COMMENT_ID"
echo "COMMENT_BODY: $COMMENT_BODY"
echo "::set-output name=comment-id::$COMMENT_ID"
if [[ "$COMMENT_BODY" == *"/quick-validation"* ]]; then
echo "::set-output name=validation-type::quick"
elif [[ "$COMMENT_BODY" == *"/full-validation"* ]]; then
echo "::set-output name=validation-type::full"
fi

# - name: Checkout
# uses: actions/checkout@v3
# Extract "replaceWithFile" values from sfdx-project.json and check if the files exist
shell: bash

- name: Run Validation
id: validate
run: |
if [[ "${{ steps.process-comment.outputs.validation-type }}" == "quick" ]]; then
echo "Running Quick Validation..."
sleep 5 # Simulate quick validation
echo "Quick Validation Successful" > result.txt
elif [[ "${{ steps.process-comment.outputs.validation-type }}" == "full" ]]; then
echo "Running Full Validation..."
sleep 60 # Simulate full validation
echo "Full Validation Successful" > result.txt
fi
continue-on-error: true

- name: Post Validation Status to PR
uses: mshick/add-pr-comment@v2
- name: 'Get all changed files for this PR'
id: changed-deployable-files
uses: tj-actions/changed-files@v42
with:
message: |
Validation run completed: **${{ steps.process-comment.outputs.validation-type }}**
Status: ${{ steps.validate.outcome == 'success' && '✅ Success' || '❌ Failed' }}
[View the workflow run here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})













files_ignore_from_source_file: validation-ignore-list.txt
separator: ","

- name: 'Authenticate Dev Hub'
run: |
echo "Authenticating with Dev Hub"

# Validate source and trigger test, skipping if there are no deployable changes
- name: 'If deployable changes were made, push source to a scratch org'
run: |
if [ "${{ steps.changed-deployable-files.outputs.all_changed_and_modified_files }}" == "" ]; then
echo 'No deployable changes were made. Skipping Scratch Org Validation.'
exit 0
fi
echo "Deploying source to a scratch org"

# Upload test results to the GitHub workspace
- name: 'Upload test results'
# uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
run: |
echo "Dummy Uploading test results"



# name: Validate and Run Commands Based on PR Labels

# on:
# pull_request:
# types: [opened, synchronize, labeled, unlabeled]

# jobs:
# validate-and-execute:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# # - name: Get PR Labels
# # id: get-labels
# # uses: actions/github-script@v6
# # with:
# # script: |
# # const labels = context.payload.pull_request.labels.map(label => label.name);
# # return labels;
# # result-encoding: string

# # - name: Determine Validation Type
# # id: determine-validation-mode
# # run: |
# # labels="${{ steps.get-labels.outputs.result }}"

# # validation_mode="thorough"
# # if echo "$labels" | grep -q "quick validation"; then
# # validation_mode="individual"
# # fi

# # echo "validation_mode=$validation_mode" | tee -a $GITHUB_OUTPUT

# # # Validate source and trigger test, skipping if there are no deployable changes
# # - name: 'If deployable changes were made, push source to a scratch org'
# # run: |
# # labels="${{ steps.get-labels.outputs.result }}"

# # validation_mode="thorough"
# # if echo "$labels" | grep -q "quick validation"; then
# # validation_mode="individual"
# # fi
# # echo $validation_mode

# - name: Get SFP Pool Validation Mode from the PR labels
# id: sfp-validation-mode
# uses: actions/github-script@v7
# with:
# script: |

# const labels = context.payload.pull_request.labels.map(label => label.name);
# const hasQuickValidation = labels.includes('quick validation');
# const hasFullValidation = labels.includes('full validation');

# let validationMode = 'thorough';

# if (hasQuickValidation && !hasFullValidation) {
# validationMode = 'individual';
# }

# console.log(`SFP Validation Mode: ${validationMode}`);
# return validationMode;
# result-encoding: string

# - name: Run Commands Based on the Validation Mode
# run: |
# echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}"
# If the job is cancelled, release the CI org
- name: 'Delete stale CI org'
if: ${{ cancelled() }}
run: |
echo "Deleting stale CI org"


# validate-package-coverage:
# name: 'Validate Package Metadata Coverage'
# runs-on: ubuntu-latest
# container:
# image: ${{ vars.SFP_IMAGE }}
# credentials:
# username: ${{ github.repository_owner }}
# password: ${{ secrets.ACCESS_TOKEN }}
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: 'Validate metadata coverage'
# shell: bash
# run: |
# sfdx sfpowerkit:package:valid -n redhatcrm-core -b StandardValueSet

Empty file added changed-files-ignore-list.txt
Empty file.
1 change: 1 addition & 0 deletions validation-ignore-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ykoer/**