Skip to content

feat: add function container and logger examples #2

feat: add function container and logger examples

feat: add function container and logger examples #2

Workflow file for this run

name: ci
on:
push:
branches-ignore:
- 'ga-ignore-**'
- 'gh-pages'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UNWANTED_REGEX: '^(?!.*tests\/).*gc(no|da|ov)$|(.*\.(a|o|so|lib))$|(.*~)$|^(#.*#)$|^tmp\/.*|.*\/tmp\/.*'
jobs:
check_repository_cleanliness:
name: Checks if the repository is clean and void of any unwanted files (temp files, binary files, etc.)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Find unwanted files
run: |
UNWANTED_FILES=$(find . -type f -printf '%P\n' | grep -P "${{ env.UNWANTED_REGEX }}" || true)
if [ -n "$UNWANTED_FILES" ]; then
while IFS= read -r LINE; do
echo "::error file=${LINE},line=1,col=1,title=Unwanted file detected::${LINE}"
done <<< "$UNWANTED_FILES"
echo "FAIL_TASK=true" >> "$GITHUB_ENV"
exit 1
else
echo "FAIL_TASK=false" >> "$GITHUB_ENV"
fi
lint_code:
name: Lint with clang-format
runs-on: ubuntu-latest
steps:
- name: Check if triggered by bot
id: check_bot
env:
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
run: |
if [ "$COMMIT_AUTHOR" = "github-actions[bot]" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Commit made by github-actions[bot], skipping lint steps"
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
if: steps.check_bot.outputs.skip != 'true'
with:
token: ${{ secrets.PAT_CI_TEST }}
ref: ${{ github.ref_name }}
- name: Install clang-format
if: steps.check_bot.outputs.skip != 'true'
run: sudo apt-get install -y clang-format
- name: Run clang-format
if: steps.check_bot.outputs.skip != 'true'
run: |
git ls-files -z "*.cpp" "*.hpp" "*.inl" | while IFS= read -rd '' f; do tail -c1 < "$f" | read -r _ || echo >> "$f"; done
find . -iname '*.hpp' -o -iname '*.cpp' -o -iname '*.inl' | xargs clang-format -i
- name: Set up Git
if: steps.check_bot.outputs.skip != 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Push changes
if: steps.check_bot.outputs.skip != 'true'
env:
GITHUB_TOKEN: ${{ secrets.PAT_CI_TEST }}
run: |
git add .
git commit -m "style: apply linter" || true
git push || true
check_program_compilation:
name: Build and verify binaries
needs: [check_repository_cleanliness, lint_code]
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup Linux dependencies
if: contains(runner.os, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils
- name: Setup Windows dependencies
if: contains(runner.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
- name: Install xmake
uses: xmake-io/github-action-setup-xmake@e50494030a33fd120900e739f6418a48100cd6ce
with:
xmake-version: latest
actions-cache-folder: '.xmake-cache-${{ runner.os }}'
actions-cache-key: 'xmake-actions-cache-key-${{ runner.os }}-compilation'
package-cache: true
package-cache-key: 'xmake-package-cache-key-${{ runner.os }}-compilation'
project-path: '.'
build-cache: true
build-cache-key: 'xmake-build-cache-key-${{ runner.os }}-compilation'
build-cache-path: 'build/.build_cache'
- name: Build project
run: |
xmake f -y
xmake build -y
timeout-minutes: 30
run_tests:
name: Run tests
needs: [check_repository_cleanliness, lint_code]
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup Linux test dependencies
if: contains(runner.os, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils
sudo apt-get install -y python3 python3-pip
pip3 install gcovr
- name: Setup Windows dependencies
if: contains(runner.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
- name: Install xmake
uses: xmake-io/github-action-setup-xmake@e50494030a33fd120900e739f6418a48100cd6ce
with:
xmake-version: latest
actions-cache-folder: '.xmake-cache-${{ runner.os }}'
actions-cache-key: 'xmake-actions-cache-key-${{ runner.os }}-tests'
package-cache: true
package-cache-key: 'xmake-package-cache-key-${{ runner.os }}-tests'
project-path: '.'
- name: Run tests
run: |
xmake test -y -v
timeout-minutes: 30
- name: Check test coverage (Linux)
if: contains(runner.os, 'linux')
uses: threeal/gcovr-action@1b53388d5f84b4f3afb1b9082782961dff911ba0
check_examples:
name: Build and test examples
needs: [check_repository_cleanliness, lint_code]
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Pull latest changes
run: git pull origin ${{ github.ref_name }} || true
- name: Setup Linux dependencies
if: contains(runner.os, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils
- name: Setup Windows dependencies
if: contains(runner.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
- name: Install xmake
uses: xmake-io/github-action-setup-xmake@fadadea1162ec75ce1541d5bb68226fb147c221e
with:
xmake-version: latest
package-cache: true
project-path: '.'
build-cache: true
- name: Build and test examples
run: |
xmake f --all_examples=y -y -m debug
xmake build -y
xmake f --executable_examples=y -y -m debug
xmake run -y -v
timeout-minutes: 30