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.

180 changes: 47 additions & 133 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -1,152 +1,66 @@
name: 'PR Review Comment'

on:
issue_comment:
types: [created, edited]
pull_request:
types: [labeled]

permissions:
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
sfp-validate-pool:
validate:
name: 'Validate Changed Packages'
if: contains(github.event.pull_request.labels.*.name, 'full validation')
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

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

- name: Process PR Comment
id: process-comment
- name: Run Validation Script
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
echo "Running validation because 'full validation' label was added"
# Add your validation logic here (e.g., linting, testing)

# - name: Checkout
# uses: actions/checkout@v3
sleep 10
exit 0

- name: Run Validation
id: validate
- name: Remove label
if: always()
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
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 }})











PR_NUMBER=${{ github.event.pull_request.number }}
REPO=${{ github.repository }}
LABEL="full validation"

# URL-encodes the label by replacing special characters with their percent-encoded equivalents.
ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g')

echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL"
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}"





# name: Validate and Run Commands Based on PR Labels

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

# jobs:
# validate-and-execute:
# remove-label:
# needs: validate
# if: always() # Ensures this runs even if validation fails
# 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
# - name: Remove 'needs-validation' label
# run: |
# echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}"
# PR_NUMBER=${{ github.event.pull_request.number }}
# REPO=${{ github.repository }}
# LABEL="full validation"
# ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g')

# echo $ENCODED_LABEL
# echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL"
# curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "Accept: application/vnd.github.v3+json" \
# "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}"