-
Notifications
You must be signed in to change notification settings - Fork 1
168 lines (166 loc) · 6.76 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: CI
on:
[push, workflow_dispatch]
jobs:
build-and-test:
timeout-minutes: 10
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/msvc-dev-cmd@v1.13.0
with:
arch: amd64
- name: Setup cosmoc++
if: matrix.config.CXX == 'cosmoc++'
shell: bash
run: |
if [[ "${{ matrix.config.os }}" == "windows-latest" ]]; then
choco install unzip wget -y --no-progress
fi
mkdir -p cosmocc
cd cosmocc
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip -q
unzip -qq cosmocc.zip
git clone https://github.com/jart/cosmopolitan --depth=1
cd cosmopolitan
if [[ "${{ matrix.config.os }}" != "windows-latest" ]]; then
sudo ape/apeinstall.sh
fi
cd ..
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: |
# output 3 to stdin (to close the game) as 'make all' will start the game
echo -e "3" | make CXX=${{ matrix.config.CXX }} all -j2
- name: Make release
if: matrix.config.CXX != 'cmake' && matrix.config.CXX != 'cl' && matrix.config.build_type == 'release'
shell: bash
run: |
make release CXX=${{ matrix.config.CXX }} -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
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
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
analyze:
needs: build-and-test
name: CodeQL Analysis (${{ matrix.language }})
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: autobuild
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
clang-format:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make check
run: |
make check