mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 11:55:51 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			161 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			161 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: Reusable test
 | 
						|
 | 
						|
on:
 | 
						|
  workflow_call:
 | 
						|
    inputs:
 | 
						|
      runs_on:
 | 
						|
        description: Runner to run the job on
 | 
						|
        required: true
 | 
						|
        type: string
 | 
						|
 | 
						|
      container:
 | 
						|
        description: "The container object as a JSON string (leave empty to run natively)"
 | 
						|
        required: true
 | 
						|
        type: string
 | 
						|
 | 
						|
      conan_profile:
 | 
						|
        description: Conan profile to use
 | 
						|
        required: true
 | 
						|
        type: string
 | 
						|
 | 
						|
      build_type:
 | 
						|
        description: Build type
 | 
						|
        required: true
 | 
						|
        type: string
 | 
						|
 | 
						|
      run_unit_tests:
 | 
						|
        description: Whether to run unit tests
 | 
						|
        required: true
 | 
						|
        type: boolean
 | 
						|
 | 
						|
      run_integration_tests:
 | 
						|
        description: Whether to run integration tests
 | 
						|
        required: true
 | 
						|
        type: boolean
 | 
						|
 | 
						|
jobs:
 | 
						|
  unit_tests:
 | 
						|
    name: Unit testing
 | 
						|
    runs-on: ${{ inputs.runs_on }}
 | 
						|
    container: ${{ inputs.container != '' && fromJson(inputs.container) || null }}
 | 
						|
 | 
						|
    if: ${{ inputs.run_unit_tests }}
 | 
						|
 | 
						|
    env:
 | 
						|
      # TODO: remove completely when we have fixed all currently existing issues with sanitizers
 | 
						|
      SANITIZER_IGNORE_ERRORS: ${{ endsWith(inputs.conan_profile, '.tsan') || inputs.conan_profile == 'clang.asan' || (inputs.conan_profile == 'gcc.asan' && inputs.build_type == 'Release') }}
 | 
						|
 | 
						|
    steps:
 | 
						|
      - name: Cleanup workspace
 | 
						|
        if: ${{ runner.os == 'macOS' }}
 | 
						|
        uses: XRPLF/actions/.github/actions/cleanup-workspace@ea9970b7c211b18f4c8bcdb28c29f5711752029f
 | 
						|
 | 
						|
      - uses: actions/checkout@v4
 | 
						|
        with:
 | 
						|
          fetch-depth: 0
 | 
						|
 | 
						|
      - uses: actions/download-artifact@v5
 | 
						|
        with:
 | 
						|
          name: clio_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
 | 
						|
 | 
						|
      - name: Make clio_tests executable
 | 
						|
        shell: bash
 | 
						|
        run: chmod +x ./clio_tests
 | 
						|
 | 
						|
      - name: Run clio_tests (regular)
 | 
						|
        if: ${{ env.SANITIZER_IGNORE_ERRORS == 'false' }}
 | 
						|
        run: ./clio_tests
 | 
						|
 | 
						|
      - name: Run clio_tests (sanitizer errors ignored)
 | 
						|
        if: ${{ env.SANITIZER_IGNORE_ERRORS == 'true' }}
 | 
						|
        run: ./.github/scripts/execute-tests-under-sanitizer ./clio_tests
 | 
						|
 | 
						|
      - name: Check for sanitizer report
 | 
						|
        if: ${{ env.SANITIZER_IGNORE_ERRORS == 'true' }}
 | 
						|
        shell: bash
 | 
						|
        id: check_report
 | 
						|
        run: |
 | 
						|
          if ls .sanitizer-report/* 1> /dev/null 2>&1; then
 | 
						|
            echo "found_report=true" >> $GITHUB_OUTPUT
 | 
						|
          else
 | 
						|
            echo "found_report=false" >> $GITHUB_OUTPUT
 | 
						|
          fi
 | 
						|
 | 
						|
      - name: Upload sanitizer report
 | 
						|
        if: ${{ env.SANITIZER_IGNORE_ERRORS == 'true' && steps.check_report.outputs.found_report == 'true' }}
 | 
						|
        uses: actions/upload-artifact@v4
 | 
						|
        with:
 | 
						|
          name: sanitizer_report_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
 | 
						|
          path: .sanitizer-report/*
 | 
						|
          include-hidden-files: true
 | 
						|
 | 
						|
      - name: Create an issue
 | 
						|
        if: ${{ false && env.SANITIZER_IGNORE_ERRORS == 'true' && steps.check_report.outputs.found_report == 'true' }}
 | 
						|
        uses: ./.github/actions/create-issue
 | 
						|
        env:
 | 
						|
          GH_TOKEN: ${{ github.token }}
 | 
						|
        with:
 | 
						|
          labels: "bug"
 | 
						|
          title: "[${{ inputs.conan_profile }}] reported issues"
 | 
						|
          body: >
 | 
						|
            Clio tests failed one or more sanitizer checks when built with ${{ inputs.conan_profile }}`.
 | 
						|
 | 
						|
            Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/
 | 
						|
            Reports are available as artifacts.
 | 
						|
 | 
						|
  integration_tests:
 | 
						|
    name: Integration testing
 | 
						|
    runs-on: ${{ inputs.runs_on }}
 | 
						|
    container: ${{ inputs.container != '' && fromJson(inputs.container) || null }}
 | 
						|
 | 
						|
    if: ${{ inputs.run_integration_tests }}
 | 
						|
 | 
						|
    services:
 | 
						|
      scylladb:
 | 
						|
        image: ${{ inputs.container != '' && 'scylladb/scylla' || '' }}
 | 
						|
        options: >-
 | 
						|
          --health-cmd "cqlsh -e 'describe cluster'"
 | 
						|
          --health-interval 10s
 | 
						|
          --health-timeout 5s
 | 
						|
          --health-retries 5
 | 
						|
 | 
						|
    steps:
 | 
						|
      - name: Cleanup workspace
 | 
						|
        if: ${{ runner.os == 'macOS' }}
 | 
						|
        uses: XRPLF/actions/.github/actions/cleanup-workspace@ea9970b7c211b18f4c8bcdb28c29f5711752029f
 | 
						|
 | 
						|
      - name: Spin up scylladb
 | 
						|
        if: ${{ runner.os == 'macOS' }}
 | 
						|
        timeout-minutes: 3
 | 
						|
        run: |
 | 
						|
          docker rm --force scylladb || true
 | 
						|
          docker run \
 | 
						|
            --detach \
 | 
						|
            --name scylladb \
 | 
						|
            --health-cmd "cqlsh -e 'describe cluster'" \
 | 
						|
            --health-interval 10s \
 | 
						|
            --health-timeout 5s \
 | 
						|
            --health-retries 5 \
 | 
						|
            --publish 9042:9042 \
 | 
						|
            --memory 16G \
 | 
						|
            scylladb/scylla
 | 
						|
 | 
						|
          until [ "$(docker inspect -f '{{.State.Health.Status}}' scylladb)" == "healthy" ]; do
 | 
						|
            sleep 5
 | 
						|
          done
 | 
						|
 | 
						|
      - uses: actions/download-artifact@v5
 | 
						|
        with:
 | 
						|
          name: clio_integration_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
 | 
						|
 | 
						|
      - name: Run clio_integration_tests
 | 
						|
        run: |
 | 
						|
          chmod +x ./clio_integration_tests
 | 
						|
          ./clio_integration_tests ${{ runner.os != 'macOS' && '--backend_host=scylladb' || '' }}
 | 
						|
 | 
						|
      - name: Show docker logs and stop scylladb
 | 
						|
        if: ${{ always() && runner.os == 'macOS' }}
 | 
						|
        run: |
 | 
						|
          docker logs scylladb
 | 
						|
          docker rm --force scylladb || true
 |