yum-mirror/slang

Making it easier to work with shaders

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

Yong HeRe-enable slangpy test_blit.py::test_generate_mips for CUDA. (#8740)74d93c0fe

master
8.0 KiB224 linesraw
1name: CI Test Workflow
2
3on:
4  workflow_call:
5    inputs:
6      os:
7        required: true
8        type: string
9      compiler:
10        required: true
11        type: string
12      platform:
13        required: true
14        type: string
15      config:
16        required: true
17        type: string
18      runs-on:
19        required: true
20        type: string
21      test-category:
22        required: false
23        type: string
24        default: smoke
25      full-gpu-tests:
26        required: false
27        type: boolean
28        default: false
29      server-count:
30        required: false
31        type: number
32        default: 8
33      enable-debug-layers:
34        required: false
35        type: boolean
36        default: true
37
38jobs:
39  test-slang:
40    runs-on: ${{ fromJSON(inputs.runs-on) }}
41    timeout-minutes: 30
42    defaults:
43      run:
44        shell: bash
45
46    steps:
47      - uses: actions/checkout@v4
48
49      - name: Common Test Setup
50        uses: ./.github/actions/common-test-setup
51        with:
52          os: ${{ inputs.os }}
53          compiler: ${{ inputs.compiler }}
54          platform: ${{ inputs.platform }}
55          config: ${{ inputs.config }}
56
57      - name: Test Slang
58        run: |
59          export SLANG_RUN_SPIRV_VALIDATION=1
60          export SLANG_USE_SPV_SOURCE_LANGUAGE_UNKNOWN=1
61          if [ "${{ inputs.enable-debug-layers }}" == "true" ]; then
62            export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
63          fi
64          # Build common slang-test arguments
65          slang_test_args=(
66            "-category" "${{ inputs.test-category }}"
67            "-expected-failure-list" "tests/expected-failure-github.txt"
68            "-skip-reference-image-generation"
69            "-show-adapter-info"
70            "-ignore-abort-msg"
71            "-enable-debug-layers" "${{ inputs.enable-debug-layers }}"
72          )
73
74          # Add test server arguments only if server count > 1
75          if [ "${{ inputs.server-count }}" -gt 1 ]; then
76            slang_test_args+=("-use-test-server")
77            slang_test_args+=("-server-count" "${{ inputs.server-count }}")
78          fi
79
80          # Add no-GPU failure list for non-GPU tests
81          if [[ "${{ inputs.full-gpu-tests }}" != "true" ]]; then
82            slang_test_args+=("-expected-failure-list" "tests/expected-failure-no-gpu.txt")
83          fi
84
85          # Execute slang-test with all arguments
86          "$bin_dir/slang-test" "${slang_test_args[@]}"
87      - name: Run Slang examples
88        # Run GLSL backend tests on release for pull requests, and not on merge_group, to reduce CI load.
89        if: inputs.full-gpu-tests && inputs.config == 'release' && github.event_name == 'pull_request'
90        run: |
91          .github/workflows/ci-examples.sh \
92           --bin-dir "$bin_dir" \
93           --os "${{ inputs.os }}" \
94           --platform "${{ inputs.platform }}" \
95           --config "${{ inputs.config }}" \
96           --skip-file tests/expected-example-failure-github.txt
97      - name: Run slangc tests
98        run: |
99          PATH=$bin_dir:$PATH tools/slangc-test/test.sh
100      - name: Test Slang via glsl
101        # Run GLSL backend tests on release for pull requests, and not on merge_group, to reduce CI load.
102        if: inputs.os != 'macos' && inputs.full-gpu-tests && inputs.config == 'release' && github.event_name == 'pull_request'
103        run: |
104          export SLANG_RUN_SPIRV_VALIDATION=1
105          export SLANG_USE_SPV_SOURCE_LANGUAGE_UNKNOWN=1
106          "$bin_dir/slang-test" \
107            -use-test-server \
108            -server-count ${{ inputs.server-count }} \
109            -category ${{ inputs.test-category }} \
110            -emit-spirv-via-glsl \
111            -ignore-abort-msg \
112            -api vk \
113            -expected-failure-list tests/expected-failure-via-glsl.txt \
114            -skip-reference-image-generation
115
116  # Run slang-rhi tests when:
117  # 1. full-gpu-tests is enabled AND
118  # 2. Either it's a pull request OR config is release
119  # This is to reduce the CI load but do some check on pull requests.
120  # expensive slang-rhi tests are excluded with -tce option, because they are not relevant for Slang.
121  test-slang-rhi:
122    runs-on: ${{ fromJSON(inputs.runs-on) }}
123    timeout-minutes: 30
124    if: inputs.full-gpu-tests && (github.event_name == 'pull_request' || inputs.config == 'release')
125    defaults:
126      run:
127        shell: bash
128
129    steps:
130      - uses: actions/checkout@v4
131        with:
132          submodules: "recursive"
133          fetch-depth: "1"
134
135      - name: Common Test Setup
136        uses: ./.github/actions/common-test-setup
137        with:
138          os: ${{ inputs.os }}
139          compiler: ${{ inputs.compiler }}
140          platform: ${{ inputs.platform }}
141          config: ${{ inputs.config }}
142
143      - name: Run slang-rhi tests
144        run: |
145          export SLANG_RHI_EXCLUDE_TESTS="md-clear*,cmd-copy*,cmd-upload*,fence*,staging-heap*,texture-create*"
146          "$bin_dir/slang-rhi-tests" -check-devices -tce="$SLANG_RHI_EXCLUDE_TESTS"
147
148      - name: Run slang-rhi tests (OptiX 8.0)
149        if: inputs.os == 'windows' || inputs.os == 'linux'
150        run: |
151          "$bin_dir/slang-rhi-tests" -check-devices -optix-version=80000 -tc="ray-tracing-*.cuda"
152
153      - name: Run slang-rhi tests (OptiX 8.1)
154        if: inputs.os == 'windows' || inputs.os == 'linux'
155        run: |
156          "$bin_dir/slang-rhi-tests" -check-devices -optix-version=80100 -tc="ray-tracing-*.cuda"
157
158  # Run slangpy tests when:
159  # 1. full-gpu-tests is enabled AND
160  # 2. Either it's a pull request OR config is release
161  # This is to reduce the CI load but do some check on pull requests.
162  test-slangpy:
163    runs-on: ${{ fromJSON(inputs.runs-on) }}
164    timeout-minutes: 30
165    if: inputs.full-gpu-tests && (github.event_name == 'pull_request' || inputs.config == 'release')
166    defaults:
167      run:
168        shell: bash
169
170    steps:
171      - uses: actions/checkout@v4
172
173      - name: Common Test Setup
174        uses: ./.github/actions/common-test-setup
175        with:
176          os: ${{ inputs.os }}
177          compiler: ${{ inputs.compiler }}
178          platform: ${{ inputs.platform }}
179          config: ${{ inputs.config }}
180
181      - name: Setup Python
182        if: ${{ runner.environment != 'self-hosted' }}
183        uses: actions/setup-python@v5
184        with:
185          python-version: "3.10"
186
187      - name: Run slangpy tests
188        run: |
189          python --version
190          echo "Cleaning up existing installations and installing slangpy..."
191
192          # Try to uninstall existing slangpy
193          python -m pip uninstall -y slangpy || echo "slangpy not found or already removed"
194
195          # Install slangpy
196          python -m pip install --verbose slangpy --user
197
198          # Get site packages directory
199          SITE_PACKAGES=$(python -c "import slangpy; import os; print(os.path.dirname(os.path.dirname(slangpy.__file__)))" | tail -n 1)
200          echo "Site packages directory: $SITE_PACKAGES"
201          echo "bin_dir location: $bin_dir"
202          echo "lib_dir location: $lib_dir"
203          # Copy library files
204          if [[ "${{ inputs.os }}" == "windows" ]]; then
205            cp "$bin_dir"/slang*.dll "$SITE_PACKAGES/slangpy/" || { echo "Failed to copy library files"; exit 1; }
206          else
207            cp "$lib_dir"/libslang*.* "$SITE_PACKAGES/slangpy/" || { echo "Failed to copy library files"; exit 1; }
208          fi
209
210          echo "Listing files in slangpy directory..."
211          ls -la "$SITE_PACKAGES/slangpy/"
212
213          # Skip package installation on self-hosted runners to avoid permission issues
214          if [[ ! "${{ inputs.runs-on }}" =~ self-hosted ]]; then
215            echo "Installing python packages..."
216            curl -fsSL https://raw.githubusercontent.com/shader-slang/slangpy/main/requirements-dev.txt -o requirements-dev.txt
217            python -m pip install -r requirements-dev.txt --user
218            python -m pip install pytest-github-actions-annotate-failures --user
219            python -m pip install pytest-xdist --user
220          fi
221
222          echo "Running pytest on slangpy tests..."
223          export PYTHONPATH="$SITE_PACKAGES"
224          python -m pytest "$SITE_PACKAGES/slangpy/tests" -ra -n auto --maxprocesses=3