Skip to content

Commit 90ea8ae

Browse files
authored
Merge pull request #10 from ccassise/integration-tests
v0.4.0
2 parents d107ea5 + 8e8eb41 commit 90ea8ae

102 files changed

Lines changed: 3168 additions & 1480 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
3+
name: CMake on multiple platforms
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
jobs:
12+
macos:
13+
runs-on: macos-latest
14+
15+
strategy:
16+
fail-fast: false
17+
18+
matrix:
19+
build_type: [Release, Debug]
20+
c_compiler: [clang]
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set reusable strings
26+
id: strings
27+
shell: bash
28+
run: |
29+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
30+
31+
- name: Create wowpkg config.ini
32+
run: |
33+
{
34+
echo '[Config]'
35+
echo "github_token = ${{ secrets.GITHUB_TOKEN }}"
36+
echo '[Retail]'
37+
echo "addons_path = ${{ github.workspace }}/data/addons"
38+
} > "${{ github.workspace }}/data/config.ini"
39+
40+
- name: Install vcpkg
41+
run: |
42+
git clone https://github.com/microsoft/vcpkg.git
43+
/bin/sh -c ./vcpkg/bootstrap-vcpkg.sh
44+
45+
- name: Configure CMake
46+
run: >
47+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
48+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
49+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
50+
-S ${{ github.workspace }}
51+
-DWOWPKG_USE_DEVELOPMENT_PATHS:option=on
52+
-DWOWPKG_ENABLE_SANITIZERS:option=on
53+
-DWOWPKG_ENABLE_TESTS:option=on
54+
-DWOWPKG_ENABLE_TESTS_INTEGRATION:option=on
55+
56+
- name: Build
57+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
58+
59+
- name: Test
60+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
61+
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure
62+
63+
linux:
64+
runs-on: ubuntu-latest
65+
66+
strategy:
67+
fail-fast: false
68+
69+
matrix:
70+
build_type: [Release, Debug]
71+
c_compiler: [gcc]
72+
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Set reusable strings
77+
id: strings
78+
shell: bash
79+
run: |
80+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
81+
82+
- name: Create wowpkg config.ini
83+
run: |
84+
{
85+
echo '[Config]'
86+
echo "github_token = ${{ secrets.GITHUB_TOKEN }}"
87+
echo '[Retail]'
88+
echo "addons_path = ${{ github.workspace }}/data/addons"
89+
} > "${{ github.workspace }}/data/config.ini"
90+
91+
- name: Install vcpkg
92+
run: |
93+
git clone https://github.com/microsoft/vcpkg.git
94+
/bin/sh -c ./vcpkg/bootstrap-vcpkg.sh
95+
96+
- name: Configure CMake
97+
run: >
98+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
99+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
100+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
101+
-S ${{ github.workspace }}
102+
-DWOWPKG_USE_DEVELOPMENT_PATHS:option=on
103+
-DWOWPKG_ENABLE_SANITIZERS:option=on
104+
-DWOWPKG_ENABLE_TESTS:option=on
105+
-DWOWPKG_ENABLE_TESTS_INTEGRATION:option=on
106+
107+
108+
- name: Build
109+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
110+
111+
- name: Test
112+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
113+
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure
114+
115+
windows:
116+
runs-on: windows-latest
117+
118+
strategy:
119+
fail-fast: false
120+
121+
matrix:
122+
build_type: [Release, Debug]
123+
c_compiler: [cl]
124+
125+
steps:
126+
- uses: actions/checkout@v4
127+
128+
- name: Set reusable strings
129+
id: strings
130+
shell: bash
131+
run: |
132+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
133+
134+
- name: Create wowpkg config.ini
135+
shell: bash
136+
run: |
137+
{
138+
echo '[Config]'
139+
echo "github_token = ${{ secrets.GITHUB_TOKEN }}"
140+
echo '[Retail]'
141+
echo "addons_path = ${{ github.workspace }}/data/addons"
142+
} > "${{ github.workspace }}/data/config.ini"
143+
144+
- name: Install vcpkg
145+
shell: pwsh
146+
run: |
147+
git clone https://github.com/microsoft/vcpkg.git
148+
.\vcpkg\bootstrap-vcpkg.bat
149+
150+
- name: Configure CMake
151+
run: >
152+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
153+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
154+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
155+
-S ${{ github.workspace }}
156+
-DWOWPKG_USE_DEVELOPMENT_PATHS:option=on
157+
-DWOWPKG_ENABLE_SANITIZERS:option=off
158+
-DWOWPKG_ENABLE_TESTS:option=on
159+
-DWOWPKG_ENABLE_TESTS_INTEGRATION:option=on
160+
161+
- name: Build
162+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
163+
164+
- name: Test
165+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
166+
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure

