aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/.github/workflows/example_toolsets.yml
blob: 9c08b3d13d888f74b526d156a272c6841eca896f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                


                                                          
                                                       


                               
                                                  
                                                  
                                             



























                                                             
                                     

                                                  



                                                                             
                                            
                                              










                                                                              
                                 

                           
                                         





                                                

                           


                                     



                                      
                                            
                                                                                      



                                        
                                            




                                                                     
                                            













































                                                                              
name: Examples (toolsets)

on:
  push:
  pull_request:
  schedule:
    # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen).
    - cron: '30 5 * * 6'
  workflow_dispatch:

jobs:
  build:
    strategy:
      matrix:
        example: [simple, static, dynamic]
        toolset: [auto, clang, clang-cl, gcc, mingw, msvc]
        os: [ubuntu-latest, windows-2019, windows-2022]

        include:
          # Prettier run names.
          - {os: windows-2022, name: Windows 2022}
          - {os: windows-2019, name: Windows 2019}
          - {os: ubuntu-latest, name: Ubuntu}
          # Target platform.
          - {example: simple, platform: x64}
          - {example: static, platform: x86}
          - {example: dynamic, platform: x64}
          # Configuration.
          - {example: simple, configuration: Release}
          - {example: static, configuration: Debug}
          - {example: dynamic, configuration: RelWithDebInfo}
          # Expected symbols.
          - example: simple
            symbols:
              - target: foo
                type: exe
                symbols: []
          - example: static
            symbols:
              - target: foo
                type: exe
                symbols: [main, bar]
          - example: dynamic
            symbols:
              - target: foo
                type: exe
                symbols: [main]
              - target: baz
                type: dll
                symbols: [baz]
        exclude:
          # Ubuntu: no MSVC/clang-cl.
          - {os: ubuntu-latest, toolset: msvc}
          - {os: ubuntu-latest, toolset: clang-cl}
          # Optimization: MinGW-w64 should be the same on different Windows
          # versions.  Clang on the other hand relies on the Microsoft linker
          # (at least it did at some point), so it makes sense to test it
          # against different Visual Studio versions.
          - {os: windows-2019, toolset: gcc}
          - {os: windows-2019, toolset: mingw}

    runs-on: '${{ matrix.os }}'

    name: '${{ matrix.example }} / ${{ matrix.toolset }} / ${{ matrix.name }}'

    defaults:
      run:
        shell: pwsh

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Clean up PATH
        uses: egor-tensin/cleanup-path@v3
        if: runner.os == 'Windows'

      - name: Set common variables
        uses: ./.github/actions/common-variables
        with:
          toolset: '${{ matrix.toolset }}'

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install GCC
        uses: egor-tensin/setup-gcc@v1
        with:
          platform: '${{ matrix.platform }}'
        if: env.CI_HOST_LINUX && (matrix.toolset == 'auto' || matrix.toolset == 'gcc')

      - name: Install Clang
        uses: egor-tensin/setup-clang@v1
        with:
          platform: '${{ matrix.platform }}'
        if: matrix.toolset == 'clang' || matrix.toolset == 'clang-cl'

      - name: Install MinGW
        uses: egor-tensin/setup-mingw@v2
        with:
          platform: '${{ matrix.platform }}'
        # toolset == 'clang' needs some kind of make, e.g. mingw32-make:
        if: env.CI_MINGW || (matrix.toolset == 'clang' && env.CI_HOST_WINDOWS)

      - name: Set up software environment
        uses: ./.github/actions/software-environment
        with:
          toolset: '${{ matrix.toolset }}'
          platform: '${{ matrix.platform }}'

      - name: Set up Visual Studio
        uses: egor-tensin/vs-shell@v2
        with:
          arch: '${{ matrix.platform }}'
        if: matrix.toolset == 'clang-cl' && env.CI_HOST_WINDOWS

      - name: Build example project
        id: build
        uses: ./.github/actions/build-example
        with:
          src-dir: 'examples/${{ matrix.example }}'
          toolset: '${{ matrix.toolset }}'
          platform: '${{ matrix.platform }}'
          configuration: '${{ matrix.configuration }}'

      - name: Verify runtime library linkage
        uses: ./.github/actions/check-runtime-library
        with:
          path: '${{ steps.build.outputs.install-dir }}'

      - name: Verify architecture
        uses: ./.github/actions/check-arch
        with:
          path: '${{ steps.build.outputs.install-dir }}'
          expected: '${{ matrix.platform }}'

      - name: Run example project
        uses: ./.github/actions/run-example
        with:
          path: '${{ steps.build.outputs.install-dir }}'

      - name: Check symbols
        uses: ./.github/actions/check-symbols
        with:
          path: '${{ steps.build.outputs.install-dir }}'
          expected: '${{ toJson(matrix.symbols) }}'
        if: env.CI_TARGET_ELF