Added Github actions to handle PR pipelines (#147)

Replaced old azure pipeline CI with Github actions.
This commit is contained in:
Sergio R. Z. Masson 2024-09-05 14:31:06 -03:00 коммит произвёл GitHub
Родитель d01d109037
Коммит 187f76f565
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 180 добавлений и 265 удалений

31
.github/workflows/ci.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,31 @@
name: Master - CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: 0 23 * * 1-5
jobs:
# Windows
build-windows:
uses: ./.github/workflows/windows.yml
with:
cmake-version: '3.26.3'
platforms: "['x64', 'Win32', 'ARM', 'ARM64']"
configurations: "['Release', 'Debug']"
# MacOS
build-macos:
uses: ./.github/workflows/macos.yml
with:
cmake-version: '3.26.3'
platforms: "['macOS']"
configurations: "['Release', 'Debug']"
# iOS
build-ios:
uses: ./.github/workflows/ios.yml
with:
cmake-version: '3.26.3'
platforms: "['iOS']"
configurations: "['Release', 'Debug']"

36
.github/workflows/ios.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,36 @@
name: 'build ios'
on:
workflow_call:
inputs:
cmake-version:
required: true
type: string
platforms:
required: true
type: string
configurations:
required: true
type: string
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
platform: ${{ fromJson(inputs.platforms) }}
config: ${{ fromJson(inputs.configurations) }}
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2.0.2
with:
cmake-version: ${{ inputs.cmake-version }}
- name: CMake Configure
run: cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/Build/CMake/ios.toolchain.cmake" -DPLATFORM=OS -DDEPLOYMENT_TARGET="10.11" -DENABLE_UNIT_TESTS="OFF" -B ./built/Int/cmake_${{ matrix.platform }} .
- name: CMake Build
run: cmake --build . --target install --config ${{ matrix.config }}
working-directory: ./built/Int/cmake_${{ matrix.platform }}

44
.github/workflows/macos.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,44 @@
name: 'build macos'
on:
workflow_call:
inputs:
cmake-version:
required: true
type: string
platforms:
required: true
type: string
configurations:
required: true
type: string
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
platform: ${{ fromJson(inputs.platforms) }}
config: ${{ fromJson(inputs.configurations) }}
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2.0.2
with:
cmake-version: ${{ inputs.cmake-version }}
- name: CMake Configure
run: cmake -G Xcode -B ./built/Int/cmake_${{ matrix.platform }} .
- name: CMake Build
run: cmake --build . --target install --config ${{ matrix.config }}
working-directory: ./built/Int/cmake_${{ matrix.platform }}
- name: Running Unit Tests
run: ./GLTFSDK.Test --gtest_output=xml:GLTFSDK.Test.log
working-directory: ./built/Out/${{ matrix.platform }}/${{ matrix.config }}/GLTFSDK.Test
- uses: actions/upload-artifact@v4
name: "Upload test results"
with:
name: GLTFSDK.Test.MacOS.${{ matrix.platform }}.${{ matrix.config }}
path: ${{ github.workspace }}/built/Out/${{ matrix.platform }}/${{ matrix.config }}/GLTFSDK.Test/GLTFSDK.Test.log

46
.github/workflows/windows.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,46 @@
name: 'build windows'
on:
workflow_call:
inputs:
cmake-version:
required: true
type: string
platforms:
required: true
type: string
configurations:
required: true
type: string
jobs:
build:
runs-on: windows-2019
strategy:
matrix:
platform: ${{ fromJson(inputs.platforms) }}
config: ${{ fromJson(inputs.configurations) }}
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2.0.2
with:
cmake-version: ${{ inputs.cmake-version }}
- name: CMake Configure
run: cmake -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -B ./built/Int/cmake_${{ matrix.platform }} .
- name: CMake Build
run: cmake --build . --target install --config ${{ matrix.config }}
working-directory: ./built/Int/cmake_${{ matrix.platform }}
- name: Running Unit Tests
if: ${{ (matrix.platform == 'x64') || (matrix.platform == 'Win32') }}
run: .\GLTFSDK.Test.exe --gtest_output=xml:GLTFSDK.Test.log
working-directory: ./built/Out/windows_${{ matrix.platform }}\${{ matrix.config }}\GLTFSDK.Test
- uses: actions/upload-artifact@v4
name: "Upload test results"
if: ${{ (matrix.platform == 'x64') || (matrix.platform == 'Win32') }}
with:
name: GLTFSDK.Test.Windows.${{ matrix.platform }}.${{ matrix.config }}
path: ${{ github.workspace }}\built\Out\windows_${{ matrix.platform }}\${{ matrix.config }}\GLTFSDK.Test\GLTFSDK.Test.log

Просмотреть файл

@ -1,255 +0,0 @@
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
jobs:
- job: Windows_VS2019
pool:
vmImage: 'windows-2019'
strategy:
matrix:
Win32-Release:
buildPlatform: Win32
buildConfiguration: Release
Win32-Debug:
buildPlatform: Win32
buildConfiguration: Debug
x64-Release:
buildPlatform: x64
buildConfiguration: Release
x64-Debug:
buildPlatform: x64
buildConfiguration: Debug
ARM-Release:
buildPlatform: ARM
buildConfiguration: Release
ARM-Debug:
buildPlatform: ARM
buildConfiguration: Debug
ARM64-Release:
buildPlatform: ARM64
buildConfiguration: Release
ARM64-Debug:
buildPlatform: ARM64
buildConfiguration: Debug
workspace:
clean: all
steps:
- task: CMake@1
inputs:
workingDirectory: 'built\Int\cmake_$(buildPlatform)'
cmakeArgs: '..\..\.. -G "Visual Studio 16 2019" -A "$(buildPlatform)"'
- task: CMake@1
inputs:
workingDirectory: 'built\Int\cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration) -- /m'
- script: .\GLTFSDK.Test.exe --gtest_output=xml:GLTFSDK.Test.log
workingDirectory: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test
displayName: Running Unit Tests
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test\GLTFSDK.Test.log
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))
- job: WindowsVcPkg_VS2019
pool:
vmImage: 'windows-2019'
strategy:
matrix:
Win32-Release:
buildPlatform: Win32
buildConfiguration: Release
vcpkgTriplet: x86-windows
Win32-Debug:
buildPlatform: Win32
buildConfiguration: Debug
vcpkgTriplet: x86-windows
x64-Release:
buildPlatform: x64
buildConfiguration: Release
vcpkgTriplet: x64-windows
x64-Debug:
buildPlatform: x64
buildConfiguration: Debug
vcpkgTriplet: x64-windows
ARM-Release:
buildPlatform: ARM
buildConfiguration: Release
vcpkgTriplet: arm-windows
ARM-Debug:
buildPlatform: ARM
buildConfiguration: Debug
vcpkgTriplet: arm-windows
ARM64-Release:
buildPlatform: ARM64
buildConfiguration: Release
vcpkgTriplet: arm64-windows
ARM64-Debug:
buildPlatform: ARM64
buildConfiguration: Debug
vcpkgTriplet: arm64-windows
workspace:
clean: all
variables:
vcpkgRoot: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
steps:
- powershell: vcpkg install --triplet "$(vcpkgTriplet)" rapidjson gtest
displayName: Install packages with VcPkg
- task: CMake@1
inputs:
workingDirectory: 'built\Int\cmake_$(buildPlatform)'
cmakeArgs: '..\..\.. -G "Visual Studio 16 2019" -A "$(buildPlatform)" -DCMAKE_TOOLCHAIN_FILE="$(vcpkgRoot)" -DVCPKG_TARGET_TRIPLET="$(vcpkgTriplet)"'
- task: CMake@1
inputs:
workingDirectory: 'built\Int\cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration) -- /m'
# copy googletest related dll files
- task: CopyFiles@2
inputs:
sourceFolder: 'built\Int\cmake_$(buildPlatform)\GLTFSDK.Test\$(buildConfiguration)'
contents: 'gtest*.dll'
targetFolder: 'built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test'
overWrite: true
condition: in(variables['buildPlatform'], 'Win32', 'x64')
- script: .\GLTFSDK.Test.exe --gtest_output=xml:GLTFSDK.Test.log
workingDirectory: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test
displayName: Running Unit Tests
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test\GLTFSDK.Test.log
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))
- job: MacOS
pool:
vmImage: 'macos-latest'
strategy:
matrix:
macOS-Release:
buildPlatform: macOS
buildConfiguration: Release
macOS-Debug:
buildPlatform: macOS
buildConfiguration: Debug
workspace:
clean: all
steps:
- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '../../.. -G Xcode'
- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration)'
- script: ./GLTFSDK.Test --gtest_output=xml:GLTFSDK.Test.log
workingDirectory: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test
displayName: Running Unit Tests
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test/GLTFSDK.Test.log
- job: MacOSVcPkg
pool:
vmImage: 'macos-latest'
strategy:
matrix:
macOS-Release:
buildPlatform: macOS
buildConfiguration: Release
vcpkgTriplet: x64-osx
macOS-Debug:
buildPlatform: macOS
buildConfiguration: Debug
vcpkgTriplet: x64-osx
workspace:
clean: all
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: vcpkg install --triplet "$(vcpkgTriplet)" rapidjson gtest
displayName: Install packages with VcPkg
- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '../../.. -G Xcode -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake'
- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration)'
- script: ./GLTFSDK.Test --gtest_output=xml:GLTFSDK.Test.log
workingDirectory: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test
displayName: Running Unit Tests
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test/GLTFSDK.Test.log
- job: iOS
pool:
vmImage: 'macos-latest'
strategy:
matrix:
iOS-Release:
buildPlatform: iOS
buildConfiguration: Release
iOS-Debug:
buildPlatform: iOS
buildConfiguration: Debug
workspace:
clean: all
steps:
- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '../../.. -G Xcode -DCMAKE_TOOLCHAIN_FILE="$(Build.SourcesDirectory)/Build/CMake/ios.toolchain.cmake" -DPLATFORM=OS -DDEPLOYMENT_TARGET="10.11" -DENABLE_UNIT_TESTS="OFF"'
- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration)'

