From 2d8b65ba74c6a3b4808bb786e70ee95d609c9f47 Mon Sep 17 00:00:00 2001 From: DK Date: Thu, 7 Sep 2023 15:35:39 -0500 Subject: [PATCH] feat: main ci action (#11) + auto build (no test suites) for msvc/clang-cl with debug/release configuration + mainteinance set to on build success + mainteinance also updates vcpkg.json `version-date`, **not vcpkg registry** + updates README.md with vcpkg version and build status accordingly --- .../cmake => .github}/make-directives.ps1 | 0 .github/update-registry.ps1 | 30 ++++++++++++ .github/workflows/main_ci.yml | 49 +++++++++++++++++++ .github/workflows/maintenance.yml | 36 +++++++++++--- CommonLibSF/CMakePresets.json | 8 +-- CommonLibSF/vcpkg.json | 4 +- README.md | 9 ++-- 7 files changed, 119 insertions(+), 17 deletions(-) rename {CommonLibSF/cmake => .github}/make-directives.ps1 (100%) create mode 100644 .github/update-registry.ps1 create mode 100644 .github/workflows/main_ci.yml diff --git a/CommonLibSF/cmake/make-directives.ps1 b/.github/make-directives.ps1 similarity index 100% rename from CommonLibSF/cmake/make-directives.ps1 rename to .github/make-directives.ps1 diff --git a/.github/update-registry.ps1 b/.github/update-registry.ps1 new file mode 100644 index 00000000..6bb24b5f --- /dev/null +++ b/.github/update-registry.ps1 @@ -0,0 +1,30 @@ +#Requires -Version 5 + +# args +param ( + [string]$PathIn +) + +# test-path +if (!(Test-Path "$PathIn/CommonLibSF") -or !(Test-Path "$PathIn/CommonLibSF/vcpkg.json") -or !(Test-Path "$PathIn/README.md")) { + Write-Output "::set-output name=VCPKG_SUCCESS::false" + exit +} + +# commit time +$version = (Get-Date -AsUTC -Format "yyyy-MM-dd") + +# update vcpkg +$vcpkg = [IO.File]::ReadAllText("$PathIn/CommonLibSF/vcpkg.json") | ConvertFrom-Json +$vcpkg.'version-date' = $version +$vcpkg = $vcpkg | ConvertTo-Json -Depth 9 | ForEach-Object { $_ -replace "(?m) (?<=^(?: )*)", " " } +[IO.File]::WriteAllText("$PathIn/CommonLibSF/vcpkg.json", $vcpkg) + +# update readme +$readme = [IO.File]::ReadAllLines("$PathIn/README.md") +$readme = $readme -replace "(?<=label=vcpkg&message=).+?(?=&color)", $version +[IO.File]::WriteAllLines("$PathIn/README.md", $readme) + +# status +Write-Output "::set-output name=VCPKG_SUCCESS::true" +Write-Output "::set-output name=VCPKG_VERSION::$version" diff --git a/.github/workflows/main_ci.yml b/.github/workflows/main_ci.yml new file mode 100644 index 00000000..d42797cf --- /dev/null +++ b/.github/workflows/main_ci.yml @@ -0,0 +1,49 @@ +name: Main CI + +on: + push: + branches: [ main ] + paths: + - '.github/workflows/main_ci.yml' + - 'CommonLibSF/**' + pull_request: + branches: [ main, feature/* ] + workflow_dispatch: + +env: + VCPKG_COMMIT_ID: 095ee8757ec933b22d445738d2dbb1ce89bb8021 + +jobs: + build-and-test-vcpkg: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + build-type: + - debug + - release + compiler: + - msvc + - clang-cl + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup MSVC Environment + uses: ilammy/msvc-dev-cmd@v1.10.0 + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }} + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.14 + with: + cmake-version: '3.26' + + - name: Generate + run: cmake -B "${{ github.workspace }}/build" -S "${{ github.workspace }}/CommonLibSF" --preset=build-debug-${{ matrix.compiler }} + + - name: Build + run: cmake --build "${{ github.workspace }}/build" --config ${{ matrix.build-type }} \ No newline at end of file diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml index d5e73e6f..f3780938 100644 --- a/.github/workflows/maintenance.yml +++ b/.github/workflows/maintenance.yml @@ -1,26 +1,46 @@ -on: [push] +name: "Maintainance" + +on: + workflow_run: + workflows: ["Main CI"] + types: + - completed jobs: maintainance: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v2 - - shell: pwsh - run: "& ${{ github.workspace }}/CommonLibSF/cmake/make-directives.ps1 ${{ github.workspace }}/CommonLibSF" + - name: Update Starfield.h + shell: pwsh + run: "& ${{ github.workspace }}/.github/make-directives.ps1 ${{ github.workspace }}/CommonLibSF" - - uses: DoozyX/clang-format-lint-action@v0.16.2 + - name: Enforce style formatting + uses: DoozyX/clang-format-lint-action@v0.16.2 with: source: '.' exclude: './docs' - extensions: 'c,cc,cpp,cxx,h,hpp,hxx,inl,inc,ixx' + extensions: 'c,cc,cpp,cppm,cxx,h,hpp,hxx,inl,inc,ixx,mxx' clangFormatVersion: 16 inplace: True + + - name: Update vcpkg version-date + id: versioning + shell: pwsh + run: "& ${{ github.workspace }}/.github/update-registry.ps1 ${{ github.workspace }}" + + - name: Check for success + run: exit 1 + if: ${{ steps.versioning.outputs.VCPKG_SUCCESS == 'false' }} - - uses: EndBug/add-and-commit@v9 + - name: Check for commit + uses: EndBug/add-and-commit@v9 with: author_name: maintenance - message: 'chore: maintenance' + message: 'ci: maintenance `${{ steps.versioning.outputs.VCPKG_VERSION }}`' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CommonLibSF/CMakePresets.json b/CommonLibSF/CMakePresets.json index 8a73393c..d29863b0 100644 --- a/CommonLibSF/CMakePresets.json +++ b/CommonLibSF/CMakePresets.json @@ -2,7 +2,7 @@ "version": 3, "cmakeMinimumRequired": { "major": 3, - "minor": 21, + "minor": 26, "patch": 0 }, "configurePresets": [ @@ -114,7 +114,7 @@ "environment": { "CC": "clang-cl", "CXX": "clang-cl", - "PROJECT_COMPILER_FLAGS": "/permissive- /EHsc /W4 /WX -Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-inconsistent-missing-override -Wno-reinterpret-base-class" + "PROJECT_COMPILER_FLAGS": "/permissive- /EHsc /W4 /WX -Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-inconsistent-missing-override -Wno-reinterpret-base-class -D__cpp_consteval" } }, { @@ -202,7 +202,7 @@ "inherits": [ "common", "packaging-vcpkg", - "buildtype-minsizerel", + "buildtype-debug", "generator-msvc", "compiler-msvc" ] @@ -213,7 +213,7 @@ "inherits": [ "common", "packaging-vcpkg", - "buildtype-minsizerel", + "buildtype-debug", "generator-msvc", "compiler-clang-cl" ] diff --git a/CommonLibSF/vcpkg.json b/CommonLibSF/vcpkg.json index 2cdb2aff..df4d7d47 100644 --- a/CommonLibSF/vcpkg.json +++ b/CommonLibSF/vcpkg.json @@ -1,11 +1,11 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "commonlibsf", - "version-semver": "1.0.0", + "version-date": "2023-09-07", "port-version": 0, "description": "CommonLibSF, the collaborative effort with advanced features for modern SFSE development.", "homepage": "https://github.com/Starfield-Reverse-Engineering/CommonLibSF", - "license": "MIT", + "license": "GPL-3.0-or-later", "supports": "windows & x64", "dependencies": [ { diff --git a/README.md b/README.md index 2bf743b6..03199993 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ A collaborative reverse-engineered library for Starfield. -[![C++23](https://img.shields.io/static/v1?label=standard&message=c%2B%2B23&color=blue&logo=c%2B%2B&&logoColor=red&style=flat)]( -https://en.cppreference.com/w/cpp/compiler_support) +[![C++23](https://img.shields.io/static/v1?label=standard&message=c%2B%2B23&color=blue&logo=c%2B%2B&&logoColor=red&style=flat)](https://en.cppreference.com/w/cpp/compiler_support) ![Platform](https://img.shields.io/static/v1?label=platform&message=windows&color=dimgray&style=flat&logo=windows) -[![Game version](https://img.shields.io/badge/game%20version-1.7.23-orange)](#use) +[![Game version](https://img.shields.io/badge/game%20version-1.7.23-orange)](#Get-started) +[![VCPKG_VER](https://img.shields.io/static/v1?label=vcpkg&message=2023-09-07&color=green&style=flat)](https://github.com/Starfield-Reverse-Engineering/Starfield-RE-vcpkg) +[![Main CI](https://img.shields.io/github/actions/workflow/status/Starfield-Reverse-Engineering/CommonLibSF/main_ci.yml)](https://github.com/Starfield-Reverse-Engineering/CommonLibSF/actions/workflows/main_ci.yml) ## Build Dependencies + [CMake 3.26+](https://cmake.org/) @@ -15,6 +16,8 @@ https://en.cppreference.com/w/cpp/compiler_support) + Add the environment variable VCPKG_ROOT with the value as the path to the folder containing vcpkg + [Visual Studio Community 2022](https://visualstudio.microsoft.com/) + Desktop development with C++ + + *ClangCL toolset and build support if using clang-cl configuration + ## Get started ### use example plugin template