.gitignore

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,21 @@ Mkfile.old
5252
dkms.conf
5353

5454
# Repo ignores
55-
.vscode/
56-
build/
5755
.DS_Store
56+
build/
57+
vcpkg/
58+
vcpkg_installed/
59+
_CPack_Packages/
5860

5961
# Setup development directory so that it is easier to run from source.
60-
dev_only/**
61-
dev_only/addons/**
62-
dev_only/tmp/**
62+
data/**
63+
data/addons/**
64+
data/tmp/**
6365

64-
!dev_only/addons/
65-
!dev_only/addons/README.md
66-
!dev_only/config.ini
67-
!dev_only/saved.wowpkg
68-
!dev_only/example_addon.ini
69-
!dev_only/tmp/
70-
!dev_only/tmp/README.md
66+
!data/addons/
67+
!data/addons/.ignore_me
68+
!data/config.ini
69+
!data/saved.wowpkg
70+
!data/example_addon.ini
71+
!data/tmp/
72+
!data/tmp/.ignore_me

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cmake.configureSettings": {
3+
"WOWPKG_ENABLE_SANITIZERS": true,
4+
"WOWPKG_ENABLE_TESTS": true,
5+
"WOWPKG_ENABLE_TESTS_INTEGRATION": false,
6+
"WOWPKG_USE_DEVELOPMENT_PATHS": true
7+
}
8+
}

CMakeLists.txt

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
cmake_minimum_required(VERSION 3.16)
1+
cmake_minimum_required(VERSION 3.17)
22

3-
set(
4-
CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
5-
CACHE STRING "Vcpkg toolchain file"
6-
)
3+
if (NOT DEFINED ${CMAKE_TOOLCHAIN_FILE})
4+
set(
5+
CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
6+
CACHE STRING "Vcpkg toolchain file"
7+
)
8+
endif()
79

810
project(
911
wowpkg
10-
VERSION 0.3.1
12+
VERSION 0.4.0
1113
DESCRIPTION "A CLI World of Warcraft addon manager"
1214
LANGUAGES C
1315
)
@@ -16,6 +18,7 @@ set(WOWPKG_C_STANDARD 11)
1618

1719
option(WOWPKG_ENABLE_SANITIZERS "Build with or without sanitizers" OFF)
1820
option(WOWPKG_ENABLE_TESTS "Build tests" OFF)
21+
option(WOWPKG_ENABLE_TESTS_INTEGRATION "Build integration tests" OFF)
1922
option(WOWPKG_USE_DEVELOPMENT_PATHS "Determines what paths will be used to find some files" OFF)
2023

2124
# Compiler flags that enable warnings.
@@ -57,18 +60,23 @@ if (WOWPKG_ENABLE_TESTS)
5760
enable_testing()
5861
endif()
5962

60-
find_package(CURL CONFIG REQUIRED)
63+
find_package(CURL REQUIRED)
6164
find_package(cJSON CONFIG REQUIRED)
62-
find_package(unofficial-minizip CONFIG REQUIRED)
65+
find_package(LibArchive REQUIRED)
6366

64-
set(WOWPKG_LIBS CURL::libcurl cjson unofficial::minizip::minizip)
67+
set(WOWPKG_LIBS CURL::libcurl cjson LibArchive::LibArchive)
6568

6669
if (MSVC)
67-
# CMake does not set proper release flags for MSVC.
68-
set(WFLAGS_RELEASE /O2 /GL /DNDEBUG /Zi /Gy)
69-
set(WFLAGS /W4 "$<$<CONFIG:Release>:${WFLAGS_RELEASE}>")
70+
set(WFLAGS_RELEASE /GL /O2)
71+
set(LDFLAGS_RELEASE /LTCG)
7072

71-
set(LDFLAGS_RELEASE /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF)
73+
# Really only needed if the config is Release.
74+
if(WOWPKG_ENABLE_SANITIZERS)
75+
set(WFLAGS_RELEASE ${WFLAGS_RELEASE} /Zi)
76+
set(LDFLAGS_RELEASE ${LDFLAGS_RELEASE} /DEBUG)
77+
endif()
78+
79+
set(WFLAGS /W4 "$<$<CONFIG:Release>:${WFLAGS_RELEASE}>")
7280
set(LDFLAGS "$<$<CONFIG:Release>:${LDFLAGS_RELEASE}>")
7381

7482
# A lot of the functions suggested by this are not available on other
@@ -80,25 +88,24 @@ else()
8088

8189
-Wall
8290
-Wextra
83-
-Wshadow
84-
-Wdouble-promotion
85-
-Wconversion
8691
-Wpedantic
8792
-Wcast-align
88-
-Wstrict-prototypes
89-
90-
-Wwrite-strings
91-
-Winit-self
93+
-Wcast-qual
94+
-Wconversion
95+
-Wdouble-promotion
9296
-Wformat=2
97+
-Winit-self
98+
-Wparentheses
99+
-Wshadow
100+
-Wstrict-aliasing
93101
-Wstrict-overflow=2
94-
-Wcast-qual
95-
-Wundef
102+
-Wstrict-prototypes
96103
-Wswitch-default
97-
-fstack-protector-strong
98-
-Wparentheses
99-
-Wunused-macros
100104
-Wswitch-enum
101-
-Wstrict-aliasing
105+
-Wundef
106+
-Wunused-macros
107+
-Wwrite-strings
108+
-fstack-protector-strong
102109
)
103110
endif()
104111

@@ -112,19 +119,20 @@ if (WOWPKG_ENABLE_SANITIZERS)
112119
set(
113120
SANFLAGS
114121

115-
-fsanitize=address
116-
-fsanitize=undefined
117-
-fsanitize=float-divide-by-zero
118-
-fsanitize=float-cast-overflow
119122
-fno-sanitize-recover=all
120-
-fno-sanitize=null
121123
-fno-sanitize=alignment
124+
-fno-sanitize=null
125+
-fsanitize=address
126+
-fsanitize=float-cast-overflow
127+
-fsanitize=float-divide-by-zero
128+
-fsanitize=undefined
122129
)
123130

124131
set (WFLAGS ${WFLAGS} ${SANFLAGS})
125132

126133
if (APPLE)
127-
set(LDFLAGS ${SANFLAGS} -static-libsan)
134+
# set(LDFLAGS ${SANFLAGS} -static-libsan)
135+
set(LDFLAGS ${SANFLAGS})
128136
else()
129137
set(LDFLAGS ${SANFLAGS} -static-libasan)
130138
endif()
@@ -136,11 +144,13 @@ set(
136144

137145
${PROJECT_SOURCE_DIR}/src/addon.c
138146
${PROJECT_SOURCE_DIR}/src/appstate.c
147+
${PROJECT_SOURCE_DIR}/src/catalog.c
139148
${PROJECT_SOURCE_DIR}/src/command.c
140149
${PROJECT_SOURCE_DIR}/src/config.c
141150
${PROJECT_SOURCE_DIR}/src/ini.c
142151
${PROJECT_SOURCE_DIR}/src/list.c
143152
${PROJECT_SOURCE_DIR}/src/osapi.c
153+
${PROJECT_SOURCE_DIR}/src/osstring.c
144154
${PROJECT_SOURCE_DIR}/src/zipper.c
145155
)
146156

@@ -149,7 +159,7 @@ list(APPEND WOWPKG_DEFINES WOWPKG_VERSION="${PROJECT_VERSION}")
149159
if(WOWPKG_USE_DEVELOPMENT_PATHS)
150160
message(STATUS "[${PROJECT_NAME}] building with development paths")
151161
list(APPEND WOWPKG_DEFINES
152-
WOWPKG_USER_FILE_DIR="${PROJECT_SOURCE_DIR}/dev_only"
162+
WOWPKG_USER_FILE_DIR="${PROJECT_SOURCE_DIR}/data"
153163
WOWPKG_CATALOG_PATH="${PROJECT_SOURCE_DIR}/catalog"
154164
)
155165
endif()
@@ -158,7 +168,12 @@ add_subdirectory(src)
158168

159169
if (WOWPKG_ENABLE_TESTS)
160170
message(STATUS "[${PROJECT_NAME}] enabling tests")
161-
add_subdirectory(test)
171+
add_subdirectory(tests)
172+
endif()
173+
174+
if (WOWPKG_ENABLE_TESTS_INTEGRATION)
175+
message(STATUS "[${PROJECT_NAME}] enabling integration tests")
176+
add_subdirectory(tests/integration)
162177
endif()
163178

164179
if (APPLE)
@@ -183,6 +198,7 @@ else()
183198
endif()
184199

185200
if (WIN32)
201+
install(FILES ${PROJECT_SOURCE_DIR}/build/src/Release/archive.dll DESTINATION bin)
186202
install(FILES ${PROJECT_SOURCE_DIR}/build/src/Release/cjson.dll DESTINATION bin)
187203
install(FILES ${PROJECT_SOURCE_DIR}/build/src/Release/libcurl.dll DESTINATION bin)
188204
install(FILES ${PROJECT_SOURCE_DIR}/build/src/Release/zlib1.dll DESTINATION bin)

0 commit comments

Comments
 (0)