Просмотреть файл

@ -82,10 +82,8 @@ namespace Microsoft
// Utility for verifying GetRotations
template<typename T>
void VerifyGetRotations()
void VerifyGetRotations(const std::vector<float>& testValues)
{
std::vector<float> testValues = { 0.213941514f, 0.963860869f, -0.158749819f, 0.204712942f };
auto readerWriter = std::make_shared<const StreamReaderWriter>();
auto bufferBuilder = BufferBuilder(std::make_unique<GLTFResourceWriter>(readerWriter));
@ -254,11 +252,14 @@ namespace Microsoft
// Verify GetRotations for all possible component types
GLTFSDK_TEST_METHOD(AnimationUtilsTests, AnimationUtils_Test_GetRotations)
{
VerifyGetRotations<float>();
VerifyGetRotations<int8_t>();
VerifyGetRotations<uint8_t>();
VerifyGetRotations<int16_t>();
VerifyGetRotations<uint16_t>();
const std::vector<float> testValues = { 0.213941514f, 0.963860869f, -0.158749819f, 0.204712942f };
const std::vector<float> testValuesPositivesOnly = { 0.213941514f, 0.963860869f, 0.158749819f, 0.204712942f };
VerifyGetRotations<float>(testValues);
VerifyGetRotations<int8_t>(testValues);
VerifyGetRotations<uint8_t>(testValuesPositivesOnly);
VerifyGetRotations<int16_t>(testValues);
VerifyGetRotations<uint16_t>(testValuesPositivesOnly);
}
};
}

Просмотреть файл

@ -13,6 +13,7 @@
#include <memory>
#include <unordered_map>
#include <sstream>
#include <limits>
using namespace glTF::UnitTest;
@ -23,11 +24,22 @@ namespace Microsoft
namespace Test
{
template <typename T>
static void AreEqual(const std::vector<T>& a, const std::vector<T>& b, wchar_t const* message = nullptr)
inline void AreEqual(const std::vector<T>& a, const std::vector<T>& b, wchar_t const* message = nullptr)
{
Assert::IsTrue(a == b, message);
}
template <>
inline void AreEqual<float>(const std::vector<float>& a, const std::vector<float>& b, wchar_t const* message)
{
const float tolerancePercentage = 0.0001f;
Assert::IsTrue(std::equal(std::begin(a), std::end(a), std::begin(b), std::end(b),
[tolerancePercentage](float a, float b){
return std::abs(a - b) <= std::abs(a * tolerancePercentage);
}), message);
}
class StreamReaderWriter : public Microsoft::glTF::IStreamWriter, public Microsoft::glTF::IStreamReader
{
public: