1name: LLVM Project Tests
2
3on:
4  workflow_dispatch:
5    inputs:
6      build_target:
7        required: false
8      projects:
9        required: false
10  workflow_call:
11    inputs:
12      build_target:
13        required: true
14        type: string
15
16      projects:
17        required: true
18        type: string
19
20concurrency:
21  # Skip intermediate builds: always.
22  # Cancel intermediate builds: only if it is a pull request build.
23  # If the group name here is the same as the group name in the workflow that includes
24  # this one, then the action will try to wait on itself and get stuck.
25  group: llvm-project-${{ github.workflow }}-${{ inputs.projects}}${{ github.ref }}
26  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
27
28jobs:
29  lit-tests:
30    name: Lit Tests
31    runs-on: ${{ matrix.os }}
32    strategy:
33      fail-fast: false
34      matrix:
35        os:
36          - ubuntu-latest
37          # Use windows-2019 due to:
38          # https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
39          - windows-2019
40          # We're using a specific version of macOS due to:
41          # https://github.com/actions/virtual-environments/issues/5900
42          - macOS-11
43    steps:
44      - name: Setup Windows
45        if: startsWith(matrix.os, 'windows')
46        uses: llvm/actions/setup-windows@main
47        with:
48          arch: amd64
49      # On Windows, starting with win19/20220814.1, cmake choose the 32-bit
50      # python3.10.6 libraries instead of the 64-bit libraries when building
51      # lldb.  Using this setup-python action to make 3.10 the default
52      # python fixes this.
53      - name: Setup Python
54        uses: actions/setup-python@v4
55        with:
56          python-version: '3.10'
57      - name: Install Ninja
58        uses: llvm/actions/install-ninja@main
59      # actions/checkout deletes any existing files in the new git directory,
60      # so this needs to either run before ccache-action or it has to use
61      # clean: false.
62      - uses: actions/checkout@v3
63        with:
64          fetch-depth: 250
65      - name: Setup ccache
66        uses: hendrikmuhs/ccache-action@v1.2
67        with:
68          # A full build of llvm, clang, lld, and lldb takes about 250MB
69          # of ccache space. There's not much reason to have more than this,
70          # because we usually won't need to save cache entries from older
71          # builds.  Also, there is an overall 10GB cache limit, and each
72          # run creates a new cache entry so we want to ensure that we have
73          # enough cache space for all the tests to run at once and still
74          # fit under the 10 GB limit.
75          max-size: 500M
76          key: sccache-${{ matrix.os }}
77          variant: sccache
78      - name: Build and Test
79        uses: llvm/actions/build-test-llvm-project@main
80        env:
81          # Workaround for https://github.com/actions/virtual-environments/issues/5900.
82          # This should be a no-op for non-mac OSes
83          PKG_CONFIG_PATH: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
84        with:
85          cmake_args: '-GNinja -DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" -DCMAKE_BUILD_TYPE=Release -DLLDB_INCLUDE_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache'
86          build_target:  '${{ inputs.build_target }}'
87
88      - name: Build and Test libclc
89        if: "!startsWith(matrix.os, 'windows') && contains(inputs.projects, 'libclc')"
90        run: |
91          # Make sure all of LLVM libraries that llvm-config needs are built.
92          ninja -C build
93          cmake -G Ninja -S libclc -B libclc-build -DLLVM_CONFIG=`pwd`/build/bin/llvm-config -DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl"
94          ninja -C libclc-build
95          ninja -C libclc-build test
96