Merge pull request #159 from CBIIT/fix-2.10.0-vulerabilities #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Tests | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - '*.*.*' | |
| push: | |
| branches: | |
| - main | |
| - '*.*.*' | |
| jobs: | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Run unit tests with coverage | |
| run: mvn clean test jacoco:report -Dspring.profiles.active=test | |
| - name: Coveralls GitHub Action | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| flag-name: unit-tests | |
| parallel: false | |
| continue-on-error: true | |
| - name: Publish test results | |
| if: always() | |
| uses: dorny/test-reporter@v1 | |
| with: | |
| name: Unit Test Results | |
| path: target/surefire-reports/*.xml | |
| reporter: java-junit | |
| fail-on-error: false | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| # Docker service container for OpenSearch | |
| services: | |
| opensearch: | |
| image: opensearchproject/opensearch:2.11.1 | |
| env: | |
| discovery.type: single-node | |
| plugins.security.disabled: 'true' | |
| OPENSEARCH_JAVA_OPTS: '-Xms512m -Xmx512m' | |
| ports: | |
| - 9200:9200 | |
| - 9600:9600 | |
| options: >- | |
| --health-cmd "curl -f http://localhost:9200/_cluster/health || exit 1" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Wait for OpenSearch to be ready | |
| run: | | |
| echo "Waiting for OpenSearch..." | |
| timeout 60 bash -c 'until curl -f http://localhost:9200/_cluster/health > /dev/null 2>&1; do sleep 2; done' | |
| echo "OpenSearch is ready!" | |
| - name: Verify OpenSearch health | |
| run: | | |
| echo "OpenSearch Status:" | |
| curl -f http://localhost:9200/_cluster/health?pretty | |
| - name: List integration test files | |
| run: | | |
| echo "Looking for integration test files..." | |
| find src/test/java -name '*IntegrationTest.java' -o -name '*IT.java' || echo "No integration test files found" | |
| - name: Run integration tests | |
| run: | | |
| echo "Running integration tests..." | |
| mvn verify -Dspring.profiles.active=integration || echo "Tests completed with exit code $?" | |
| echo "" | |
| echo "Checking for test execution..." | |
| if [ -d "target/failsafe-reports" ]; then | |
| echo "Failsafe reports directory exists" | |
| ls -la target/failsafe-reports/ || echo "Directory is empty" | |
| else | |
| echo "Failsafe reports directory does not exist" | |
| fi | |
| continue-on-error: true | |
| env: | |
| ES_HOST: localhost | |
| ES_PORT: 9200 | |
| ES_SCHEME: http | |
| - name: Check for integration test reports | |
| id: check-reports | |
| if: always() | |
| run: | | |
| echo "Checking for test reports..." | |
| if [ -d "target/failsafe-reports" ]; then | |
| echo "Directory exists, looking for XML files..." | |
| find target/failsafe-reports -name '*.xml' || echo "No XML files found" | |
| if [ -n "$(find target/failsafe-reports -name 'TEST-*.xml' 2>/dev/null)" ]; then | |
| echo "reports_exist=true" >> $GITHUB_OUTPUT | |
| echo "✓ Integration test reports found:" | |
| ls -la target/failsafe-reports/TEST-*.xml | |
| # Create a clean directory with only test reports (exclude summary) | |
| mkdir -p target/test-reports | |
| cp target/failsafe-reports/TEST-*.xml target/test-reports/ || true | |
| echo "Copied test reports to target/test-reports/" | |
| else | |
| echo "reports_exist=false" >> $GITHUB_OUTPUT | |
| echo "ℹ No XML reports found in failsafe-reports directory" | |
| fi | |
| else | |
| echo "reports_exist=false" >> $GITHUB_OUTPUT | |
| echo "ℹ No failsafe-reports directory found" | |
| fi | |
| - name: Publish integration test results | |
| if: always() && steps.check-reports.outputs.reports_exist == 'true' | |
| uses: dorny/test-reporter@v1 | |
| with: | |
| name: Integration Test Results | |
| path: target/test-reports/*.xml | |
| reporter: java-junit | |
| fail-on-error: false | |
| - name: Integration tests summary | |
| if: always() | |
| run: | | |
| if [ "${{ steps.check-reports.outputs.reports_exist }}" == "true" ]; then | |
| echo "✓ Integration tests executed and reported" | |
| else | |
| echo "ℹ No integration tests found - skipping test report publishing" | |
| echo "This is expected if you haven't created any *IntegrationTest.java files yet" | |
| fi | |
| - name: Upload test logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-logs | |
| path: | | |
| target/surefire-reports/ | |
| target/failsafe-reports/ | |
| *.log | |