From 85b9debde2a035bbd78d48fd47fc7576ad1fc7cf Mon Sep 17 00:00:00 2001 From: rpljwi <46608177+rpljwi@users.noreply.github.com> Date: Sat, 30 May 2020 23:14:33 +0300 Subject: [PATCH] add Github CI --- .github/workflows/build.sh | 36 ++++++++++++++ .github/workflows/github_ci.yml | 80 +++++++++++++++++++++++++++++++ .github/workflows/install_deps.sh | 40 ++++++++++++++++ .github/workflows/test_simple.sh | 5 ++ 4 files changed, 161 insertions(+) create mode 100755 .github/workflows/build.sh create mode 100644 .github/workflows/github_ci.yml create mode 100755 .github/workflows/install_deps.sh create mode 100755 .github/workflows/test_simple.sh diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh new file mode 100755 index 00000000..7184753f --- /dev/null +++ b/.github/workflows/build.sh @@ -0,0 +1,36 @@ +set -e o pipefail +source .github/workflows/gh_ci_envvars.sh + + +GH_MYMAKE_ARGS="" +GH_AUTOTOOLS_CXXFLAGS="-W -Wall -Wextra -Wno-unused-parameter -Wno-maybe-uninitialized" + +HYPERROGUE_USE_GLEW=$GH_HYP_GLEW +export HYPERROGUE_USE_GLEW=${HYPERROGUE_USE_GLEW: -1} + +HYPERROGUE_USE_PNG=$GH_HYP_PNG +export HYPERROGUE_USE_PNG=${HYPERROGUE_USE_PNG: -1} + +HYPERROGUE_USE_ROGUEVIZ=$GH_HYP_RVIZ +export HYPERROGUE_USE_ROGUEVIZ=${HYPERROGUE_USE_ROGUEVIZ: -1} +if [[ "$GH_HYP_RVIZ" == "rviz_1" ]]; then + GH_MYMAKE_ARGS+=" -rv" + GH_AUTOTOOLS_CXXFLAGS+=" -DCAP_ROGUEVIZ=1" +fi + +export CC=$GH_COMPILER +export CXX=${CC%cc}++ + +if [[ "$GH_BUILDSYS" == "makefile" ]]; then + make -f Makefile.simple +elif [[ "$GH_BUILDSYS" == "autotools" ]]; then + autoreconf -vfi + ./configure CXXFLAGS="${GH_AUTOTOOLS_CXXFLAGS}" + make +elif [[ "$GH_BUILDSYS" == "mymake" ]]; then + make -f Makefile.simple mymake + ./mymake $GH_MYMAKE_ARGS + mv hyper hyperrogue +else + exit 'unknown build system' +fi diff --git a/.github/workflows/github_ci.yml b/.github/workflows/github_ci.yml new file mode 100644 index 00000000..5affa528 --- /dev/null +++ b/.github/workflows/github_ci.yml @@ -0,0 +1,80 @@ +name: Github CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + main_matrix: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + compiler: [gcc, clang] + build_system: [makefile, autotools, mymake] + hyper_use_rviz: [rviz_1, rviz_0] + hyper_use_png: [png_1] + hyper_use_glew: [glew_1] + steps: + - uses: actions/checkout@v2 + - name: envvars_setup + run: | + cat << ENDOFVARS > .github/workflows/gh_ci_envvars.sh + GH_OS=${{ matrix.os }} + GH_COMPILER=${{ matrix.compiler }} + GH_BUILDSYS=${{ matrix.build_system }} + GH_HYP_RVIZ=${{ matrix.hyper_use_rviz }} + GH_HYP_PNG=${{ matrix.hyper_use_png }} + GH_HYP_GLEW=${{ matrix.hyper_use_glew }} + ENDOFVARS + - name: install_deps + run: .github/workflows/install_deps.sh + - name: build + run: .github/workflows/build.sh + - name: test_simple + run: .github/workflows/test_simple.sh + + windows: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest] + compiler: [gcc] + build_system: [makefile, autotools] + hyper_use_rviz: [rviz_1, rviz_0] + hyper_use_png: [png_1] + hyper_use_glew: [glew_1] + steps: + - uses: actions/checkout@v2 + - name: envvars_setup + shell: cmd.exe /D /E:ON /V:OFF /C "C:\msys64\msys2_shell.cmd -defterm -msys2 -no-start -full-path -here {0}" + run: | + cat << ENDOFVARS > .github/workflows/gh_ci_envvars.sh + GH_OS=${{ matrix.os }} + GH_COMPILER=${{ matrix.compiler }} + GH_BUILDSYS=${{ matrix.build_system }} + GH_HYP_RVIZ=${{ matrix.hyper_use_rviz }} + GH_HYP_PNG=${{ matrix.hyper_use_png }} + GH_HYP_GLEW=${{ matrix.hyper_use_glew }} + ENDOFVARS + - name: install_deps + run: cmd.exe /D /E:ON /V:OFF /C "C:\msys64\msys2_shell.cmd -defterm -msys2 -no-start -full-path -here .github/workflows/install_deps.sh" + - name: build + run: cmd.exe /D /E:ON /V:OFF /C "C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here .github/workflows/build.sh" + - name: test_simple + run: cmd.exe /D /E:ON /V:OFF /C "C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here .github/workflows/test_simple.sh" + + emscripten: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: build + run: | + docker run --rm -v $(pwd):/src trzeci/emscripten make -f Makefile.simple emscripten + - name: test_simple + run: | + ls -lAF hyper.html hyper.js hyper.wasm diff --git a/.github/workflows/install_deps.sh b/.github/workflows/install_deps.sh new file mode 100755 index 00000000..35ca0e7d --- /dev/null +++ b/.github/workflows/install_deps.sh @@ -0,0 +1,40 @@ +set -e o pipefail +source .github/workflows/gh_ci_envvars.sh + + +GH_DEPS_UBUNTU="$GH_COMPILER libsdl1.2-dev libsdl-ttf2.0-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev" +GH_DEPS_MACOS="sdl sdl_gfx sdl_mixer sdl_ttf" +GH_DEPS_MINGW64="$GH_COMPILER:x SDL:x SDL_ttf:x SDL_gfx:x SDL_mixer:x" + +if [[ "$GH_HYP_GLEW" == "glew_1" ]]; then + GH_DEPS_UBUNTU+=" libglew-dev" + GH_DEPS_MACOS+=" glew" + GH_DEPS_MINGW64+=" glew:x" +fi + +if [[ "$GH_HYP_PNG" == "png_1" ]]; then + GH_DEPS_UBUNTU+=" libpng-dev" + GH_DEPS_MACOS+=" libpng" + GH_DEPS_MINGW64+=" libpng:x" +fi + +if [[ "$GH_BUILDSYS" == "autotools" ]]; then + GH_DEPS_UBUNTU+=" autoconf" + GH_DEPS_MACOS+=" automake" + GH_DEPS_MINGW64+=" automake-wrapper autoconf" +fi + +if [[ "$GH_OS" == "ubuntu-latest" ]]; then + sudo apt-get -y install $GH_DEPS_UBUNTU +elif [[ "$GH_OS" == "macos-latest" ]]; then + brew update + # macos-latest already has both gcc and clang + brew install $GH_DEPS_MACOS + # work around https://stackoverflow.com/questions/51034399/ for now + (cd /usr/local/include && ln -sf SDL/SDL.h) +elif [[ "$GH_OS" == "windows-latest" ]]; then + pacboy -Sy --noconfirm --needed $GH_DEPS_MINGW64 + sed -i'.orig' 's//"SDL.h"/' /mingw64/include/SDL/SDL_gfxPrimitives.h +else + exit 'unknown OS' +fi diff --git a/.github/workflows/test_simple.sh b/.github/workflows/test_simple.sh new file mode 100755 index 00000000..5627fa59 --- /dev/null +++ b/.github/workflows/test_simple.sh @@ -0,0 +1,5 @@ +set -e o pipefail +source .github/workflows/gh_ci_envvars.sh + + +./hyperrogue --version \ No newline at end of file