Skip to content

feat: Travis to GitHub Actions CI #21

feat: Travis to GitHub Actions CI

feat: Travis to GitHub Actions CI #21

Workflow file for this run

name: Code Quality
on:
push:
branches: [ 1.x ]
pull_request:
branches: [ 1.x ]
workflow_dispatch:
# cancel same workflows in progress for pull request branches
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/1.x' }}
jobs:
code-coverage:
name: Code Coverage Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Shallow clones should be disabled for better analysis
- name: Set up JDK 8
uses: actions/setup-java@v5
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Build and run tests with coverage
run: |
mvn clean install -B -V \
-Dmaven.test.failure.ignore=true
- name: Generate JaCoCo aggregate report
run: |
mvn package -pl distribution -B -DskipTests
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./distribution/target/site/jacoco-aggregate/jacoco.xml
flags: unittests
name: codecov-dsbulk
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
continue-on-error: true
- name: Generate coverage summary
id: coverage
run: |
# Extract coverage percentage from JaCoCo XML report
if [ -f "distribution/target/site/jacoco-aggregate/jacoco.xml" ]; then
# Parse XML to get instruction coverage percentage
COVERED=$(grep -oP 'type="INSTRUCTION".*?covered="\K\d+' distribution/target/site/jacoco-aggregate/jacoco.xml | head -1)
MISSED=$(grep -oP 'type="INSTRUCTION".*?missed="\K\d+' distribution/target/site/jacoco-aggregate/jacoco.xml | head -1)
if [ -n "$COVERED" ] && [ -n "$MISSED" ]; then
TOTAL=$((COVERED + MISSED))
if [ $TOTAL -gt 0 ]; then
COVERAGE=$((COVERED * 100 / TOTAL))
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
echo "Coverage: $COVERAGE% ($COVERED/$TOTAL instructions)"
else
echo "coverage=0" >> $GITHUB_OUTPUT
echo "No coverage data available"
fi
else
echo "coverage=0" >> $GITHUB_OUTPUT
echo "Could not parse coverage data"
fi
else
echo "coverage=0" >> $GITHUB_OUTPUT
echo "Coverage report not found"
fi
- name: Add coverage comment to PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const coverage = '${{ steps.coverage.outputs.coverage }}';
const comment = `## Code Coverage Report
📊 **Coverage**: ${coverage}%
[View detailed report in artifacts](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Upload JaCoCo report
uses: actions/upload-artifact@v6
with:
name: jacoco-report
path: distribution/target/site/jacoco-aggregate/
retention-days: 30
- name: Check coverage threshold
run: |
COVERAGE=${{ steps.coverage.outputs.coverage }}
THRESHOLD=70
if [ "$COVERAGE" -lt "$THRESHOLD" ]; then
echo "⚠️ Coverage ($COVERAGE%) is below threshold ($THRESHOLD%)"
# Don't fail the build, just warn
else
echo "✅ Coverage ($COVERAGE%) meets threshold ($THRESHOLD%)"
fi
code-style:
name: Code Style Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up JDK 8
uses: actions/setup-java@v5
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Check code formatting
run: |
# Run the fmt-maven-plugin check
mvn com.coveo:fmt-maven-plugin:check -B
continue-on-error: true
- name: Check license headers
run: |
# Run the license-maven-plugin check
mvn license:check -B
continue-on-error: true
- name: Run SpotBugs
run: |
mvn compile spotbugs:check -B
continue-on-error: true
dependency-check:
name: Dependency Security Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up JDK 8
uses: actions/setup-java@v5
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Check for dependency vulnerabilities
run: |
mvn dependency:tree -B
mvn versions:display-dependency-updates -B
continue-on-error: true
- name: Upload dependency tree
uses: actions/upload-artifact@v6
with:
name: dependency-tree
path: target/dependency-tree.txt
retention-days: 7
if: always()
build-summary:
name: Quality Summary
runs-on: ubuntu-latest
needs: [code-coverage, code-style, dependency-check]
if: always()
steps:
- name: Create quality summary
run: |
echo "## Code Quality Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Code Coverage | ${{ needs.code-coverage.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Code Style | ${{ needs.code-style.result == 'success' && '✅ Passed' || '⚠️ Issues Found' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Dependencies | ${{ needs.dependency-check.result == 'success' && '✅ Passed' || '⚠️ Issues Found' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[View detailed results](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY