mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Merge pull request #2 from Laupetin/feature/github-workflows
Add CI with Github workflows
This commit is contained in:
commit
6eba8a8062
83
.github/workflows/ci.yaml
vendored
Normal file
83
.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
PREMAKE_VERSION: "5.0.0-beta2"
|
||||
|
||||
jobs:
|
||||
build-test-linux:
|
||||
env:
|
||||
PREMAKE_CONFIG: gmake2
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install multilib
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-multilib g++-multilib
|
||||
|
||||
- name: Setup premake
|
||||
uses: abel0b/setup-premake@v2.1
|
||||
with:
|
||||
version: ${{ env.PREMAKE_VERSION }}
|
||||
|
||||
- name: Premake generate
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: premake5 ${{ env.PREMAKE_CONFIG }}
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: make -C build -j$(nproc) config=release_x86 all
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{ github.workspace }}/build/lib/Release_x86/tests
|
||||
run: |
|
||||
./ObjCommonTests
|
||||
./ObjLoadingTests
|
||||
./ParserTests
|
||||
./ZoneCodeGeneratorLibTests
|
||||
./ZoneCommonTests
|
||||
|
||||
build-test-windows:
|
||||
env:
|
||||
PREMAKE_CONFIG: vs2022
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- name: Setup premake
|
||||
uses: abel0b/setup-premake@v2.1
|
||||
with:
|
||||
version: ${{ env.PREMAKE_VERSION }}
|
||||
|
||||
- name: Premake generate
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: premake5 ${{ env.PREMAKE_CONFIG }}
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: msbuild /m /p:Configuration=Release /p:Platform=Win32 build
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{ github.workspace }}/build/lib/Release_x86/tests
|
||||
run: |
|
||||
./ObjCommonTests
|
||||
./ObjLoadingTests
|
||||
./ParserTests
|
||||
./ZoneCodeGeneratorLibTests
|
||||
./ZoneCommonTests
|
@ -1,36 +0,0 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
build-gcc:
|
||||
image: laupetin/gcc-9-multilib:latest
|
||||
stage: build
|
||||
interruptible: true
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
tags:
|
||||
- build
|
||||
- docker
|
||||
- linux
|
||||
script:
|
||||
- "./generate.sh"
|
||||
- "./scripts/make-release.sh"
|
||||
|
||||
test-gcc:
|
||||
image: laupetin/gcc-9-multilib:latest
|
||||
stage: test
|
||||
interruptible: true
|
||||
cache:
|
||||
paths:
|
||||
- build/
|
||||
tags:
|
||||
- build
|
||||
- docker
|
||||
- linux
|
||||
script:
|
||||
- "./build/lib/Release_x86/tests/ObjCommonTests"
|
||||
- "./build/lib/Release_x86/tests/ObjLoadingTests"
|
||||
- "./build/lib/Release_x86/tests/ParserTests"
|
||||
- "./build/lib/Release_x86/tests/ZoneCodeGeneratorLibTests"
|
||||
- "./build/lib/Release_x86/tests/ZoneCommonTests"
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
class MemoryManager
|
||||
|
@ -44,7 +44,8 @@ public:
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include <catch2/catch.hpp>")
|
||||
LINE("#include <catch2/catch_test_macros.hpp>")
|
||||
LINE("#include <catch2/generators/catch_generators.hpp>")
|
||||
LINE("#include <cstddef>")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("")
|
||||
|
@ -48,5 +48,6 @@ function ObjCommonTests:project()
|
||||
catch2:include(includes)
|
||||
|
||||
links:linkto(ObjCommon)
|
||||
links:linkto(catch2)
|
||||
links:linkall()
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
@ -49,5 +49,6 @@ function ObjLoadingTests:project()
|
||||
|
||||
links:linkto(ParserTestUtils)
|
||||
links:linkto(ObjLoading)
|
||||
links:linkto(catch2)
|
||||
links:linkall()
|
||||
end
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -12,6 +14,7 @@
|
||||
using namespace menu;
|
||||
using namespace IW4;
|
||||
using namespace std::literals;
|
||||
using namespace Catch::Matchers;
|
||||
|
||||
namespace test::game::iw4::menu::parsing::it
|
||||
{
|
||||
@ -184,10 +187,10 @@ namespace test::game::iw4::menu::parsing::it
|
||||
REQUIRE(menu->fullScreen > 0);
|
||||
REQUIRE(menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE);
|
||||
REQUIRE(menu->window.staticFlags & WINDOW_FLAG_DECORATION);
|
||||
REQUIRE(menu->window.rect.x == Approx(420));
|
||||
REQUIRE(menu->window.rect.y == Approx(1337));
|
||||
REQUIRE(menu->window.rect.w == Approx(12));
|
||||
REQUIRE(menu->window.rect.h == Approx(64));
|
||||
REQUIRE_THAT(menu->window.rect.x, WithinRel(420.0f));
|
||||
REQUIRE_THAT(menu->window.rect.y, WithinRel(1337.0f));
|
||||
REQUIRE_THAT(menu->window.rect.w, WithinRel(12.0f));
|
||||
REQUIRE_THAT(menu->window.rect.h, WithinRel(64.0f));
|
||||
REQUIRE(menu->window.rect.horzAlign == 1);
|
||||
REQUIRE(menu->window.rect.vertAlign == 2);
|
||||
REQUIRE(menu->window.style == 5);
|
||||
@ -250,16 +253,16 @@ namespace test::game::iw4::menu::parsing::it
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventData.unconditionalScript == R"("setColor" "1" "0.5" "0.1" "1" ; )"s);
|
||||
|
||||
REQUIRE(menu->window.border == 1);
|
||||
REQUIRE(menu->window.borderSize == Approx(1.25));
|
||||
REQUIRE(menu->window.borderSize == Approx(1.25));
|
||||
REQUIRE(menu->window.backColor[0] == Approx(1));
|
||||
REQUIRE(menu->window.backColor[1] == Approx(0.8));
|
||||
REQUIRE(menu->window.backColor[2] == Approx(0.4));
|
||||
REQUIRE(menu->window.backColor[3] == Approx(0.95));
|
||||
REQUIRE(menu->window.foreColor[0] == Approx(0.7));
|
||||
REQUIRE(menu->window.foreColor[1] == Approx(0));
|
||||
REQUIRE(menu->window.foreColor[2] == Approx(0));
|
||||
REQUIRE(menu->window.foreColor[3] == Approx(0));
|
||||
REQUIRE_THAT(menu->window.borderSize, WithinRel(1.25f));
|
||||
REQUIRE_THAT(menu->window.borderSize, WithinRel(1.25));
|
||||
REQUIRE_THAT(menu->window.backColor[0], WithinRel(1.0f));
|
||||
REQUIRE_THAT(menu->window.backColor[1], WithinRel(0.8f));
|
||||
REQUIRE_THAT(menu->window.backColor[2], WithinRel(0.4f));
|
||||
REQUIRE_THAT(menu->window.backColor[3], WithinRel(0.95f));
|
||||
REQUIRE_THAT(menu->window.foreColor[0], WithinRel(0.7f));
|
||||
REQUIRE_THAT(menu->window.foreColor[1], WithinRel(0.0f));
|
||||
REQUIRE_THAT(menu->window.foreColor[2], WithinRel(0.0f));
|
||||
REQUIRE_THAT(menu->window.foreColor[3], WithinRel(0.0f));
|
||||
REQUIRE(menu->window.background == funnyDogMaterial);
|
||||
|
||||
REQUIRE(menu->onKey != nullptr);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerScript.h"
|
||||
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerSetLocalVar.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/Menu/Sequence/ItemScopeSequences.h"
|
||||
|
@ -1,2 +0,0 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
@ -48,5 +48,6 @@ function ParserTestUtils:project()
|
||||
catch2:include(includes)
|
||||
|
||||
links:linkto(Parser)
|
||||
links:linkto(catch2)
|
||||
links:linkall()
|
||||
end
|
||||
|
@ -49,5 +49,6 @@ function ParserTests:project()
|
||||
|
||||
links:linkto(ParserTestUtils)
|
||||
links:linkto(Parser)
|
||||
links:linkto(catch2)
|
||||
links:linkall()
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||
#include "Parsing/Mock/MockParserLineStream.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Impl/DefinesStreamProxy.h"
|
||||
#include "Parsing/Mock/MockParserLineStream.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Impl/IncludingStreamProxy.h"
|
||||
#include "Parsing/Mock/MockParserLineStream.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Impl/PackDefinitionStreamProxy.h"
|
||||
#include "Parsing/Mock/MockParserLineStream.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
@ -49,5 +49,6 @@ function ZoneCodeGeneratorLibTests:project()
|
||||
|
||||
links:linkto(ZoneCodeGeneratorLib)
|
||||
links:linkto(ParserTestUtils)
|
||||
links:linkto(catch2)
|
||||
links:linkall()
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Commands/Impl/CommandsLexer.h"
|
||||
#include "Parsing/Mock/MockParserLineStream.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceAction.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceArchitecture.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceGame.h"
|
||||
|
@ -1,8 +1,12 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Header/Impl/HeaderLexer.h"
|
||||
#include "Parsing/Mock/MockParserLineStream.h"
|
||||
|
||||
using namespace Catch::Matchers;
|
||||
|
||||
namespace test::parsing::header::impl::header_lexer
|
||||
{
|
||||
void ExpectCharacterToken(HeaderLexer& lexer, char c)
|
||||
@ -22,7 +26,8 @@ namespace test::parsing::header::impl::header_lexer
|
||||
void ExpectFloatingPointToken(HeaderLexer& lexer, double number)
|
||||
{
|
||||
REQUIRE(lexer.GetToken(0).m_type == HeaderParserValueType::FLOATING_POINT);
|
||||
REQUIRE(lexer.GetToken(0).FloatingPointValue() == Approx(number));
|
||||
const auto a = lexer.GetToken(0).FloatingPointValue();
|
||||
REQUIRE_THAT(lexer.GetToken(0).FloatingPointValue(), WithinRel(number));
|
||||
lexer.PopTokens(1);
|
||||
}
|
||||
|
||||
@ -250,7 +255,7 @@ namespace test::parsing::header::impl::header_lexer
|
||||
ExpectIdentifierToken(lexer, "a");
|
||||
ExpectIdentifierToken(lexer, "b");
|
||||
ExpectFloatingPointToken(lexer, 36.999);
|
||||
ExpectFloatingPointToken(lexer, 59595.2412);
|
||||
ExpectFloatingPointToken(lexer, 59595.2414);
|
||||
ExpectIdentifierToken(lexer, "c");
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Parsing/Header/Sequence/SequenceNamespace.h"
|
||||
#include "Parsing/Mock/MockLexer.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
@ -1,2 +0,0 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
@ -49,6 +49,7 @@ function ZoneCommonTests:project()
|
||||
catch2:include(includes)
|
||||
|
||||
links:linkto(ZoneCommon)
|
||||
links:linkto(catch2)
|
||||
links:linkall()
|
||||
|
||||
ZoneCode:use()
|
||||
|
@ -1,2 +0,0 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
2
thirdparty/catch2
vendored
2
thirdparty/catch2
vendored
@ -1 +1 @@
|
||||
Subproject commit de6fe184a9ac1a06895cdd1c9b437f0a0bdf14ad
|
||||
Subproject commit 3f0283de7a9c43200033da996ff9093be3ac84dc
|
65
thirdparty/catch2.lua
vendored
65
thirdparty/catch2.lua
vendored
@ -3,12 +3,14 @@ catch2 = {}
|
||||
function catch2:include(includes)
|
||||
if includes:handle(self:name()) then
|
||||
includedirs {
|
||||
path.join(ThirdPartyFolder(), "catch2", "single_include")
|
||||
path.join(ThirdPartyFolder(), "catch2", "src"),
|
||||
"%{wks.location}/thirdparty/catch2"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function catch2:link()
|
||||
function catch2:link(links)
|
||||
links:add(self:name())
|
||||
end
|
||||
|
||||
function catch2:use()
|
||||
@ -20,4 +22,63 @@ function catch2:name()
|
||||
end
|
||||
|
||||
function catch2:project()
|
||||
local folder = ThirdPartyFolder()
|
||||
local includes = Includes:create()
|
||||
|
||||
self:writeUserConfig()
|
||||
|
||||
project(self:name())
|
||||
targetdir(TargetDirectoryLib)
|
||||
location "%{wks.location}/thirdparty/%{prj.name}"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
path.join(folder, "catch2/src/**.cpp"),
|
||||
path.join(folder, "catch2/src/**.hpp"),
|
||||
"%{wks.location}/thirdparty/%{prj.name}/**.cpp",
|
||||
"%{wks.location}/thirdparty/%{prj.name}/**.hpp"
|
||||
}
|
||||
|
||||
vpaths {
|
||||
["*"] = {
|
||||
path.join(folder, "catch2/src"),
|
||||
"%{wks.location}/thirdparty/%{prj.name}"
|
||||
}
|
||||
}
|
||||
|
||||
defines {
|
||||
"DO_NOT_USE_WMAIN",
|
||||
"_CRT_SECURE_NO_WARNINGS"
|
||||
}
|
||||
|
||||
self:include(includes)
|
||||
|
||||
-- Disable warnings. They do not have any value to us since it is not our code.
|
||||
warnings "off"
|
||||
end
|
||||
|
||||
function catch2:writeUserConfig()
|
||||
local folder = ThirdPartyFolder()
|
||||
local inputFileName = path.join(folder, "catch2/src/catch2/catch_user_config.hpp.in")
|
||||
local outputFileName = path.getabsolute("build/thirdparty/catch2/catch2/catch_user_config.hpp")
|
||||
|
||||
local inputInfo = os.stat(inputFileName)
|
||||
local outputInfo = os.stat(outputFileName)
|
||||
|
||||
if inputInfo == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if outputInfo ~= nil and inputInfo.mtime <= outputInfo.mtime then
|
||||
return
|
||||
end
|
||||
|
||||
local fileData = io.readfile(inputFileName)
|
||||
fileData = string.gsub(fileData, '#cmakedefine[^\n]*', '')
|
||||
fileData = string.gsub(fileData, '@CATCH_CONFIG_CONSOLE_WIDTH@', '80')
|
||||
fileData = string.gsub(fileData, '@CATCH_CONFIG_DEFAULT_REPORTER@', 'console')
|
||||
|
||||
os.mkdir(path.getdirectory(outputFileName))
|
||||
os.writefile_ifnotequal(fileData, outputFileName)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user