-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (131 loc) · 5.42 KB
/
make.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CI
on:
[push, workflow_dispatch]
#concurrency:
# group: "make"
# cancel-in-progress: false
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make check
run: |
make check
build-and-test:
# runs-on: self-hosted
timeout-minutes: 5
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, CXX: g++, build_type: all}
- {os: ubuntu-latest, CXX: g++, build_type: release}
- {os: ubuntu-latest, CXX: clang++, build_type: all}
- {os: ubuntu-latest, CXX: clang++, build_type: release}
- {os: ubuntu-latest, CXX: cmake, build_type: Debug}
- {os: ubuntu-latest, CXX: cosmoc++, build_type: all}
- {os: ubuntu-latest, CXX: cosmoc++, build_type: release}
- {os: windows-latest, CXX: cl, build_type: Debug}
- {os: windows-latest, CXX: g++, build_type: all}
- {os: windows-latest, CXX: g++, build_type: release}
- {os: windows-latest, CXX: clang++, build_type: all}
- {os: windows-latest, CXX: clang++, build_type: release}
- {os: windows-latest, CXX: cmake, build_type: Debug}
# macos-12 is for x64, while macos-14 is for arm64 (M1)
- {os: macos-12, CXX: g++, build_type: all}
- {os: macos-12, CXX: g++, build_type: release}
- {os: macos-12, CXX: clang++, build_type: all}
- {os: macos-12, CXX: clang++, build_type: release}
- {os: macos-12, CXX: cmake, build_type: Debug}
- {os: macos-latest, CXX: g++, build_type: all}
- {os: macos-latest, CXX: g++, build_type: release}
- {os: macos-latest, CXX: clang++, build_type: all}
- {os: macos-latest, CXX: clang++, build_type: release}
- {os: macos-latest, CXX: cmake, build_type: Debug}
name: "${{ matrix.config.os }} ${{ matrix.config.CXX }} ${{ matrix.config.build_type }}"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup LLVM on Windows
# https://github.com/actions/runner-images/issues/10001
if: matrix.config.CXX == 'clang++' && matrix.config.os == 'windows-latest'
run: |
choco upgrade llvm -y
echo "LLVM_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV
- name: Set up Microsoft Dev Cmd
if: matrix.config.os == 'windows-latest' && matrix.config.CXX == 'cl'
uses: ilammy/[email protected]
with:
arch: amd64
- name: Setup cosmoc++
if: matrix.config.CXX == 'cosmoc++' && matrix.config.os == 'ubuntu-latest'
run: |
mkdir -p cosmocc
cd cosmocc
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip -q
unzip cosmocc.zip -qq
cd ..
echo "$(pwd)/cosmocc/bin" >> $GITHUB_PATH
- name: Output compiler version
shell: bash
run: |
if [[ "${{ matrix.config.CXX }}" == "cl" ]]; then
cl
else \
${{ matrix.config.CXX }} --version
fi
- name: Make all
if: matrix.config.CXX != 'cmake' && matrix.config.CXX != 'cl' && matrix.config.build_type == 'all'
shell: bash
run: |
# Enabling optimization checks -Wmaybe-uninitialized from -Wall
# output 3 to stdin (to close the game) as 'make all' will start the game
echo -e "3" | CXXFLAGS=-O2 CXX=${{ matrix.config.CXX }} make all -j2
- name: Make release
if: matrix.config.CXX != 'cmake' && matrix.config.CXX != 'cl' && matrix.config.build_type == 'release'
shell: bash
run: |
CXX=${{ matrix.config.CXX }} make release -j 2
- name: CMake
if: matrix.config.CXX == 'cmake'
shell: bash
run: |
cmake -B build -S . -DOUTPUT_NAME=stocksim-cmake -Werror=dev -Werror=deprecated --fresh
cmake --build build --parallel 2 --config ${{ matrix.config.build_type }} --clean-first
cmake --install build --prefix . --config ${{ matrix.config.build_type }}
- name: Compile with cl
if: matrix.config.os == 'windows-latest' && matrix.config.CXX == 'cl'
shell: cmd
run: |
make msvc
- name: Run test cases
shell: bash
run: |
if [[ "${{ matrix.config.CXX }}" == "cmake" ]]; then
executable="stocksim-cmake"
elif [[ "${{ matrix.config.CXX }}" == "cl" ]]; then
executable="stocksim-msvc"
elif [[ "${{ matrix.config.build_type }}" == "release" ]]; then
executable="stocksim-release"
else
executable="stocksim"
fi
echo -e "1\ntest\nX\nY\n" | ./$executable
echo -e "0\n saves\nsaves\nB\n1\n1\nN\nY\nN\nY\nN\nY\nT\n0\nT\n1\nT\n2\nE\nT\nX\nY\n" | ./$executable
# test for loading saves
echo -e "1\nsaves\nN\nY\nN\nY\nN\nY\nN\nY\nT\n0\nT\nT\n3\nT\n4\nT\nS\n1\n1\nX\nY\n" | ./$executable
# test for deleting saves
echo -e "2\nsaves\nY\n3\n" | ./$executable
- name: Upload executable
uses: actions/upload-artifact@v4
with:
# suppose we compiled our game and named it 'stocksim'
# use wildcard to match the executable for all platforms
# name: stocksim
name: stocksim-${{ matrix.config.os }}-${{ matrix.config.CXX }}-${{ matrix.config.build_type }}
path: stocksim*
compression-level: 9
if-no-files-found: error