This README offers examples of how to set up GitHub Actions for 42 Network C-based projects, including norminette checks and build processes.
- Example 1: Basic Norminette and Build Workflow
- Example 2: MinilibX Docker Integration Workflow
- Customization
- Docker Image
This example demonstrates a basic GitHub Actions workflow for C-based projects, focusing on norminette checks and building the project.
---
name: NORM AND FLAGS CHECKS
on:
push:
branches:
- main
pull_request:
branches:
- '*'
jobs:
check-norm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.12
- name: Install dependencies
run: |
pip install setuptools norminette
- name: Run norminette checks
run: |
norminette
make-with-flags:
runs-on: ubuntu-latest
needs: check-norm
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y make gcc
- name: Create Makefile for testing
run: |
echo -e 'SRCS= $(shell find . -type f -name "*.c")\nINCLUDES= $(shell find . -type f -name "*.h")\nOBJS= $(SRCS:.c=.o)\nCC= cc\nCFLAGS= -Wall -Wextra -Werror\nNAME= uniq_name_][\nall: $(NAME)\n$(NAME): $(OBJS)\n\t$(CC) $(OBJS) -o $(NAME)\n%.o: %.c $(INCLUDES)\n\t$(CC) $(CFLAGS) -c $< -o $@' > Makefile
- name: Run Services
run: |
make
-
check-norm
Job:- Runs on the latest Ubuntu.
- Checks out the code using actions/checkout@v2.
- Sets up Python 3.12 using actions/setup-python@v2.
- Installs
setuptools
andnorminette
using pip. - Runs
norminette
to check the code.
-
make-with-flags
Job:- Runs on the latest Ubuntu and depends on the successful completion of
check-norm
. - Checks out the code using actions/checkout@v2.
- Installs
make
andgcc
usingapt-get
. - Creates a
Makefile
for testing, which compiles.c
files and links them into an executable. - Runs
make
to build the executable.
- Runs on the latest Ubuntu and depends on the successful completion of
This example demonstrates a GitHub Actions workflow for integrating MinilibX using Docker.
---
name: NORM AND FLAGS CHECKS FOR MINILIBX PROJECT
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
check-norm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.12
- name: Install dependencies
run: |
pip install setuptools norminette
- name: Run norminette checks
run: |
norminette
make-with-flags:
runs-on: ubuntu-latest
needs: check-norm
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Pull Docker image
run: |
docker pull ahlyelamine/minilibx:latest
- name: Build and run project
run: |
docker run --rm -v ${{ github.workspace }}:/opt ahlyelamine/minilibx:latest
-
check-norm
Job:- Runs on the latest Ubuntu.
- Checks out the code using actions/checkout@v2.
- Sets up Python 3.12 using actions/setup-python@v2.
- Installs
setuptools
andnorminette
using pip. - Runs
norminette
to check the code.
-
make-with-flags
Job:- Runs on the latest Ubuntu and depends on the successful completion of
check-norm
. - Checks out the code using actions/checkout@v3.
- Pulls the Docker image
ahlyelamine/minilibx:latest
. - Builds and runs the project using Docker with the workspace mounted to
/opt
in the container.
- Runs on the latest Ubuntu and depends on the successful completion of
To customize the branches that trigger these workflows, modify the on
section:
on:
push:
branches:
- main
- feature-branch
pull_request:
branches:
- main
- feature-branch
This workflow triggers on every push and pull request to the specified branches.
The Docker image used in Example 2 is available on Docker Hub.