Overview
The build and publish workflow is triggered when:- PR Merged: Pull request is merged to main, develop, or release branches
- Manual Trigger: Via workflow_dispatch
build-publish.yaml workflow from backbase-common/gc-ai-workflows for consistent build and publish processes.
Reusable Components Used
This workflow leverages the following reusable components:- build-publish.yaml: Main reusable workflow that orchestrates the entire build and publish process
- setup-project: Sets up Python environment and resolves project metadata
- code-quality: Runs pylint, pytest, and hadolint checks
- sonar-check: Performs SonarCloud code analysis (conditional)
- promptfoo-evaluation: Runs prompt evaluation tests (conditional)
- promptfoo-redteaming: Runs security and adversarial tests (conditional)
- build-docker: Builds Docker images
- security-check: Scans Docker images with Trivy
- push-docker: Pushes images to Azure Container Registry
Workflow Flowchart
Build Process
1. Build and Test
The workflow performs:- Code Compilation: Build agent code
- Dependency Resolution: Install and verify dependencies
- Testing: Run automated tests
2. Quality Checks
Quality gates are conditionally enabled:- SonarQube: Enabled for main and develop branches
- Promptfoo: Enabled for main and develop branches
- Redteam: Enabled for main and develop branches
3. Artifact Publishing
Build artifacts are published:- Packages: Agent packages published to registry
- Docker Images: Container images built and pushed
- Documentation: Auto-generated documentation
Workflow Configuration
The build and publish workflow is defined in.github/workflows/build-publish.yaml:
Configuration Options
Timeout
Maximum execution time in minutes:SonarQube
Conditionally enabled for main and develop branches:Promptfoo Testing
Conditionally enabled for main and develop branches:Redteam Testing
Conditionally enabled for main and develop branches:Branch-Specific Behavior
Main and Develop Branches
Full quality gates enabled:- SonarQube analysis
- Promptfoo testing
- Redteam security testing
Release Branches
Basic build and publish:- Build and test
- Artifact publishing
- Quality gates disabled for faster releases
Build Artifacts
The build workflow produces:- Agent Packages: Published to package registry
- Docker Images: Container images tagged and pushed
- Test Reports: Test execution results
- Coverage Reports: Code coverage metrics
- Build Logs: Complete build execution logs
Troubleshooting
Build Failures
Common build failure reasons:- Compilation Errors: Fix syntax or type errors
- Test Failures: Address failing tests
- Dependency Issues: Resolve missing or incompatible dependencies
- Quality Gate Failures: Improve code quality metrics (SonarQube)
- Security Issues: Address Redteam findings
Performance Optimization
- Quality gates are disabled for release branches to speed up builds
- Use caching for dependencies
- Optimize test execution
Best Practices
- Keep builds fast and efficient
- Monitor build times and optimize
- Address quality gate failures promptly
- Test locally before pushing changes
- Review build logs for detailed error information