Update .woodpecker/default.yml

This commit is contained in:
nyosic 2025-04-04 13:05:03 +00:00
parent 5197f4e7c6
commit 976542688c

View file

@ -1,54 +1,52 @@
---
kind: pipeline
name: default
steps: steps:
- name: Build the C++ project # Step 1: Build and Test the C++ Project
image: gcc:13 - name: build
image: gcc:latest
environment: environment:
BUILD_DIR: build - CC=gcc
- CXX=g++
commands: commands:
- echo "[*] Installing dependencies" # Cache CMake dependencies
- apt-get update && apt-get install -y cmake make g++ git - mkdir -p ~/.cache/woodpecker/cmake
- echo "[*] Removing existing source directory" - cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H.
- rm -rf /woodpecker/src # Remove the existing source directory - cmake --build build --target all
- echo "[*] Cloning repository"
- git clone https://git.xyro.win/nyosic/MarioDB.git /woodpecker/src
- chmod -R 777 /woodpecker/src
- echo "[*] Creating build directory"
- mkdir -p $BUILD_DIR
- cd $BUILD_DIR
- echo "[*] Running CMake"
- cmake /woodpecker/src
- echo "[*] Building project"
- make -j$(nproc)
- name: Run tests # Run tests
image: gcc:13 - cd build && ctest --output-on-failure
environment:
BUILD_DIR: build # Create the release directory
- mkdir -p release
- cp build/your_program release/
# Step 2: Cache Dependencies to Speed Up Builds
- name: cache
image: alpine:latest
commands: commands:
- echo "[*] Running tests" - echo "Caching build dependencies"
- cd $BUILD_DIR - mkdir -p ~/.cache/woodpecker
- ctest --output-on-failure || echo "[!] Some tests failed" - mv ~/.cache/woodpecker/cmake /root/.cache/woodpecker/cmake
- name: Check code formatting volumes:
image: gcc:13 - ~/.cache/woodpecker:/root/.cache/woodpecker
commands:
- apt-get update && apt-get install -y clang-format
- echo "[*] Checking code formatting..."
- find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' | xargs clang-format --dry-run --Werror
- name: Cache build directory # Step 3: Upload Release Artifact
image: alpine - name: release
image: woodpeckerci/release:latest
settings: settings:
paths: api_key: ${GITEA_TOKEN} # Set your API key (GitHub, GitLab, etc.)
- build target: 'MarioDB' # Replace with your project's name
files:
- release/your_program # Replace with your actual binary name
- name: Create release in Gitea
image: woodpeckerci/plugin-gitea-release
when: when:
branch:
- main # Trigger release only on the main branch
trigger:
event: event:
- tag # Trigger only on tags - push
environment: - pull_request
GITEA_URL: "https://git.xyro.win"
GITEA_TOKEN: "${GITEA_TOKEN}" # Make sure to set this secret in the Woodpecker UI
REPO_NAME: "MarioDB" # Replace with your actual repository name
TAG_NAME: "${CI_COMMIT_REF}" # Use the commit reference (tag name)
ASSET_PATH: "build/main" # Path to the compiled C++ binary