mirror of
				https://github.com/Xahau/xahaud.git
				synced 2025-11-04 02:35:48 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			107 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: dependencies
 | 
						|
description: 'Installs build dependencies with caching'
 | 
						|
 | 
						|
inputs:
 | 
						|
  configuration:
 | 
						|
    description: 'Build configuration (Debug, Release, etc.)'
 | 
						|
    required: true
 | 
						|
  build_dir:
 | 
						|
    description: 'Directory to build dependencies in'
 | 
						|
    required: false
 | 
						|
    default: '.build'
 | 
						|
  compiler-id:
 | 
						|
    description: 'Unique identifier for compiler/version combination used for cache keys'
 | 
						|
    required: false
 | 
						|
    default: ''
 | 
						|
  cache_version:
 | 
						|
    description: 'Cache version for invalidation'
 | 
						|
    required: false
 | 
						|
    default: '1'
 | 
						|
  cache_enabled:
 | 
						|
    description: 'Whether to use caching'
 | 
						|
    required: false
 | 
						|
    default: 'true'
 | 
						|
  main_branch:
 | 
						|
    description: 'Main branch name for restore keys'
 | 
						|
    required: false
 | 
						|
    default: 'dev'
 | 
						|
 | 
						|
outputs:
 | 
						|
  cache-hit:
 | 
						|
    description: 'Whether there was a cache hit'
 | 
						|
    value: ${{ steps.cache-restore-conan.outputs.cache-hit }}
 | 
						|
 | 
						|
runs:
 | 
						|
  using: 'composite'
 | 
						|
  steps:
 | 
						|
    - name: Generate safe branch name
 | 
						|
      if: inputs.cache_enabled == 'true'
 | 
						|
      id: safe-branch
 | 
						|
      shell: bash
 | 
						|
      run: |
 | 
						|
        SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
 | 
						|
        echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
 | 
						|
 | 
						|
    - name: Check conanfile changes
 | 
						|
      if: inputs.cache_enabled == 'true'
 | 
						|
      id: check-conanfile-changes
 | 
						|
      shell: bash
 | 
						|
      run: |
 | 
						|
        # Check if we're on the main branch
 | 
						|
        if [ "${{ github.ref_name }}" == "${{ inputs.main_branch }}" ]; then
 | 
						|
          echo "should-save-conan-cache=true" >> $GITHUB_OUTPUT
 | 
						|
        else
 | 
						|
          # Fetch main branch for comparison
 | 
						|
          git fetch origin ${{ inputs.main_branch }}
 | 
						|
          
 | 
						|
          # Check if conanfile.txt or conanfile.py has changed compared to main branch
 | 
						|
          if git diff --quiet origin/${{ inputs.main_branch }}..HEAD -- '**/conanfile.txt' '**/conanfile.py'; then
 | 
						|
            echo "should-save-conan-cache=false" >> $GITHUB_OUTPUT
 | 
						|
          else
 | 
						|
            echo "should-save-conan-cache=true" >> $GITHUB_OUTPUT
 | 
						|
          fi
 | 
						|
        fi
 | 
						|
 | 
						|
    - name: Restore Conan cache
 | 
						|
      if: inputs.cache_enabled == 'true'
 | 
						|
      id: cache-restore-conan
 | 
						|
      uses: actions/cache/restore@v4
 | 
						|
      with:
 | 
						|
        path: |
 | 
						|
          ~/.conan
 | 
						|
          ~/.conan2
 | 
						|
        key: ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-${{ inputs.configuration }}
 | 
						|
        restore-keys: |
 | 
						|
          ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-
 | 
						|
          ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
 | 
						|
 | 
						|
    - name: Export custom recipes
 | 
						|
      shell: bash
 | 
						|
      run: |
 | 
						|
        conan export external/snappy --version 1.1.10 --user xahaud --channel stable
 | 
						|
        conan export external/soci --version 4.0.3 --user xahaud --channel stable
 | 
						|
        conan export external/wasmedge --version 0.11.2 --user xahaud --channel stable
 | 
						|
 | 
						|
    - name: Install dependencies
 | 
						|
      shell: bash
 | 
						|
      run: |
 | 
						|
        # Create build directory
 | 
						|
        mkdir -p ${{ inputs.build_dir }}
 | 
						|
        cd ${{ inputs.build_dir }}
 | 
						|
        
 | 
						|
        # Install dependencies using conan
 | 
						|
        conan install \
 | 
						|
          --output-folder . \
 | 
						|
          --build missing \
 | 
						|
          --settings build_type=${{ inputs.configuration }} \
 | 
						|
          ..
 | 
						|
 | 
						|
    - name: Save Conan cache
 | 
						|
      if: always() && inputs.cache_enabled == 'true' && steps.cache-restore-conan.outputs.cache-hit != 'true' && steps.check-conanfile-changes.outputs.should-save-conan-cache == 'true'
 | 
						|
      uses: actions/cache/save@v4
 | 
						|
      with:
 | 
						|
        path: |
 | 
						|
          ~/.conan
 | 
						|
          ~/.conan2
 | 
						|
        key: ${{ steps.cache-restore-conan.outputs.cache-primary-key }}
 |