1
0

chore: fix github action build issue

This commit is contained in:
2026-01-22 16:35:49 +08:00
parent 6449ae1977
commit aecf9bb8cc
7 changed files with 49 additions and 19 deletions

View File

@@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail
GTest_ROOT="${GTest_ROOT:?GTest_ROOT must be set}"
benchmark_ROOT="${benchmark_ROOT:?benchmark_ROOT must be set}"
# Create build directory and enter it
mkdir bin
cd bin

View File

@@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail
GTest_ROOT="${GTest_ROOT:?GTest_ROOT must be set}"
benchmark_ROOT="${benchmark_ROOT:?benchmark_ROOT must be set}"
# Create build directory and enter it
mkdir bin
cd bin

View File

@@ -10,6 +10,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
shell: bash
run: |
sudo apt update
sudo apt install -y build-essential cmake git
@@ -20,6 +21,7 @@ jobs:
ref: 'v1.17.0'
path: 'extern/googletest'
- name: Build Google Test
shell: bash
run: |
# Build Google Test
cd extern/googletest
@@ -30,7 +32,7 @@ jobs:
cmake --install . --prefix=../install
cd ..
cd install
export GTest_ROOT=$(pwd)
echo "GTest_ROOT=$(pwd)" >> "$GITHUB_ENV"
cd ../..
- name: Fetch Google Benchmark
uses: actions/checkout@v4
@@ -39,6 +41,7 @@ jobs:
ref: 'v1.9.4'
path: 'extern/benchmark'
- name: Build Google Benchmark
shell: bash
run: |
# Build Google Benchmark
cd extern/benchmark
@@ -51,16 +54,19 @@ jobs:
cmake --install . --prefix=../install
cd ..
cd install
export benchmark_ROOT=$(pwd)
echo "benchmark_ROOT=$(pwd)" >> "$GITHUB_ENV"
cd ../..
- name: Build YYCC
shell: bash
run: |
chmod +x ./.github/linux_build.sh
./.github/linux_build.sh
- name: Run YYCC Test
shell: bash
run: |
./bin/install/bin/YYCCTest
- name: Run YYCC Benchmark
shell: bash
run: |
./bin/install/bin/YYCCBenchmark
- name: Upload Built Artifact

View File

@@ -16,6 +16,7 @@ jobs:
ref: 'v1.17.0'
path: 'extern/googletest'
- name: Build Google Test
shell: bash
run: |
# Build Google Test
cd extern/googletest
@@ -26,7 +27,7 @@ jobs:
cmake --install . --prefix=../install
cd ..
cd install
export GTest_ROOT=$(pwd)
echo "GTest_ROOT=$(pwd)" >> "$GITHUB_ENV"
cd ../..
- name: Fetch Google Benchmark
uses: actions/checkout@v4
@@ -35,6 +36,7 @@ jobs:
ref: 'v1.9.4'
path: 'extern/benchmark'
- name: Build Google Benchmark
shell: bash
run: |
# Build Google Benchmark
cd extern/benchmark
@@ -47,16 +49,19 @@ jobs:
cmake --install . --prefix=../install
cd ..
cd install
export benchmark_ROOT=$(pwd)
echo "benchmark_ROOT=$(pwd)" >> "$GITHUB_ENV"
cd ../..
- name: Build YYCC
shell: bash
run: |
chmod +x ./.github/macos_build.sh
./.github/macos_build.sh
- name: Run YYCC Test
shell: bash
run: |
./bin/install/bin/YYCCTest
- name: Run YYCC Benchmark
shell: bash
run: |
./bin/install/bin/YYCCBenchmark
- name: Upload Built Artifact

View File

@@ -23,17 +23,21 @@ jobs:
ref: 'v1.17.0'
path: 'extern/googletest'
- name: Build Google Test
shell: cmd
run: |
# Build Google Test
:: Build Google Test
cd extern/googletest
mkdir build install
mkdir build
mkdir install
cd build
cmake -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=Release ..
cmake -A x64 -DCMAKE_CXX_STANDARD=23 -Dgtest_force_shared_crt=ON ..
cmake --build . --config Release
cmake --install . --prefix=../install --config Release
cd ..
cd install
set GTest_ROOT=%CD%
:: Idk why I can't use $GITHUB_ENV, so I use this stupid way to do this.
:: This is first entry so we override it.
echo set GTest_ROOT=%CD% > ../../envs.bat
cd ../..
- name: Fetch Google Benchmark
uses: actions/checkout@v4
@@ -42,27 +46,34 @@ jobs:
ref: 'v1.9.4'
path: 'extern/benchmark'
- name: Build Google Benchmark
shell: cmd
run: |
# Build Google Benchmark
:: Build Google Benchmark
cd extern/benchmark
# Create symlink to googletest as required by benchmark
:: Create symlink to googletest as required by benchmark
mklink /D googletest ../googletest
mkdir build install
mkdir build
mkdir install
cd build
cmake -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ..
cmake -A x64 -DCMAKE_CXX_STANDARD=23 -DBENCHMARK_ENABLE_TESTING=OFF ..
cmake --build . --config Release
cmake --install . --prefix=../install --config Release
cd ..
cd install
set benchmark_ROOT=%CD%
:: This is second entry so we append it.
echo set benchmark_ROOT=%CD% >> ../../envs.bat
cd ../..
- name: Build YYCC
shell: cmd
run: |
:: Prepare Visual Studio
set VS=${{ matrix.vs }}
set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
call %VCVARS% ${{ matrix.msvc_arch }}
:: Extract saved environment variables
call .\extern\envs.bat
:: Build Project
.\.github\windows_build.bat
- name: Run YYCC Test
shell: cmd

View File

@@ -33,6 +33,11 @@
#endif
#endif
// Extern POSIX environment variables list.
#if !defined(YYCC_OS_WINDOWS)
extern char** environ;
#endif
#define SAFECAST ::yycc::num::safe_cast
#define SAFEOP ::yycc::num::safe_op
#define ENC ::yycc::encoding::windows
@@ -169,10 +174,6 @@ namespace yycc::env {
};
using SmartEnvironmentStrings = std::unique_ptr<std::remove_pointer_t<LPWCH>, EnvironmentStringsDeleter>;
#else
extern char** environ;
#endif
VarResult<std::vector<VarPair>> get_vars() {

View File

@@ -8,9 +8,10 @@ namespace yycctest::windows::console {
#if defined(YYCC_OS_WINDOWS) && defined(YYCC_STL_MSSTL)
TEST(WindowsConsole, ColorfulConsole) {
// Set colorful console should always be success.
auto rv = CONSOLE::colorful_console();
EXPECT_TRUE(rv.has_value());
// Set colorful console should always be success.
// Unless it is not a TTY.
EXPECT_TRUE(rv.has_value() || rv.error() == CONSOLE::ExecError::NotTty);
}
#endif