Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 27 additions & 35 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,78 @@
---
name: C/C++ CI

on:
"on":
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

jobs:
install-dependencies:
name: Installing Dependencies
runs-on: ubuntu-latest
container: ghcr.io/gravity-sim/deps:latest
steps:
- uses: actions/checkout@v4
- name: Setup complete
run: echo "Dependencies are pre-installed in the container"
- 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

build:
name: Build
runs-on: ubuntu-latest
needs: install-dependencies
container: ghcr.io/gravity-sim/deps:latest
steps:
- uses: actions/checkout@v4
- name: Restore build cache
id: build-cache
uses: actions/cache/restore@v3
uses: actions/cache@v3
with:
path: |
src/*.o
tests/*.o
key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }}
key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}"
restore-keys: "${{ runner.os }}-build-"
- name: Build
run: make
- name: Save build cache
if: steps.build-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
src/*.o
tests/*.o
key: ${{ steps.build-cache.outputs.cache-primary-key }}
run: make clean && make

test:
name: Test
runs-on: ubuntu-latest
needs: build
container: ghcr.io/gravity-sim/deps:latest
steps:
- uses: actions/checkout@v4
- name: Restore build cache
uses: actions/cache/restore@v3
uses: actions/cache@v3
with:
path: |
src/*.o
tests/*.o
key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }}
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
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
- name: Build
run: make
- name: Test
run: make test
- uses: actions/checkout@v4
- name: Restore build cache
uses: actions/cache/restore@v3
uses: actions/cache@v3
with:
path: |
src/*.o
tests/*.o
key: ${{ runner.os }}-build-${{ hashFiles('**/*.c') }}
key: "${{ runner.os }}-build-${{ hashFiles('**/*.c') }}"
restore-keys: "${{ runner.os }}-build-"
- name: Make
run: make
run: make clean && make
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ To set up and compile the project on your local machine, follow these steps:

## 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.
This project uses a GitHub Actions workflow with four sequential jobs:
**Installing Dependencies**, **Build**, **Test**, 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

Expand Down
Loading