yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Gangzheng TongEnhances CI reliability and debug logging (#8393)c0d7405d8

master
4.8 KiB127 linesraw
1name: Common Test Setup
2description: "Common setup steps for Slang test jobs"
3
4inputs:
5  os:
6    required: true
7    description: "Operating system"
8  compiler:
9    required: true
10    description: "Compiler to use"
11  platform:
12    required: true
13    description: "Platform to build for"
14  config:
15    required: true
16    description: "Build configuration"
17
18runs:
19  using: "composite"
20  steps:
21    - name: Setup
22      uses: ./.github/actions/common-setup
23      with:
24        os: ${{ inputs.os }}
25        compiler: ${{ inputs.compiler }}
26        platform: ${{ inputs.platform }}
27        config: ${{ inputs.config }}
28        build-llvm: false
29
30    - uses: actions/download-artifact@v4
31      with:
32        name: slang-tests-${{ inputs.os }}-${{ inputs.platform }}-${{ inputs.compiler }}-${{ inputs.config }}
33        path: github_artifact
34
35    - name: Setup environment
36      shell: bash
37      run: |
38        # Artifacts are now directly extracted to github_artifact directory
39        # Just ensure all executables are executable
40        chmod +x github_artifact/${cmake_config}/bin/* 2>/dev/null || echo "No executables to make executable"
41
42        # Set up bin_dir based on platform and config
43        bin_dir=$(pwd)/github_artifact/${cmake_config}/bin
44        echo "bin_dir=$bin_dir" >> $GITHUB_ENV
45
46        # Also set lib_dir for slangpy tests
47        lib_dir=$(pwd)/github_artifact/${cmake_config}/lib
48        echo "lib_dir=$lib_dir" >> $GITHUB_ENV
49
50        # Set up library path for runtime linking
51        if [[ "${{ inputs.os }}" == "linux" ]]; then
52          echo "LD_LIBRARY_PATH=${lib_dir}:$LD_LIBRARY_PATH" >> $GITHUB_ENV
53        elif [[ "${{ inputs.os }}" == "macos" ]]; then
54          echo "DYLD_LIBRARY_PATH=${lib_dir}:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
55        elif [[ "${{ inputs.os }}" == "windows" ]]; then
56          # On Windows, DLLs should be in the same directory as executables or in PATH
57          # Use $GITHUB_PATH instead of $PATH for preservation across steps and
58          # avoid unix-like/windows-like path issues
59          # echo "$bin_dir" >> $GITHUB_PATH
60          # echo "$lib_dir" >> $GITHUB_PATH
61          echo "skipping setting PATH in Windows"
62        fi
63
64        # List directory contents
65        echo "Contents of bin_dir ($bin_dir):"
66        ls -a "$bin_dir" 2>/dev/null || echo "bin_dir not found"
67        echo "Contents of lib_dir ($lib_dir):"
68        ls -a "$lib_dir" 2>/dev/null || echo "lib_dir not found"
69
70    - name: Check runtime environment
71      shell: bash
72      run: |
73        echo "Checking supported backends"
74        # Capture the output of slang-test while also displaying it
75        # Add retry logic for intermittent failures
76        for attempt in 1 2 3; do
77          if smokeResult=$("$bin_dir/slang-test" "tests/render/check-backend-support-on-ci.slang" 2>&1); then
78            break
79          else
80            echo "⚠️  Attempt $attempt failed, retrying..."
81            if [ $attempt -eq 3 ]; then
82              echo "❌ ERROR: slang-test failed to run after 3 attempts"
83              echo "Output: $smokeResult"
84              exit 1
85            fi
86            sleep 2
87          fi
88        done
89        supportedBackends="$(echo "$smokeResult" | grep 'Supported backends: ')"
90        echo "$smokeResult"
91        echo "$supportedBackends"
92
93        # Check if the output contains "llvm" (case-insensitive)
94        if echo "$supportedBackends" | grep -qi "llvm"; then
95          echo "✅ LLVM backend support detected"
96        else
97          echo "❌ ERROR: LLVM backend support not detected - this is required to run the filecheck!"
98        fi
99
100        # Function to check API support
101        check_api_support() {
102          local api_list=("$@")
103          for api in "${api_list[@]}"; do
104            if echo "$smokeResult" | grep -qi "${api}: Supported"; then
105              echo "✅ ${api} API support detected"
106            else
107              echo "❌ ${api} API support not detected"
108              exit 1
109            fi
110          done
111        }
112
113        # Platform-specific API checks - fail if APIs are not available
114        if [[ "${{ inputs.os }}" == "macos" ]]; then
115          check_api_support "mtl,metal"
116        elif [[ "${{ inputs.os }}" == "windows" ]]; then
117          check_api_support "vk,vulkan" "dx12,d3d12" "dx11,d3d11" "cuda"
118
119          echo "Printing CUDA compiler version: ..."
120          nvcc --version || (echo "ERROR: CUDA compiler (nvcc) not available on Windows" && exit 1)
121          echo "Printing GPU driver version: ..."
122          nvidia-smi -q | grep Version || (echo "ERROR: NVIDIA driver (nvidia-smi) not available on Windows" && exit 1)
123          echo "Printing Vulkan SDK version: ..."
124          vulkaninfo | grep -i version || (echo "ERROR: Vulkan SDK (vulkaninfo) not available on Windows" && exit 1)
125        fi        
126        echo "All environment variables:"
127        env | sort