Continuous Integration #291
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Continuous Integration | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: # Nightly build | |
| - cron: "0 0 * * *" | |
| jobs: | |
| build: | |
| name: ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| defaults: | |
| run: | |
| shell: ${{ matrix.config.shell }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: Linux GCC | |
| os: ubuntu-latest | |
| compiler: gcc | |
| shell: bash | |
| suffix: "" | |
| src_package: true | |
| - name: Linux Clang | |
| os: ubuntu-latest | |
| compiler: clang | |
| shell: bash | |
| suffix: "" | |
| - name: MSYS2 MINGW64 | |
| os: windows-latest | |
| compiler: gcc | |
| shell: 'msys2 {0}' | |
| msystem: mingw64 | |
| msys-env: mingw-w64-x86_64 | |
| suffix: "-win64" | |
| - name: MSYS2 MINGW32 | |
| os: windows-latest | |
| compiler: gcc | |
| shell: 'msys2 {0}' | |
| msystem: mingw32 | |
| msys-env: mingw-w64-i686 | |
| suffix: "-win32" | |
| - name: macOS arm64 | |
| os: macos-latest | |
| compiler: clang | |
| shell: bash | |
| suffix: "-macos-arm64" | |
| steps: | |
| - name: Install build dependencies (Chocolatey, Windows) | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: choco install pandoc | |
| - name: Install build dependencies (MSYS, Windows) | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{ matrix.config.msystem }} | |
| path-type: inherit | |
| update: true | |
| install: >- | |
| autotools | |
| base-devel | |
| dos2unix | |
| git | |
| zip | |
| ${{ matrix.config.msys-env}}-gcc | |
| ${{ matrix.config.msys-env}}-python | |
| ${{ matrix.config.msys-env}}-SDL2 | |
| - name: Install build dependencies (Homebrew, macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install -q sdl2 autoconf automake libtool pandoc | |
| - name: Install build dependencies (apt, Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt update | |
| sudo apt -q install libsdl2-dev ${{ matrix.config.compiler }} | |
| - uses: actions/checkout@v6 | |
| - name: Find Git version | |
| id: version | |
| run: | | |
| if git describe --exact-match --tags >/dev/null; then | |
| VERSION=$(git describe --exact-match --tags) | |
| VERSION=${VERSION/#sdl-sopwith-/} | |
| else | |
| VERSION=$(git rev-parse --short HEAD) | |
| VERSION=git-$VERSION | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "SUFFIXED_VERSION=$VERSION${{ matrix.config.suffix }}" >> $GITHUB_OUTPUT | |
| # Patch the version in configure.ac: | |
| sed -i.old "s/\(AC_INIT([^,]*, \)\[[^]]*\], /\1[$VERSION], /" \ | |
| configure.ac | |
| - name: autogen | |
| env: | |
| CC: ${{ matrix.config.compiler }} | |
| run: | | |
| ./autogen.sh | |
| - name: make | |
| run: make -j8 | |
| - name: make check | |
| run: make check | |
| - name: autotools distcheck | |
| if: ${{ matrix.config.src_package }} | |
| run: | | |
| # This checks we can go through the entire process of generating | |
| # a distribution package with autotools, and that the package can | |
| # be built and installed successfully. | |
| make -j8 distcheck | |
| - name: Build source package | |
| if: ${{ matrix.config.src_package }} | |
| run: | | |
| make dist | |
| mkdir srcdist | |
| mv *.tar.gz srcdist/ | |
| - name: Build package (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cd pkg/win32 | |
| make | |
| - name: Upload source package | |
| if: ${{ matrix.config.src_package }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| path: "srcdist" | |
| name: sdl-sopwith-src-${{steps.version.outputs.VERSION}} | |
| - name: Upload build (Windows) | |
| if: runner.os == 'Windows' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| path: "pkg/win32/staging" | |
| name: sdl-sopwith-${{steps.version.outputs.SUFFIXED_VERSION}} | |
| check_style_etc: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt -q install clang-format | |
| - uses: actions/checkout@v6 | |
| - name: Check formatting | |
| if: '!cancelled()' | |
| run: | | |
| clang-format -i {src,src/sdl}/*.[ch] | |
| git diff > formatting-fixes.diff | |
| if ! grep "" formatting-fixes.diff; then | |
| rm -f formatting-fixes.diff | |
| else | |
| (echo "Formatting errors detected by clang-format. Please run" \ | |
| "\`make format\` or apply formatting-fixes.diff below."; | |
| echo) >> $GITHUB_STEP_SUMMARY | |
| false | |
| fi | |
| - uses: actions/upload-artifact@v6 | |
| if: '!cancelled()' | |
| with: | |
| if-no-files-found: ignore | |
| name: formatting-fixes.diff | |
| path: formatting-fixes.diff |