Updated dependencies. #253
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 ubuntu | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-program: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Step 2: Move to the parent directory and fetch dependencies | |
| - name: Fetch dependencies | |
| run: | | |
| cd .. | |
| mkdir lib | |
| cd lib | |
| git clone https://github.com/razterizer/Core.git | |
| git clone https://github.com/razterizer/Termin8or.git | |
| git clone https://github.com/razterizer/8Beat.git | |
| # git clone https://github.com/razterizer/AudioLibSwitcher_OpenAL.git --recurse-submodules | |
| git clone https://github.com/razterizer/AudioLibSwitcher_applaudio.git --recurse-submodules | |
| git clone https://github.com/razterizer/applaudio.git | |
| git clone https://github.com/razterizer/TrainOfThought.git | |
| # Step 3: Install OpenAL | |
| - name: Install OpenAL | |
| if: false | |
| run: sudo apt install libopenal-dev | |
| # Step 3: Install ALSA development packages | |
| - name: Install ALSA development packages | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install libasound2-dev pkg-config | |
| # Step 4: Change to the correct directory and build | |
| - name: Build project | |
| run: | | |
| cd Pilot_Episode | |
| ./build.sh | |
| continue-on-error: false # Ensure errors are not bypassed | |
| # Step 5: Run program | |
| - name: Run program | |
| if: false | |
| run: | | |
| cd Pilot_Episode | |
| ./bin/pilot_episode | |
| # Step 6: Upload executable for valgrind. | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: program-binary | |
| path: Pilot_Episode/bin | |
| build-program-with-locked-dependencies: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Step 2: Move to the parent directory and fetch dependencies | |
| - name: Fetch dependencies | |
| run: | | |
| cd .. | |
| ./Pilot_Episode/fetch-dependencies.py Pilot_Episode/dependencies -y | |
| # Step 3: Install OpenAL | |
| - name: Install OpenAL | |
| if: false | |
| run: sudo apt install libopenal-dev | |
| # Step 3: Install ALSA development packages | |
| - name: Install ALSA development packages | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install libasound2-dev pkg-config | |
| # Step 4: Change to the correct directory and build | |
| - name: Build project | |
| run: | | |
| cd Pilot_Episode | |
| ./build.sh | |
| continue-on-error: false # Ensure errors are not bypassed | |
| valgrind-check: | |
| runs-on: ubuntu-latest | |
| needs: build-program | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Install Valgrind | |
| run: sudo apt-get update && sudo apt-get install -y valgrind | |
| - name: Install OpenAL | |
| if: false | |
| run: sudo apt install libopenal-dev | |
| # Step 3: Install ALSA development packages | |
| - name: Install ALSA development packages | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install libasound2-dev pkg-config | |
| - name: Download binary artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: program-binary | |
| path: Pilot_Episode/bin | |
| - name: Run Valgrind | |
| run: | | |
| export ALSOFT_DRIVERS=null # disables real audio output | |
| mkdir -p valgrind-output | |
| cd Pilot_Episode | |
| # rm rec.txt # remove if any checked in. | |
| cp rec_valgrind.txt bin/rec.txt | |
| chmod +x bin/pilot_episode | |
| valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./bin/pilot_episode --log_mode replay --suppress_tty_input --suppress_tty_output --disable_audio 2>&1 | tee ../valgrind-output/valgrind.log | |
| - name: Generate Valgrind status | |
| run: | | |
| if grep -q "definitely lost: 0 bytes" valgrind-output/valgrind.log && grep -q "indirectly lost: 0 bytes" valgrind-output/valgrind.log; then | |
| echo "status: passing" > valgrind-output/valgrind-status.yml | |
| else | |
| echo "status: failing" > valgrind-output/valgrind-status.yml | |
| fi | |
| - name: Upload Valgrind status | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: valgrind-status | |
| path: | | |
| valgrind-output/valgrind-status.yml | |
| valgrind-output/valgrind.log | |
| generate-loc-badge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Step 2: Install cloc | |
| - name: Install cloc | |
| run: sudo apt-get install -y cloc | |
| # Step 3: Count C++ LOC and generate badge as SVG | |
| - name: Count C++ LOC and generate badge | |
| run: | | |
| mkdir -p badges | |
| CLOC_RESULT=$(cloc --include-ext=cpp,h --json . | jq '.SUM.code') | |
| echo "$CLOC_RESULT" | |
| if [ "$CLOC_RESULT" -lt 10000 ]; then | |
| HUMAN_READABLE=$(printf "%'d" "$CLOC_RESULT" | sed 's/,/ /g') | |
| else | |
| HUMAN_READABLE=$(awk "BEGIN { printf \"%.1f k\", $CLOC_RESULT / 1000 }") | |
| fi | |
| LABEL="C++ lines" | |
| LABEL_LEN=${#LABEL} | |
| VALUE_LEN=${#HUMAN_READABLE} | |
| # Text length in 1/10 px units (shields.io uses 90-110 per char as base) | |
| LABEL_TEXTLEN=$((LABEL_LEN * 70)) | |
| VALUE_TEXTLEN=$((VALUE_LEN * 70)) | |
| # Box widths in normal px (scale 0.1 used later) | |
| LABEL_WIDTH=$((LABEL_TEXTLEN / 10 + 10)) | |
| VALUE_WIDTH=$((VALUE_TEXTLEN / 10 + 10)) | |
| TOTAL_WIDTH=$((LABEL_WIDTH + VALUE_WIDTH)) | |
| # Positions for centered text | |
| LABEL_CENTER=$((LABEL_WIDTH * 10 / 2)) | |
| VALUE_CENTER=$((LABEL_WIDTH * 10 + VALUE_WIDTH * 10 / 2)) | |
| # Create SVG | |
| cat <<EOF > badges/loc-badge.svg | |
| <svg xmlns="http://www.w3.org/2000/svg" width="$TOTAL_WIDTH" height="20" role="img" aria-label="$LABEL: $HUMAN_READABLE"> | |
| <title>$LABEL: $HUMAN_READABLE</title> | |
| <linearGradient id="s" x2="0" y2="100%"> | |
| <stop offset="0" stop-color="#bbb" stop-opacity=".1"/> | |
| <stop offset="1" stop-opacity=".1"/> | |
| </linearGradient> | |
| <clipPath id="r"> | |
| <rect width="$TOTAL_WIDTH" height="20" rx="3" fill="#fff"/> | |
| </clipPath> | |
| <g clip-path="url(#r)"> | |
| <rect width="$LABEL_WIDTH" height="20" fill="#555"/> | |
| <rect x="$LABEL_WIDTH" width="$VALUE_WIDTH" height="20" fill="#007ec6"/> | |
| <rect width="$TOTAL_WIDTH" height="20" fill="url(#s)"/> | |
| </g> | |
| <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"> | |
| <text aria-hidden="true" x="$LABEL_CENTER" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="$LABEL_TEXTLEN">$LABEL</text> | |
| <text x="$LABEL_CENTER" y="140" transform="scale(.1)" fill="#fff" textLength="$LABEL_TEXTLEN">$LABEL</text> | |
| <text aria-hidden="true" x="$VALUE_CENTER" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="$VALUE_TEXTLEN">$HUMAN_READABLE</text> | |
| <text x="$VALUE_CENTER" y="140" transform="scale(.1)" fill="#fff" textLength="$VALUE_TEXTLEN">$HUMAN_READABLE</text> | |
| </g> | |
| </svg> | |
| EOF | |
| # Step 4: Upload badge artifact. | |
| - name: Upload LOC badge artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: loc-badge | |
| path: badges/loc-badge.svg | |
| generate-valgrind-badge: | |
| runs-on: ubuntu-latest | |
| needs: valgrind-check # Wait for valgrind to finish | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download Valgrind log artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: valgrind-status | |
| path: valgrind-output | |
| - name: Generate memory leak badge | |
| run: | | |
| mkdir -p badges | |
| VALGRIND_LOG="valgrind-output/valgrind.log" | |
| if grep -q "definitely lost: 0 bytes" "$VALGRIND_LOG" && | |
| grep -q "indirectly lost: 0 bytes" "$VALGRIND_LOG" && | |
| grep -q "possibly lost: 0 bytes" "$VALGRIND_LOG"; then | |
| STATUS="none" | |
| COLOR="4c1" | |
| else | |
| STATUS="found" | |
| COLOR="e05d44" | |
| fi | |
| LABEL="memory leaks" | |
| VALUE="$STATUS" | |
| LABEL_LEN=${#LABEL} | |
| VALUE_LEN=${#VALUE} | |
| LABEL_TEXTLEN=$((LABEL_LEN * 70)) | |
| VALUE_TEXTLEN=$((VALUE_LEN * 70)) | |
| LABEL_WIDTH=$((LABEL_TEXTLEN / 10 + 10)) | |
| VALUE_WIDTH=$((VALUE_TEXTLEN / 10 + 10)) | |
| TOTAL_WIDTH=$((LABEL_WIDTH + VALUE_WIDTH)) | |
| LABEL_CENTER=$((LABEL_WIDTH * 10 / 2)) | |
| VALUE_CENTER=$((LABEL_WIDTH * 10 + VALUE_WIDTH * 10 / 2)) | |
| cat <<EOF > badges/valgrind-badge.svg | |
| <svg xmlns="http://www.w3.org/2000/svg" width="$TOTAL_WIDTH" height="20" role="img" aria-label="$LABEL: $VALUE"> | |
| <title>$LABEL: $VALUE</title> | |
| <linearGradient id="s" x2="0" y2="100%"> | |
| <stop offset="0" stop-color="#bbb" stop-opacity=".1"/> | |
| <stop offset="1" stop-opacity=".1"/> | |
| </linearGradient> | |
| <clipPath id="r"> | |
| <rect width="$TOTAL_WIDTH" height="20" rx="3" fill="#fff"/> | |
| </clipPath> | |
| <g clip-path="url(#r)"> | |
| <rect width="$LABEL_WIDTH" height="20" fill="#555"/> | |
| <rect x="$LABEL_WIDTH" width="$VALUE_WIDTH" height="20" fill="#$COLOR"/> | |
| <rect width="$TOTAL_WIDTH" height="20" fill="url(#s)"/> | |
| </g> | |
| <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="110"> | |
| <text aria-hidden="true" x="$LABEL_CENTER" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="$LABEL_TEXTLEN">$LABEL</text> | |
| <text x="$LABEL_CENTER" y="140" transform="scale(.1)" fill="#fff" textLength="$LABEL_TEXTLEN">$LABEL</text> | |
| <text aria-hidden="true" x="$VALUE_CENTER" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="$VALUE_TEXTLEN">$VALUE</text> | |
| <text x="$VALUE_CENTER" y="140" transform="scale(.1)" fill="#fff" textLength="$VALUE_TEXTLEN">$VALUE</text> | |
| </g> | |
| </svg> | |
| EOF | |
| - name: Upload Valgrind badge artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: valgrind-badge | |
| path: badges/valgrind-badge.svg | |
| deploy-badges: | |
| runs-on: ubuntu-latest | |
| needs: [generate-loc-badge, generate-valgrind-badge] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download LOC badge | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: loc-badge | |
| path: badges | |
| - name: Download Valgrind badge | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: valgrind-badge | |
| path: badges | |
| - name: Deploy to badges branch | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./badges | |
| publish_branch: badges | |
| keep_files: true | |
| commit_message: "Update all badges" | |