Overview
This workflow runs automatically on:- Pull requests targeting the
mainbranch - Merge queue events (when using GitHub merge queues)
Key Features
Fast Feedback
Provides quick validation results on pull requests without deploying to environments.
Concurrency Control
Automatically cancels in-progress runs when new commits are pushed to the PR.
Code Scanning
Uploads code analysis results directly to the pull request for inline review.
Short-lived Artifacts
Retains build artifacts for a shorter period to save storage costs.
Workflow Jobs
Pregate Check
Verifies pull request changes when coming from forked repositories.Security Check:
- Validates that PRs from external forks don’t contain malicious changes
- Uses the
VerifyPRChangesaction for security scanning - Only runs for cross-repository pull requests
Initialization
Prepares the build environment and determines what to build.Actions Performed:
- Checks out the PR merge commit
- Initializes AL-Go workflow
- Reads repository and project settings
- Determines which projects need to be built
- Calculates build order based on dependencies
- Sets artifact retention period (shorter than CI/CD builds)
Build
Compiles all affected AL projects.Build Characteristics:
- Builds on the PR merge commit (simulates merged state)
- Runs in a matrix for multiple projects and build modes
- Executes all tests
- Performs code analysis
- Does NOT sign artifacts (faster builds)
- Uses artifact cache for performance
- Validates against baseline from target branch
MyProject-Default-Apps-PR123).Code Analysis Upload
Processes and uploads code analysis results to GitHub.Features:
- Downloads error logs from build artifacts
- Converts AL compiler output to SARIF format
- Uploads to GitHub Code Scanning
- Shows inline annotations on the pull request
Code analysis results appear directly in the Files changed tab of your pull request.
Concurrency Management
The workflow uses concurrency controls to optimize resource usage:- Each PR has its own concurrency group
- New commits automatically cancel in-progress builds
- Saves runner time and provides faster feedback
When you push new commits to a PR, the old build is automatically cancelled and a new build starts.
Differences from CI/CD Workflow
The Pull Request Build workflow is optimized for speed and feedback:| Feature | Pull Request Build | CI/CD |
|---|---|---|
| Trigger | Pull requests | Push to main/release branches |
| Artifact Signing | No | Yes |
| Deployment | No | Yes (to configured environments) |
| Delivery | No | Yes (NuGet, Storage, etc.) |
| Artifact Retention | Short (e.g., 7 days) | Longer (e.g., 90 days) |
| Reference Docs | No | Yes (on main branch) |
| Concurrency | Cancel in-progress | Run all |
Configuration
Artifact Retention
Control how long PR artifacts are kept: In.github/AL-Go-Settings.json:
Default is typically 7 days for PR artifacts vs. 90 days for CI/CD artifacts.
Code Analysis
Enable inline code analysis on pull requests:- Compiler warnings appear as annotations on changed files
- Code scanning alerts show in the Security tab
- Reviewers can see issues directly in the PR
Build Matrix
The workflow automatically determines which projects to build based on:- Changed files in the pull request
- Project dependencies
- Workflow depth setting
Workflow Permissions
Required permissions for the workflow:Using with Branch Protection
Integrate the Pull Request Build with GitHub branch protection:Require Status Checks
Enable Require status checks to pass before mergingSelect the status check:
- Pull Request Status Check
Code Analysis Results
When code analysis is enabled, you’ll see:In Pull Request Files Tab
- Inline annotations on changed lines with issues
- Severity levels: Error, Warning, Info
- Quick links to AL documentation for code cops
In Security Tab
- All issues from the build (not just changed lines)
- Historical trends across builds
- Issue tracking and resolution status
Code analysis results are posted to the PR head commit, ensuring they align with the exact code being reviewed.
Build Artifacts
PR builds generate artifacts with special naming:- Format:
{ProjectName}-{BuildMode}-{ArtifactType}-PR{PRNumber} - Example:
MyApp-Default-Apps-PR42
Apps: Compiled application filesTestApps: Test application filesErrorLogs: Compilation and test error logsBuildOutput: Build logs and metadata
Artifacts are automatically cleaned up after the retention period expires.
Testing Pull Requests
Automated Testing
The workflow automatically:- Runs all test codeunits in test apps
- Collects test results in JUnit XML format
- Reports failures in the workflow summary
- Uploads test results as artifacts
Manual Testing
To manually test PR artifacts:Troubleshooting
Build Fails on PR but Not Locally
Ensure you’re testing the merge commit, not just your branch. The PR build tests the result of merging into the target branch.
Code Analysis Not Showing
Verify that
trackALAlertsInGitHub is enabled and the workflow has security-events: write permission.Cancelled Builds
This is normal behavior. Each new commit cancels the previous build to save resources.
Pregate Check Fails
The PR may contain unauthorized changes to critical files. Review the VerifyPRChanges action output for details.
Best Practices
Keep PRs Small
Smaller pull requests build faster and are easier to review. Aim for focused changes.
Wait for Builds
Always wait for the PR build to complete before merging. Don’t bypass status checks.
Review Code Analysis
Address code analysis warnings before merging. They help maintain code quality.
Example Workflow
A typical pull request workflow:- Developer creates PR from feature branch to main
- PR Build triggers automatically
- Pregate check validates the PR (if from fork)
- Projects are determined based on changed files
- Build runs on the merge commit
- Tests execute and results are reported
- Code analysis uploads issues to PR
- Status check reports overall result
- Developer addresses any issues
- Reviewer approves after build succeeds
- PR is merged into main
The Pull Request Build typically completes faster than CI/CD builds since it skips signing, deployment, and delivery steps.