xref: /llvm-project/.github/workflows/llvm-project-tests.yml (revision a75917679549109fcbf92cb63ef61638517713d6)
1name: LLVM Project Tests
2
3permissions:
4  contents: read
5
6on:
7  workflow_dispatch:
8    inputs:
9      build_target:
10        required: false
11      projects:
12        required: false
13      extra_cmake_args:
14        required: false
15      os_list:
16        required: false
17        default: '["ubuntu-latest", "windows-2019", "macOS-13"]'
18      python_version:
19        required: false
20        type: string
21        default: '3.11'
22  workflow_call:
23    inputs:
24      build_target:
25        required: false
26        type: string
27        default: "all"
28
29      projects:
30        required: true
31        type: string
32
33      extra_cmake_args:
34        required: false
35        type: string
36
37      os_list:
38        required: false
39        type: string
40        # Use windows-2019 due to:
41        # https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
42        # Use ubuntu-22.04 rather than ubuntu-latest to match the ubuntu
43        # version in the CI container. Without this, setup-python tries
44        # to install a python version linked against a newer version of glibc.
45        # TODO(boomanaiden154): Bump the Ubuntu version once the version in the
46        # container is bumped.
47        default: '["ubuntu-22.04", "windows-2019", "macOS-13"]'
48
49      python_version:
50        required: false
51        type: string
52        default: '3.11'
53
54concurrency:
55  # Skip intermediate builds: always.
56  # Cancel intermediate builds: only if it is a pull request build.
57  # If the group name here is the same as the group name in the workflow that includes
58  # this one, then the action will try to wait on itself and get stuck.
59  group: llvm-project-${{ github.workflow }}-${{ inputs.projects }}-${{ inputs.python_version }}${{ github.ref }}
60  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
61
62jobs:
63  lit-tests:
64    name: Lit Tests
65    runs-on: ${{ matrix.os }}
66    container:
67      image: ${{(startsWith(matrix.os, 'ubuntu') && 'ghcr.io/llvm/ci-ubuntu-22.04:latest') || null}}
68      volumes:
69        - /mnt/:/mnt/
70    strategy:
71      fail-fast: false
72      matrix:
73        os: ${{ fromJSON(inputs.os_list) }}
74    steps:
75      - name: Setup Windows
76        if: startsWith(matrix.os, 'windows')
77        uses: llvm/actions/setup-windows@main
78        with:
79          arch: amd64
80      # On Windows, starting with win19/20220814.1, cmake choose the 32-bit
81      # python3.10.6 libraries instead of the 64-bit libraries when building
82      # lldb.  Using this setup-python action to make 3.10 the default
83      # python fixes this.
84      - name: Setup Python
85        uses: actions/setup-python@v5
86        with:
87          python-version: ${{ inputs.python_version }}
88      - name: Install Ninja
89        if: runner.os != 'Linux'
90        uses: llvm/actions/install-ninja@main
91      # actions/checkout deletes any existing files in the new git directory,
92      # so this needs to either run before ccache-action or it has to use
93      # clean: false.
94      - uses: actions/checkout@v4
95        with:
96          fetch-depth: 250
97      - name: Setup ccache
98        uses: hendrikmuhs/ccache-action@v1
99        with:
100          # A full build of llvm, clang, lld, and lldb takes about 250MB
101          # of ccache space. There's not much reason to have more than this,
102          # because we usually won't need to save cache entries from older
103          # builds.  Also, there is an overall 10GB cache limit, and each
104          # run creates a new cache entry so we want to ensure that we have
105          # enough cache space for all the tests to run at once and still
106          # fit under the 10 GB limit.
107          # Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
108          max-size: 2G
109          key: ${{ matrix.os }}
110          variant: sccache
111      - name: Build and Test
112        env:
113          # Workaround for https://github.com/actions/virtual-environments/issues/5900.
114          # This should be a no-op for non-mac OSes
115          PKG_CONFIG_PATH: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
116        shell: bash
117        id: build-llvm
118        run: |
119          if [ "${{ runner.os }}" == "Linux" ]; then
120            builddir="/mnt/build/"
121            sudo mkdir -p $builddir
122            sudo chown gha $builddir
123            extra_cmake_args="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
124          else
125            builddir="$(pwd)"/build
126          fi
127          if [ "${{ runner.os }}" == "macOS" ]; then
128            # Workaround test failure on some lld tests on MacOS
129            # https://github.com/llvm/llvm-project/issues/81967
130            extra_cmake_args="-DLLVM_DISABLE_ASSEMBLY_FILES=ON"
131          fi
132          echo "llvm-builddir=$builddir" >> "$GITHUB_OUTPUT"
133          cmake -G Ninja \
134                -B "$builddir" \
135                -S llvm \
136                -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" \
137                -DCMAKE_BUILD_TYPE=Release \
138                -DLLVM_ENABLE_ASSERTIONS=ON \
139                -DLLDB_INCLUDE_TESTS=OFF \
140                -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" \
141                -DCMAKE_C_COMPILER_LAUNCHER=sccache \
142                -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
143                $extra_cmake_args \
144                ${{ inputs.extra_cmake_args }}
145          ninja -C "$builddir" '${{ inputs.build_target }}'
146
147      - name: Build and Test libclc
148        if: "!startsWith(matrix.os, 'windows') && contains(inputs.projects, 'libclc')"
149        env:
150          LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }}
151        run: |
152          # The libclc tests don't have a generated check target so all we can
153          # do is build it.
154          ninja -C "$LLVM_BUILDDIR"
155