Repository navigation
Updated: 强化并新增 Terminal 相关 API,实现类似 std::cout 效果 #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: | |
| workflow_call: | |
| push: | |
| branches: | |
| - main | |
| - beta | |
| pull_request: | |
| branches: | |
| - main | |
| - beta | |
| jobs: | |
| env-linux: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v4 | |
| - name: Install requirements | |
| shell: bash | |
| run: | | |
| sudo apt update | |
| sudo apt install build-essential git cmake make ninja-build libgpm-dev gpm -y | |
| - name: Compiling project | |
| shell: bash | |
| run: | | |
| mkdir -p ~/MyLibs/ | |
| cmake -B build -DCMAKE_INSTALL_PREFIX=~/MyLibs/Tiny.cpp -DCMAKE_BUILD_TYPE=Release -DTINY_USE_GPM=ON | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to configure project!" | |
| exit 1 | |
| fi | |
| cmake --build build --target install -j8 | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to compile and install!" | |
| exit 1 | |
| fi | |
| - name: Test for project | |
| shell: bash | |
| run: | | |
| cd ~/work/Tiny.cpp/Tiny.cpp/build/gtests | |
| sudo timedatectl set-timezone `curl ipconfig.io/json | grep time_zone | cut -d'"' -f4` | |
| for EXE in $(ls -1); do | |
| ./$EXE | |
| if [ $? -ne 0 ]; then | |
| echo "* Test failed: " $EXE | |
| exit 1 | |
| fi | |
| done | |
| - name: Get version | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION=$(tr -d '[:space:]' < .github/current_version.txt) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: bash | |
| run: | | |
| cd ~/MyLibs | |
| ARCH=$(uname -m) | |
| ARTIFACT_NAME="Tiny_cpp_v${{ steps.version.outputs.version }}_linux_${ARCH}" | |
| tar -czf ${ARTIFACT_NAME}.tar.gz Tiny.cpp | |
| echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ~/MyLibs/${{ steps.package.outputs.artifact_name }}.tar.gz | |
| env-macos: | |
| runs-on: macos-latest | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v4 | |
| - name: Compiling project | |
| shell: bash | |
| run: | | |
| mkdir -p ~/MyLibs/ | |
| cmake -B build -DCMAKE_INSTALL_PREFIX=~/MyLibs/Tiny.cpp -DCMAKE_BUILD_TYPE=Release | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to configure project!" | |
| exit 1 | |
| fi | |
| cmake --build build --target install -j8 | |
| if [ $? -ne 0 ]; then | |
| echo "* Failed to compile and install!" | |
| exit 1 | |
| fi | |
| - name: Test for project | |
| shell: bash | |
| run: | | |
| cd ~/work/Tiny.cpp/Tiny.cpp/build/gtests | |
| sudo rm -rf /etc/localtime | |
| TIMEZONE=`curl ipconfig.io/json | grep time_zone | cut -d'"' -f4` | |
| sudo ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime | |
| for EXE in $(ls -1); do | |
| ./$EXE | |
| if [ $? -ne 0 ]; then | |
| echo "* Test failed: " $EXE | |
| exit 1 | |
| fi | |
| done | |
| - name: Get version | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION=$(tr -d '[:space:]' < .github/current_version.txt) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: bash | |
| run: | | |
| cd ~/MyLibs | |
| ARCH=$(uname -m) | |
| ARTIFACT_NAME="Tiny_cpp_v${{ steps.version.outputs.version }}_macos_${ARCH}" | |
| tar -czf ${ARTIFACT_NAME}.tar.gz Tiny.cpp | |
| echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ~/MyLibs/${{ steps.package.outputs.artifact_name }}.tar.gz | |
| env-windows-msvc: | |
| runs-on: windows-latest | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v4 | |
| - name: Compiling project | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\MyLibs" | |
| cmake -B build -DCMAKE_INSTALL_PREFIX="$env:USERPROFILE\MyLibs\Tiny.cpp" | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Failed to configure project!" | |
| exit 1 | |
| } | |
| cmake --build build --target install --config Release -j8 | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Failed to compile and install!" | |
| exit 1 | |
| } | |
| - name: Test for project | |
| shell: pwsh | |
| run: | | |
| cd build\test | |
| $exes = Get-ChildItem -Filter *.exe | |
| foreach ($exe in $exes) { | |
| & $exe.FullName | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Test failed: " $exe.Name | |
| exit 1 | |
| } | |
| } | |
| - name: Get version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $version = (Get-Content .github\current_version.txt -Raw).Trim() | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: pwsh | |
| run: | | |
| $libDir = Join-Path $env:USERPROFILE "MyLibs" | |
| $artifactName = "Tiny_cpp_v${{ steps.version.outputs.version }}_MSVC_windows_x86_64" | |
| $dest = Join-Path $env:GITHUB_WORKSPACE "$artifactName.zip" | |
| Compress-Archive -Path (Join-Path $libDir "Tiny.cpp") -DestinationPath $dest | |
| echo "artifact_name=$artifactName" >> $env:GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ${{ github.workspace }}/${{ steps.package.outputs.artifact_name }}.zip | |
| env-windows-mingw: | |
| runs-on: windows-latest | |
| steps: | |
| - name: pull project | |
| uses: actions/checkout@v4 | |
| - name: Install MinGW | |
| shell: pwsh | |
| run: | | |
| choco install mingw -y | |
| - name: Compiling project | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\MyLibs" | |
| $env:Path += ";C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" | |
| cmake -B build -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="$env:USERPROFILE\MyLibs\Tiny.cpp" -DCMAKE_BUILD_TYPE=Release | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Failed to configure project!" | |
| exit 1 | |
| } | |
| cmake --build build --target install -j8 | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Failed to compile and install!" | |
| exit 1 | |
| } | |
| - name: Test for project | |
| shell: pwsh | |
| run: | | |
| $env:Path += ";C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" | |
| cd build\test | |
| $exes = Get-ChildItem -Filter *.exe | |
| foreach ($exe in $exes) { | |
| & $exe.FullName | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "* Test failed: " $exe.Name | |
| exit 1 | |
| } | |
| } | |
| - name: Get version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $version = (Get-Content .github\current_version.txt -Raw).Trim() | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| - name: Package artifact | |
| id: package | |
| shell: pwsh | |
| run: | | |
| $libDir = Join-Path $env:USERPROFILE "MyLibs" | |
| $artifactName = "Tiny_cpp_v${{ steps.version.outputs.version }}_mingw64_windows_x86_64" | |
| $dest = Join-Path $env:GITHUB_WORKSPACE "$artifactName.zip" | |
| Compress-Archive -Path (Join-Path $libDir "Tiny.cpp") -DestinationPath $dest | |
| echo "artifact_name=$artifactName" >> $env:GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.package.outputs.artifact_name }} | |
| path: ${{ github.workspace }}/${{ steps.package.outputs.artifact_name }}.zip | |