From 282a0435c3ea21d36ad23c35d58c20958d4664f5 Mon Sep 17 00:00:00 2001 From: Shamy <110725453+shamykyzer@users.noreply.github.com> Date: Wed, 2 Jul 2025 08:25:30 +0300 Subject: [PATCH 1/3] Fix workflow dependency installation --- .github/workflows/c-cpp.yml | 48 ++++++++++++++++++++++++++++++------- .gitignore | 2 ++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 69a4793..738a6e8 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -7,17 +7,47 @@ on: branches: [ "main" ] jobs: + installing-dependencies: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + build: + runs-on: ubuntu-latest + needs: installing-dependencies + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Build + run: make + test: runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Test + run: make test + make: + runs-on: ubuntu-latest + needs: test steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev - - name: Build - run: make - - name: Test - run: make test + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Make + run: make diff --git a/.gitignore b/.gitignore index 392d5f9..1cf7a02 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ obj/ # Object files *.o src/*.o +gravity-simulation/ +tests/test_quadtree From dc41eec9992d72f9e646977cb83eb99f3440fbad Mon Sep 17 00:00:00 2001 From: Shamy <110725453+shamykyzer@users.noreply.github.com> Date: Wed, 2 Jul 2025 08:36:29 +0300 Subject: [PATCH 2/3] Use Docker container and cache build --- .github/workflows/c-cpp.yml | 50 +++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 738a6e8..51fe13a 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -9,45 +9,63 @@ on: jobs: installing-dependencies: runs-on: ubuntu-latest + container: ghcr.io/gravity-sim/deps:latest steps: - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} + - name: Setup complete + run: echo "Dependencies are pre-installed in the container" build: runs-on: ubuntu-latest needs: installing-dependencies + container: ghcr.io/gravity-sim/deps:latest steps: - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Restore build cache + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} - name: Build run: make test: runs-on: ubuntu-latest needs: build + container: ghcr.io/gravity-sim/deps:latest steps: - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Restore build cache + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} - name: Test run: make test make: runs-on: ubuntu-latest needs: test + container: ghcr.io/gravity-sim/deps:latest steps: - uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + - name: Restore build cache + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} - name: Make run: make From 80460b0617cce4b5b54a64943cd47bdad61b8f2b Mon Sep 17 00:00:00 2001 From: Shamy <110725453+shamykyzer@users.noreply.github.com> Date: Wed, 2 Jul 2025 08:36:34 +0300 Subject: [PATCH 3/3] Refine CI workflow and document container-based steps --- .github/workflows/c-cpp.yml | 12 ++++++++++-- README.md | 9 +++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 51fe13a..75d5164 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -7,7 +7,8 @@ on: branches: [ "main" ] jobs: - installing-dependencies: + install-dependencies: + name: Installing Dependencies runs-on: ubuntu-latest container: ghcr.io/gravity-sim/deps:latest steps: @@ -19,12 +20,14 @@ jobs: src/*.o tests/*.o key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} + restore-keys: ${{ runner.os }}-build- - name: Setup complete run: echo "Dependencies are pre-installed in the container" build: + name: Build runs-on: ubuntu-latest - needs: installing-dependencies + needs: install-dependencies container: ghcr.io/gravity-sim/deps:latest steps: - uses: actions/checkout@v4 @@ -35,10 +38,12 @@ jobs: src/*.o tests/*.o key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} + restore-keys: ${{ runner.os }}-build- - name: Build run: make test: + name: Test runs-on: ubuntu-latest needs: build container: ghcr.io/gravity-sim/deps:latest @@ -51,10 +56,12 @@ jobs: src/*.o tests/*.o key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} + restore-keys: ${{ runner.os }}-build- - name: Test run: make test make: + name: Make runs-on: ubuntu-latest needs: test container: ghcr.io/gravity-sim/deps:latest @@ -67,5 +74,6 @@ jobs: src/*.o tests/*.o key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }} + restore-keys: ${{ runner.os }}-build- - name: Make run: make diff --git a/README.md b/README.md index e52a7bc..5370b9c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This project is a continuation of fluid simulation concepts, extended to simulat - [Installation](#installation) - [Build](#build) - [Usage](#usage) +- [Continuous Integration](#continuous-integration) - [Project Layout](#project-layout) - [Acknowledgments](#acknowledgments) - [License](#license) @@ -74,6 +75,14 @@ To set up and compile the project on your local machine, follow these steps: ./gravity_simulation ``` +## Continuous Integration + +This project uses a GitHub Actions workflow that runs inside a prebuilt Docker +container containing all required OpenGL dependencies. The workflow consists of +four sequential jobs: **Installing Dependencies**, **Build**, **Test**, and +**Make**. Compiled object files are cached between jobs to speed up subsequent +steps. + ## Usage To run the simulation: