@@ -2,80 +2,94 @@ name: CI
22
33on :
44 push :
5- branches : [ master ]
65 pull_request :
76 branches : [ master ]
7+ workflow_dispatch :
8+
9+ permissions :
10+ contents : read
11+ pull-requests : read
12+
13+ concurrency :
14+ group : ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
15+ cancel-in-progress : true
816
917jobs :
18+ detect-open-pr :
19+ name : Detect open PR
20+ runs-on : ubuntu-latest
21+
22+ outputs :
23+ has_open_pr : ${{ steps.check.outputs.has_open_pr }}
24+
25+ steps :
26+ - name : Check if pushed branch already has an open PR
27+ id : check
28+ env :
29+ GH_TOKEN : ${{ github.token }}
30+ BRANCH_NAME : ${{ github.ref_name }}
31+ EVENT_NAME : ${{ github.event_name }}
32+ REPO : ${{ github.repository }}
33+ OWNER : ${{ github.repository_owner }}
34+ run : |
35+ if [ "$EVENT_NAME" != "push" ]; then
36+ echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
37+ exit 0
38+ fi
39+ if [ "$BRANCH_NAME" = "master" ]; then
40+ echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
41+ exit 0
42+ fi
43+ COUNT=$(gh api \
44+ -H "Accept: application/vnd.github+json" \
45+ "/repos/$REPO/pulls?state=open&head=$OWNER:$BRANCH_NAME" \
46+ --jq 'length')
47+ echo "Open PR count for branch '$OWNER:$BRANCH_NAME': $COUNT"
48+ if [ "$COUNT" -gt 0 ]; then
49+ echo "has_open_pr=true" >> "$GITHUB_OUTPUT"
50+ else
51+ echo "has_open_pr=false" >> "$GITHUB_OUTPUT"
52+ fi
53+
1054 build :
55+ name : Build on ${{ matrix.os }}
56+ needs : detect-open-pr
57+
58+ if : >
59+ github.event_name == 'pull_request' ||
60+ github.ref == 'refs/heads/master' ||
61+ needs.detect-open-pr.outputs.has_open_pr == 'false'
62+
1163 runs-on : ${{ matrix.os }}
64+
1265 strategy :
1366 fail-fast : false
1467 matrix :
15- include :
16- - os : ubuntu-latest
17- - os : macos-latest
68+ os :
69+ - ubuntu-latest
70+ - macos-latest
1871
1972 steps :
20- - uses : actions/checkout@v2
21- with :
22- submodules : recursive
23-
24- - name : Add brew packages
25- if : matrix.os == 'macos-latest'
26- shell : bash
27- run : brew install sdl2 glew
73+ - name : Checkout repository
74+ uses : actions/checkout@v5
75+ with :
76+ submodules : recursive
2877
29- - name : Add apt packages
30- if : matrix.os == 'ubuntu-latest'
31- run : |
32- sudo apt-get update -qq
33- sudo apt-get install -y --no-install-recommends libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev libglew-dev
78+ - name : Install Linux dependencies
79+ if : runner.os == 'Linux'
80+ run : |
81+ sudo apt-get update -qq
82+ sudo apt-get install -y --no-install-recommends \
83+ xorg-dev \
84+ libgl1-mesa-dev
3485
35- - name : Build OSX
36- if : matrix.os == 'macos-latest'
37- run : |
38- clang++ -std=c++11 -stdlib=libc++ imgui/examples/example_sdl2_opengl3/main.cpp \
39- imgui/backends/imgui_impl_opengl3.cpp \
40- imgui/backends/imgui_impl_sdl2.cpp \
41- imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp \
42- imgui/imgui_widgets.cpp imgui/imgui_demo.cpp \
43- FileBrowser/ImGuiFileBrowser.cpp \
44- -DIMGUI_IMPL_OPENGL_LOADER_GLEW \
45- -I imgui \
46- -I imgui/examples \
47- -I imgui/backends \
48- -I /usr/local/include/SDL2 \
49- -lSDL2 -lGLEW \
50- -framework OpenGL \
51- -o example_sdl2_opengl3
86+ - name : Configure CMake
87+ run : |
88+ cmake -S . -B build \
89+ -DCMAKE_BUILD_TYPE=Release \
90+ -DIMGADDONS_BUILD_PREVIEW=ON \
91+ -DIMGADDONS_RUNTIME_OUTPUT_DIR="${{ github.workspace }}/build/bin"
5292
53- - name : Build Linux
54- if : matrix.os == 'ubuntu-latest'
55- run : |
56- clang++ imgui/examples/example_sdl2_opengl3/main.cpp \
57- imgui/backends/imgui_impl_opengl3.cpp \
58- imgui/backends/imgui_impl_sdl2.cpp \
59- imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp \
60- imgui/imgui_widgets.cpp imgui/imgui_demo.cpp \
61- FileBrowser/ImGuiFileBrowser.cpp \
62- -DIMGUI_IMPL_OPENGL_LOADER_GLEW \
63- -I imgui \
64- -I imgui/examples \
65- -I imgui/backends \
66- -I /usr/include/SDL2 \
67- -lSDL2 -lGL -lGLEW -ldl \
68- -o example_sdl2_opengl3
69- g++ imgui/examples/example_sdl2_opengl3/main.cpp \
70- imgui/backends/imgui_impl_opengl3.cpp \
71- imgui/backends/imgui_impl_sdl2.cpp \
72- imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp \
73- imgui/imgui_widgets.cpp imgui/imgui_demo.cpp \
74- FileBrowser/ImGuiFileBrowser.cpp \
75- -DIMGUI_IMPL_OPENGL_LOADER_GLEW \
76- -I imgui \
77- -I imgui/examples \
78- -I imgui/backends \
79- -I /usr/include/SDL2 \
80- -lSDL2 -lGL -lGLEW -ldl \
81- -o example_sdl2_opengl3
93+ - name : Build
94+ run : |
95+ cmake --build build --config Release --parallel
0 commit comments