Skip to content
Merged
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: 29 additions & 12 deletions .github/workflows/datastructures-algorithms-validate.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
name: datastructures-algorithms-validate

# Triggers when a PR is opened or updated, targeting the 'release' branch
# Triggers when a PR is opened or updated, targeting 'release' OR 'main'
on:
pull_request:
types: [opened, synchronize]
branches:
- 'release'
- 'main'
branches:
- release
- main

jobs:
# --- Job 1: Lint, Build, and Test ---
# --- Job 1: The "Gate" Job ---
# This job runs first to validate the PR path.
enforce-branch-strategy:
runs-on: ubuntu-latest
steps:
- name: Block invalid PR path
# This step ONLY runs if the path is INVALID
# Wrap the entire logical operation in ${{...}}
if: ${{ !((startsWith(github.event.pull_request.head.ref, 'feature-') && github.event.pull_request.base.ref == 'release') || (github.event.pull_request.head.ref == 'release' && github.event.pull_request.base.ref == 'main')) }}
run: |
echo "::error:: This PR path (${{ github.event.pull_request.head.ref }} -> ${{ github.event.pull_request.base.ref }}) is not allowed."
echo "::error:: Allowed paths are: 'feature-*' -> 'release' OR 'release' -> 'main'."
exit 1

- name: Approve valid PR path
# This step ONLY runs if the path is VALID (for logging)
if: (startsWith(github.event.pull_request.head.ref, 'feature-') && github.event.pull_request.base.ref == 'release') || (github.event.pull_request.head.ref == 'release' && github.event.pull_request.base.ref == 'main')
run: |
echo "Valid PR path. Proceeding to build and test..."

# --- Job 2: Lint, Build, and Test ---
lint-build-test:

# This job will ONLY run if:
# 1. (Source is 'feature-*' AND Target is 'release')
# OR
# 2. (Source is 'release' AND Target is 'main')
if: (startsWith(github.event.pull_request.head.ref, 'feature-') && github.event.pull_request.base.ref == 'release') || (github.event.pull_request.head.ref == 'release' && github.event.pull_request.base.ref == 'main')
# This job WAITS for 'enforce-branch-strategy' to succeed
needs: enforce-branch-strategy

runs-on: windows-latest

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

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
Expand Down
Loading