diff --git a/.woodpecker/default.yml b/.woodpecker/default.yml index f8474c0..4c3bc2e 100644 --- a/.woodpecker/default.yml +++ b/.woodpecker/default.yml @@ -1,54 +1,52 @@ +--- +kind: pipeline +name: default + steps: - - name: Build the C++ project - image: gcc:13 + # Step 1: Build and Test the C++ Project + - name: build + image: gcc:latest environment: - BUILD_DIR: build + - CC=gcc + - CXX=g++ commands: - - echo "[*] Installing dependencies" - - apt-get update && apt-get install -y cmake make g++ git - - echo "[*] Removing existing source directory" - - rm -rf /woodpecker/src # Remove the existing source directory - - 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) + # Cache CMake dependencies + - mkdir -p ~/.cache/woodpecker/cmake + - cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H. + - cmake --build build --target all - - name: Run tests - image: gcc:13 - environment: - BUILD_DIR: build + # Run tests + - cd build && ctest --output-on-failure + + # 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: - - echo "[*] Running tests" - - cd $BUILD_DIR - - ctest --output-on-failure || echo "[!] Some tests failed" + - echo "Caching build dependencies" + - mkdir -p ~/.cache/woodpecker + - mv ~/.cache/woodpecker/cmake /root/.cache/woodpecker/cmake - - name: Check code formatting - image: gcc:13 - 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 + volumes: + - ~/.cache/woodpecker:/root/.cache/woodpecker - - name: Cache build directory - image: alpine + # Step 3: Upload Release Artifact + - name: release + image: woodpeckerci/release:latest settings: - paths: - - build + api_key: ${GITEA_TOKEN} # Set your API key (GitHub, GitLab, etc.) + 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: - event: - - tag # Trigger only on tags - environment: - 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 + branch: + - main # Trigger release only on the main branch + +trigger: + event: + - push + - pull_request