Simplify CI scripts (#3764)

* Deps paths through https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
* Use heredocs for pasting source code
* Remove fetch-depth arg, it's the default
* Merge the `brew install`s, it's simpler and maybe even faster
This commit is contained in:
Oleh Prypin 2021-01-27 00:45:13 +01:00 committed by ocornut
parent 56f7bdae99
commit 3b4d3a9b73

View File

@ -1,8 +1,8 @@
name: build name: build
on: on:
push: {} push:
pull_request: {} pull_request:
schedule: schedule:
- cron: '0 9 * * *' - cron: '0 9 * * *'
@ -12,21 +12,19 @@ jobs:
env: env:
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\ VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\ MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
# Until gh-actions allow us to use env variables inside other env variables (because we need %GITHUB_WORKSPACE%) we have to use relative path to imgui/examples/example_name directory.
SDL2_DIR: ..\..\SDL2-devel-2.0.10-VC\SDL2-2.0.10\
VULKAN_SDK: ..\..\vulkan-sdk-1.1.121.2\
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Dependencies - name: Install Dependencies
shell: powershell shell: powershell
run: | run: |
Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip" Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip"
Expand-Archive -Path SDL2-devel-2.0.10-VC.zip Expand-Archive -Path SDL2-devel-2.0.10-VC.zip
echo "SDL2_DIR=$(pwd)\SDL2-devel-2.0.10-VC\SDL2-2.0.10\" >>${env:GITHUB_ENV}
Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip
Expand-Archive -Path vulkan-sdk-1.1.121.2.zip Expand-Archive -Path vulkan-sdk-1.1.121.2.zip
echo "VULKAN_SDK=$(pwd)\vulkan-sdk-1.1.121.2\" >>${env:GITHUB_ENV}
- name: Fix Projects - name: Fix Projects
shell: powershell shell: powershell
@ -55,24 +53,33 @@ jobs:
- name: Build example_null (single file build) - name: Build example_null (single file build)
shell: bash shell: bash
run: | run: |
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
- name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS) - name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS)
shell: bash shell: bash
run: | run: |
echo '#define IMGUI_DISABLE_WIN32_FUNCTIONS' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_DISABLE_WIN32_FUNCTIONS
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
- name: Build example_null (as DLL) - name: Build example_null (as DLL)
shell: cmd shell: cmd
run: | run: |
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat" call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"
echo #ifdef _EXPORT > example_single_file.cpp echo #ifdef _EXPORT > example_single_file.cpp
echo # define IMGUI_API __declspec(dllexport) >> example_single_file.cpp echo # define IMGUI_API __declspec(dllexport) >> example_single_file.cpp
echo #else >> example_single_file.cpp echo #else >> example_single_file.cpp
@ -80,6 +87,7 @@ jobs:
echo #endif >> example_single_file.cpp echo #endif >> example_single_file.cpp
echo #define IMGUI_IMPLEMENTATION >> example_single_file.cpp echo #define IMGUI_IMPLEMENTATION >> example_single_file.cpp
echo #include "misc/single_file/imgui_single_file.h" >> example_single_file.cpp echo #include "misc/single_file/imgui_single_file.h" >> example_single_file.cpp
cl.exe /D_USRDLL /D_WINDLL /D_EXPORT /I. example_single_file.cpp /LD /FeImGui.dll /link cl.exe /D_USRDLL /D_WINDLL /D_EXPORT /I. example_single_file.cpp /LD /FeImGui.dll /link
cl.exe /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp cl.exe /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
@ -183,9 +191,7 @@ jobs:
Linux: Linux:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Dependencies - name: Install Dependencies
run: | run: |
@ -219,82 +225,118 @@ jobs:
- name: Build example_null (single file build) - name: Build example_null (single file build)
run: | run: |
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with ImWchar32) - name: Build example_null (with ImWchar32)
run: | run: |
echo '#define IMGUI_USE_WCHAR32' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_USE_WCHAR32
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with large ImDrawIdx) - name: Build example_null (with large ImDrawIdx)
run: | run: |
echo '#define ImDrawIdx unsigned int' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define ImDrawIdx unsigned int
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with IMGUI_DISABLE_OBSOLETE_FUNCTIONS) - name: Build example_null (with IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
run: | run: |
echo '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW) - name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW)
run: | run: |
echo '#define IMGUI_DISABLE_DEMO_WINDOWS' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_DISABLE_METRICS_WINDOW' >> example_single_file.cpp
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp #define IMGUI_DISABLE_DEMO_WINDOWS
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_DISABLE_METRICS_WINDOW
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with IMGUI_DISABLE_FILE_FUNCTIONS) - name: Build example_null (with IMGUI_DISABLE_FILE_FUNCTIONS)
run: | run: |
echo '#define IMGUI_DISABLE_FILE_FUNCTIONS' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_DISABLE_FILE_FUNCTIONS
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with IMGUI_USE_BGRA_PACKED_COLOR) - name: Build example_null (with IMGUI_USE_BGRA_PACKED_COLOR)
run: | run: |
echo '#define IMGUI_USE_BGRA_PACKED_COLOR' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_USE_BGRA_PACKED_COLOR
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (with IM_VEC2_CLASS_EXTRA and IM_VEC4_CLASS_EXTRA) - name: Build example_null (with IM_VEC2_CLASS_EXTRA and IM_VEC4_CLASS_EXTRA)
run: | run: |
echo 'struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } };' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo 'struct MyVec4 { float x; float y; float z; float w;' >> example_single_file.cpp
echo 'MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } };' >> example_single_file.cpp struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } };
echo '#define IM_VEC2_CLASS_EXTRA \' >> example_single_file.cpp struct MyVec4 { float x; float y; float z; float w;
echo ' ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \' >> example_single_file.cpp MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } };
echo ' operator MyVec2() const { return MyVec2(x, y); }' >> example_single_file.cpp #define IM_VEC2_CLASS_EXTRA \
echo '#define IM_VEC4_CLASS_EXTRA \' >> example_single_file.cpp ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
echo ' ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \' >> example_single_file.cpp operator MyVec2() const { return MyVec2(x, y); }
echo ' operator MyVec4() const { return MyVec4(x, y, z, w); }' >> example_single_file.cpp #define IM_VEC4_CLASS_EXTRA \
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp operator MyVec4() const { return MyVec4(x, y, z, w); }
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (without c++ runtime, Clang) - name: Build example_null (without c++ runtime, Clang)
run: | run: |
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#define IMGUI_DISABLE_DEMO_WINDOWS' >> example_single_file.cpp
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_DISABLE_DEMO_WINDOWS
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp
- name: Build example_glfw_opengl2 - name: Build example_glfw_opengl2
@ -314,30 +356,35 @@ jobs:
MacOS: MacOS:
runs-on: macOS-latest runs-on: macOS-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Dependencies - name: Install Dependencies
run: | run: |
brew install glfw3 brew install glfw3 sdl2
brew install sdl2
- name: Build example_null (extra warnings, clang 64-bit) - name: Build example_null (extra warnings, clang 64-bit)
run: make -C examples/example_null WITH_EXTRA_WARNINGS=1 run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
- name: Build example_null (single file build) - name: Build example_null (single file build)
run: | run: |
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
- name: Build example_null (without c++ runtime) - name: Build example_null (without c++ runtime)
run: | run: |
echo '#define IMGUI_IMPLEMENTATION' > example_single_file.cpp cat > example_single_file.cpp <<'EOF'
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp #define IMGUI_IMPLEMENTATION
#include "misc/single_file/imgui_single_file.h"
#include "examples/example_null/main.cpp"
EOF
clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp
- name: Build example_glfw_opengl2 - name: Build example_glfw_opengl2
@ -369,9 +416,7 @@ jobs:
iOS: iOS:
runs-on: macOS-latest runs-on: macOS-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Build example_apple_metal - name: Build example_apple_metal
run: | run: |
@ -381,9 +426,7 @@ jobs:
Emscripten: Emscripten:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Dependencies - name: Install Dependencies
run: | run: |