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 #!/bin/bash
set -euo pipefail 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 # Create build directory and enter it
mkdir bin mkdir bin
cd bin cd bin

View File

@@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
set -euo pipefail 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 # Create build directory and enter it
mkdir bin mkdir bin
cd bin cd bin

View File

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

View File

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

View File

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

View File

@@ -33,6 +33,11 @@
#endif #endif
#endif #endif
// Extern POSIX environment variables list.
#if !defined(YYCC_OS_WINDOWS)
extern char** environ;
#endif
#define SAFECAST ::yycc::num::safe_cast #define SAFECAST ::yycc::num::safe_cast
#define SAFEOP ::yycc::num::safe_op #define SAFEOP ::yycc::num::safe_op
#define ENC ::yycc::encoding::windows #define ENC ::yycc::encoding::windows
@@ -169,10 +174,6 @@ namespace yycc::env {
}; };
using SmartEnvironmentStrings = std::unique_ptr<std::remove_pointer_t<LPWCH>, EnvironmentStringsDeleter>; using SmartEnvironmentStrings = std::unique_ptr<std::remove_pointer_t<LPWCH>, EnvironmentStringsDeleter>;
#else
extern char** environ;
#endif #endif
VarResult<std::vector<VarPair>> get_vars() { 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) #if defined(YYCC_OS_WINDOWS) && defined(YYCC_STL_MSSTL)
TEST(WindowsConsole, ColorfulConsole) { TEST(WindowsConsole, ColorfulConsole) {
// Set colorful console should always be success.
auto rv = CONSOLE::colorful_console(); 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 #endif