Continuous Integration With GitHub Actions
Apache Ozone uses GitHub Actions for continuous integration (CI), automating the build, test, and verification processes. This ensures code quality and reduces the risk of introducing defects.
CI Workflow Overview
The primary CI workflow in Ozone is defined in .github/workflows/ci.yml
. It's triggered by:
- Pull request creation or updates
- Direct pushes to the main branch
- Scheduled runs (twice daily)
Main Workflow Components
The CI workflow consists of several jobs:
- build-info: Determines which tests should run based on modified files
- compile: Builds the project with different Java versions (8, 11, 17)
- basic: Runs quick checks like style validation and license header verification
- acceptance: Executes Robot Framework tests in containerized environments
- kubernetes: Tests Kubernetes deployment configurations
- integration: Runs integration tests with MiniOzoneCluster
- coverage: Collects and merges code coverage data
Smart Test Selection
Ozone's CI optimizes resource usage by selectively running tests based on what files changed:
# Examples of selective test execution
if [[ changed_files =~ \.md$ ]]; then
# Only documentation changed, run minimal checks
RUN_CHECKS="author checkstyle"
elif [[ changed_files =~ pom\.xml ]]; then
# Dependency changes, include dependency checks
RUN_CHECKS="author rat checkstyle findbugs dependency"
fi
This logic is implemented in .github/selective_ci_checks.sh
and helps reduce CI time for smaller changes.
Available CI Jobs
1. Basic Checks
Quick checks that complete in under 10 minutes:
- author: Ensures no
@author
tags in code - rat: Verifies Apache license headers
- checkstyle: Validates code style
- findbugs: Runs static code analysis
- dependency: Checks for dependency issues
2. Integration Tests
Tests component interactions using MiniOzoneCluster:
# Run integration tests with Maven
mvn verify -Pintegration
These tests are grouped into suites in integration_suites.sh
and can run in parallel.
3. Acceptance Tests
End-to-end tests using Robot Framework with Docker:
# Run acceptance tests
cd hadoop-ozone/dist/src/main/smoketest/compose
./test.sh ozone basic
Acceptance tests verify real-world behavior in containerized environments.
4. Kubernetes Tests
Tests Ozone deployment on Kubernetes:
# Run Kubernetes tests
cd hadoop-ozone/dev-support/checks
./kubernetes.sh
Adding a New Test to CI
To add a new test to the CI pipeline:
- Create your test files in the appropriate directory
- Update the relevant test selection script:
- For acceptance tests:
acceptance_suites.sh
- For integration tests:
integration_suites.sh
- For acceptance tests:
- For new test types, update
.github/workflows/ci.yml
Running CI Locally
You can run the same checks locally:
# Run basic checks
cd hadoop-ozone/dev-support/checks
./rat.sh
./checkstyle.sh
./findbugs.sh
# Run unit tests
./unit.sh
# Run integration tests
./integration.sh
Interpreting CI Results
GitHub Actions provides detailed logs for each job. When a job fails:
- Look at the failed step in the workflow summary
- Open the detailed job log
- Search for "ERROR" or "FAIL" to find the issue
- For test failures, check test reports in artifacts
Rerunning Failed Jobs
If CI fails, you can:
- Click "Re-run jobs" in the GitHub Actions interface
- Make a small change and push again
- Use the
/retest
comment command in your PR
Best Practices
- Run checks locally before pushing changes
- Check for similar failures in recent PRs
- Add tests for new features and bug fixes
- Minimize false positives by making tests reliable
- Don't ignore failures - fix the root cause
Common Issues and Solutions
Flaky Tests
Some tests may occasionally fail due to timing or resource issues:
- Check recent runs to see if it's a known flaky test
- Look for timeout or race condition issues
- Consider improving the test's stability
Resource Constraints
CI jobs run with limited resources:
- Avoid excessive memory usage in tests
- Use appropriate timeouts for operations
- Clean up resources properly
Dependency Issues
If dependency checks fail:
- Verify compatibility with existing dependencies
- Check for Maven shade plugin conflicts
- Ensure proper dependency management
Additional CI Information
For advanced CI topics, refer to: