From 78e57f0e4cb7068dcb2f71004d5878276e12c619 Mon Sep 17 00:00:00 2001 From: Shamy <110725453+shamykyzer@users.noreply.github.com> Date: Wed, 2 Jul 2025 12:18:12 +0300 Subject: [PATCH 1/2] Reorder CI jobs and update docs --- .github/workflows/c-cpp.yml | 81 +++++++++++++++++++++++++++++++------ .gitignore | 2 + README.md | 9 +++++ 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 69a4793..0cdc759 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -1,23 +1,78 @@ +--- name: C/C++ CI -on: +"on": push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: - build: + install-dependencies: + name: Installing Dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}" + restore-keys: "${{ runner.os }}-build-" + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libglfw3-dev libopenmpi-dev + test: + name: Test runs-on: ubuntu-latest + needs: install-dependencies + steps: + - uses: actions/checkout@v4 + - name: Restore build cache + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}" + restore-keys: "${{ runner.os }}-build-" + - name: Test + run: make test + build: + name: Build + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + - name: Restore build cache + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}" + restore-keys: "${{ runner.os }}-build-" + - name: Build + run: make clean && make + + make: + name: Make + 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: Build - run: make - - name: Test - run: make test + - uses: actions/checkout@v4 + - name: Restore build cache + uses: actions/cache@v3 + with: + path: | + src/*.o + tests/*.o + key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}" + restore-keys: "${{ runner.os }}-build-" + - name: Make + run: make clean && 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 diff --git a/README.md b/README.md index e52a7bc..cc3ac06 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 with four sequential jobs: +**Installing Dependencies**, **Test**, **Build**, and **Make**. Each job +installs the required packages with `apt-get`, and compiled object files are +cached between jobs to speed up subsequent runs. The build steps run +`make clean` before `make` to ensure a fresh compilation each time. + ## Usage To run the simulation: From 3a9d57b4931735d1c721c08d0d49a6700ca2810d Mon Sep 17 00:00:00 2001 From: Shamy <110725453+shamykyzer@users.noreply.github.com> Date: Wed, 2 Jul 2025 12:27:38 +0300 Subject: [PATCH 2/2] Update c-cpp.yml --- .github/workflows/c-cpp.yml | 38 ++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 3a2c3cc..9a0232a 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -13,6 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Cache APT packages + uses: actions/cache@v3 + with: + path: /var/cache/apt + key: "${{ runner.os }}-apt-${{ hashFiles('.github/workflows/c-cpp.yml') }}" + restore-keys: "${{ runner.os }}-apt-" - name: Cache build artifacts uses: actions/cache@v3 with: @@ -32,6 +38,16 @@ jobs: needs: install-dependencies steps: - uses: actions/checkout@v4 + - name: Cache APT packages + uses: actions/cache@v3 + with: + path: /var/cache/apt + key: "${{ runner.os }}-apt-${{ hashFiles('.github/workflows/c-cpp.yml') }}" + restore-keys: "${{ runner.os }}-apt-" + - 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: @@ -49,6 +65,16 @@ jobs: needs: test steps: - uses: actions/checkout@v4 + - name: Cache APT packages + uses: actions/cache@v3 + with: + path: /var/cache/apt + key: "${{ runner.os }}-apt-${{ hashFiles('.github/workflows/c-cpp.yml') }}" + restore-keys: "${{ runner.os }}-apt-" + - 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: @@ -66,6 +92,16 @@ jobs: needs: build steps: - uses: actions/checkout@v4 + - name: Cache APT packages + uses: actions/cache@v3 + with: + path: /var/cache/apt + key: "${{ runner.os }}-apt-${{ hashFiles('.github/workflows/c-cpp.yml') }}" + restore-keys: "${{ runner.os }}-apt-" + - 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: @@ -75,4 +111,4 @@ jobs: key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}" restore-keys: "${{ runner.os }}-build-" - name: Make - run: make clean && make \ No newline at end of file + run: make clean && make