shithub: rgbds

ref: d569c6392c98a5f3037814add1f03a0dc149a86e
dir: /.github/workflows/testing.yml/

View raw version
name: "Regression testing"
on:
  - push
  - pull_request

jobs:
  unix-testing:
    strategy:
      matrix:
        os: [ubuntu-20.04, ubuntu-18.04, macos-11.0, macos-10.15]
        cc: [gcc, clang]
        buildsys: [make, cmake]
        exclude:
          # `gcc` is just an alias to `clang` on macOS, don't bother
          - os: macos-10.15
            cc: gcc
          - os: macos-11.0
            cc: gcc
        include:
          - cc: gcc
            cxx: g++
          - cc: clang
            cxx: clang++
      fail-fast: false
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - name: Install deps
        shell: bash
        run: |
          ./.github/actions/install_deps.sh ${{ matrix.os }}
      # The `export` lines are to allow working on macOS...
      # Apple's base version is severely outdated, not even supporting -Wall,
      # but it overrides Homebrew's version nonetheless...
      - name: Build & install using Make
        run: |
          export PATH="/usr/local/opt/bison/bin:$PATH"
          make develop -j Q= CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
          sudo make install -j Q=
        if: matrix.buildsys == 'make'
      - name: Build & install using CMake
        run: |
          export PATH="/usr/local/opt/bison/bin:$PATH"
          cmake -S . -B build -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DSANITIZERS=ON -DMORE_WARNINGS=ON
          cmake --build build -j
          cp build/src/rgb{asm,link,fix,gfx} .
          sudo cmake --install build
        if: matrix.buildsys == 'cmake'
      - name: Package binaries
        run: |
          mkdir bins
          cp rgb{asm,link,fix,gfx} bins
      - name: Upload binaries
        uses: actions/upload-artifact@v1
        with:
          name: rgbds-canary-${{ matrix.os }}-${{ matrix.cc }}-${{ matrix.buildsys }}
          path: bins
      - name: Test
        shell: bash
        run: |
          test/run-tests.sh

  windows-testing:
    strategy:
      matrix:
        bits: [32, 64]
        include:
          - bits: 32
            arch: x86
            platform: Win32
          - bits: 64
            arch: x86_x64
            platform: x64
      fail-fast: false
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v2
      - name: Get zlib, libpng and bison
        run: | # TODO: use an array; remember to update the versions being downloaded, *and* the paths being extracted! (`Move-Item`)
          $wc = New-Object System.Net.WebClient
          $wc.DownloadFile('https://www.zlib.net/zlib1212.zip', 'zlib.zip')
          $hash = (Get-FileHash "zlib.zip" -Algorithm SHA256).Hash
          if ($hash -ne '173e89893dcb8b4a150d7731cd72f0602f1d6b45e60e2a54efdf7f3fc3325fd7') {
            Write-Host "zlib SHA256 mismatch! ($hash)"
            exit 1
          }
          $wc.DownloadFile('https://download.sourceforge.net/libpng/lpng1637.zip', 'libpng.zip')
          $hash = (Get-FileHash "libpng.zip" -Algorithm SHA256).Hash
          if ($hash -ne '3b4b1cbd0bae6822f749d39b1ccadd6297f05e2b85a83dd2ce6ecd7d09eabdf2') {
            Write-Host "libpng SHA256 mismatch! ($hash)"
            exit 1
          }
          $wc.DownloadFile('https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip', 'winflexbison.zip')
          $hash = (Get-FileHash "winflexbison.zip" -Algorithm SHA256).Hash
          if ($hash -ne '39c6086ce211d5415500acc5ed2d8939861ca1696aee48909c7f6daf5122b505') {
            Write-Host "bison SHA256 mismatch! ($hash)"
          }
          Expand-Archive -DestinationPath .           "zlib.zip"
          Expand-Archive -DestinationPath .           "libpng.zip"
          Expand-Archive -DestinationPath install_dir "winflexbison.zip"
          Move-Item zlib-1.2.12 zlib
          Move-Item lpng1637 libpng
      - uses: actions/cache@v3
        id: cache
        with:
          path: |
            zbuild
            pngbuild
          key: ${{ matrix.arch }}-${{ hashFiles('zlib/**', 'libpng/**') }}
      - name: Build zlib
        run: | # BUILD_SHARED_LIBS causes the output DLL to be correctly called `zlib1.dll`
          cmake -S zlib -B zbuild -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DBUILD_SHARED_LIBS=ON
          cmake --build zbuild --config Release -j
        if: steps.cache.outputs.cache-hit != 'true'
      - name: Install zlib
        run: |
          cmake --install zbuild
      - name: Build libpng
        run: |
          cmake -S libpng -B pngbuild -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DPNG_SHARED=ON -DPNG_STATIC=ON -DPNG_TESTS=OFF
          cmake --build pngbuild --config Release -j
        if: steps.cache.outputs.cache-hit != 'true'
      - name: Install libpng
        run: |
          cmake --install pngbuild
      - name: Build Windows binaries
        run: |
          cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Release
          cmake --build build --config Release -j
          cmake --install build
      - name: Package binaries
        shell: bash
        run: |
          mkdir bins
          cp install_dir/bin/{rgbasm.exe,rgblink.exe,rgbfix.exe,rgbgfx.exe,zlib1.dll,libpng16.dll} bins
      - name: Upload Windows binaries
        uses: actions/upload-artifact@v1
        with:
          name: rgbds-canary-win${{ matrix.bits }}
          path: bins
      - name: Test
        shell: bash
        run: |
          cp bins/* .
          test/run-tests.sh

  windows-xbuild:
    strategy:
      matrix:
        bits: [32, 64]
        os: [ubuntu-18.04]
        include:
          - bits: 32
            arch: i686
            triplet: i686-w64-mingw32
          - bits: 64
            arch: x86-64
            triplet: x86_64-w64-mingw32
      fail-fast: false
    runs-on: ${{ matrix.os }}
    env:
      DIST_DIR: win${{ matrix.bits }}
    steps:
      - uses: actions/checkout@v2
      - name: Install deps
        shell: bash
        run: |
          ./.github/actions/install_deps.sh ${{ matrix.os }}
      - name: Install MinGW
        run: |
          sudo apt-get install {gcc,g++}-mingw-w64-${{ matrix.arch }} mingw-w64-tools libz-mingw-w64-dev
      - name: Install libpng dev headers for MinGW
        run: |
          sudo ./.github/actions/mingw-w64-libpng-dev.sh ${{ matrix.triplet }}
      - name: Cross-build Windows binaries
        run: |
          make mingw${{ matrix.bits }} -j Q=
      - name: Package binaries
        run: |
          mkdir bins
          mv rgbasm bins/rgbasm.exe
          mv rgblink bins/rgblink.exe
          mv rgbfix bins/rgbfix.exe
          mv rgbgfx bins/rgbgfx.exe
          cp /usr/${{ matrix.triplet }}/lib/zlib1.dll bins
          cp /usr/${{ matrix.triplet }}/bin/libpng16-16.dll bins
          if [ ${{ matrix.bits }} -eq 32 ]; then cp /usr/lib/gcc/${{ matrix.triplet }}/7.3-win32/lib{gcc_s_sjlj-1,stdc++-6}.dll bins; fi
      - name: Upload Windows binaries
        uses: actions/upload-artifact@v1
        with:
          name: rgbds-canary-mingw-win${{ matrix.bits }}
          path: bins

  windows-xtesting:
    needs: windows-xbuild
    strategy:
      matrix:
        bits: [32, 64]
      fail-fast: false
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v2
      - name: Retrieve binaries
        uses: actions/download-artifact@v1
        with:
          name: rgbds-canary-mingw-win${{ matrix.bits }}
          path: bins
      - name: Extract binaries
        shell: bash
        run: |
          cp bins/* .
      - name: Run tests
        shell: bash
        run: |
          test/run-tests.sh