├── .github └── workflows │ ├── minilibx.yml │ └── pipeline.yml ├── LICENSE ├── README.md └── test.c /.github/workflows/minilibx.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: NORM AND FLAGS CHECKS FOR MINILIBX PROJECT 3 | 4 | on: 5 | push: 6 | branches: 7 | - '*' 8 | pull_request: 9 | branches: 10 | - '*' 11 | 12 | jobs: 13 | check-norm: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Set up Python 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: 3.12 23 | 24 | - name: Install dependencies 25 | run: | 26 | pip install setuptools norminette 27 | 28 | - name: Run norminette checks 29 | run: | 30 | norminette 31 | 32 | make-with-flags: 33 | runs-on: ubuntu-latest 34 | needs: check-norm 35 | steps: 36 | - name: Checkout code 37 | uses: actions/checkout@v3 38 | 39 | - name: Pull Docker image 40 | run: | 41 | docker pull ahlyelamine/minilibx:latest 42 | 43 | - name: Build and run project 44 | run: | 45 | docker run --rm -v ${{ github.workspace }}:/opt ahlyelamine/minilibx:latest 46 | -------------------------------------------------------------------------------- /.github/workflows/pipeline.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: NORM AND FLAGS CHECKS 3 | 4 | on: 5 | push: 6 | branches: 7 | - main 8 | pull_request: 9 | branches: 10 | - '*' 11 | 12 | jobs: 13 | check-norm: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Set up Python 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: 3.12 23 | 24 | - name: Install dependencies 25 | run: | 26 | pip install setuptools norminette 27 | 28 | - name: Run norminette checks 29 | run: | 30 | norminette 31 | 32 | make-with-flags: 33 | runs-on: ubuntu-latest 34 | needs: check-norm 35 | steps: 36 | - name: Checkout repository 37 | uses: actions/checkout@v2 38 | 39 | - name: install dependencies 40 | run: | 41 | sudo apt-get update 42 | sudo apt-get install -y make gcc 43 | 44 | - name: Create Makefile for testing 45 | run: | 46 | 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 47 | - name: Run Services 48 | run: | 49 | make 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 leetcode.1337 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Licence](https://img.shields.io/badge/License-MIT-blue.svg) 2 | ![ReadMe](https://img.shields.io/badge/ReadMe-018EF5?logo=readme&logoColor=fff&style=flat-square) 3 | # GitHub Actions for C-based 42 Projects 4 | 5 | This README offers examples of how to set up GitHub Actions for 42 Network C-based projects, including norminette checks and build processes. 6 | 7 | ## Table of Contents 8 | 9 | - [Example 1: Basic Norminette and Build Workflow](#example-1-basic-norminette-and-build-workflow) 10 | - [Example 2: MinilibX Docker Integration Workflow](#example-2-minilibx-docker-integration-workflow) 11 | - [Customization](#customization) 12 | - [Docker Image](#docker-image) 13 | 14 | ## Example 1: Basic Norminette and Build Workflow 15 | 16 | This example demonstrates a basic GitHub Actions workflow for C-based projects, focusing on norminette checks and building the project. 17 | 18 | ```yaml 19 | --- 20 | name: NORM AND FLAGS CHECKS 21 | 22 | on: 23 | push: 24 | branches: 25 | - main 26 | pull_request: 27 | branches: 28 | - '*' 29 | 30 | jobs: 31 | check-norm: 32 | runs-on: ubuntu-latest 33 | steps: 34 | - name: Checkout code 35 | uses: actions/checkout@v2 36 | 37 | - name: Set up Python 38 | uses: actions/setup-python@v2 39 | with: 40 | python-version: 3.12 41 | 42 | - name: Install dependencies 43 | run: | 44 | pip install setuptools norminette 45 | 46 | - name: Run norminette checks 47 | run: | 48 | norminette 49 | 50 | make-with-flags: 51 | runs-on: ubuntu-latest 52 | needs: check-norm 53 | steps: 54 | - name: Checkout repository 55 | uses: actions/checkout@v2 56 | 57 | - name: Install dependencies 58 | run: | 59 | sudo apt-get update 60 | sudo apt-get install -y make gcc 61 | 62 | - name: Create Makefile for testing 63 | run: | 64 | 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 65 | - name: Run Services 66 | run: | 67 | make 68 | ``` 69 | 70 | ### Explanation 71 | 72 | 1. **`check-norm` Job:** 73 | - Runs on the latest Ubuntu. 74 | - Checks out the code using [actions/checkout@v2](https://github.com/actions/checkout). 75 | - Sets up Python 3.12 using [actions/setup-python@v2](https://github.com/actions/setup-python). 76 | - Installs `setuptools` and `norminette` using pip. 77 | - Runs `norminette` to check the code. 78 | 79 | 2. **`make-with-flags` Job:** 80 | - Runs on the latest Ubuntu and depends on the successful completion of `check-norm`. 81 | - Checks out the code using [actions/checkout@v2](https://github.com/actions/checkout). 82 | - Installs `make` and `gcc` using `apt-get`. 83 | - Creates a `Makefile` for testing, which compiles `.c` files and links them into an executable. 84 | - Runs `make` to build the executable. 85 | 86 | ## Example 2: MinilibX Docker Integration Workflow 87 | 88 | This example demonstrates a GitHub Actions workflow for integrating MinilibX using Docker. 89 | 90 | ```yaml 91 | --- 92 | name: NORM AND FLAGS CHECKS FOR MINILIBX PROJECT 93 | 94 | on: 95 | push: 96 | branches: 97 | - '*' 98 | pull_request: 99 | branches: 100 | - '*' 101 | 102 | jobs: 103 | check-norm: 104 | runs-on: ubuntu-latest 105 | steps: 106 | - name: Checkout code 107 | uses: actions/checkout@v2 108 | 109 | - name: Set up Python 110 | uses: actions/setup-python@v2 111 | with: 112 | python-version: 3.12 113 | 114 | - name: Install dependencies 115 | run: | 116 | pip install setuptools norminette 117 | 118 | - name: Run norminette checks 119 | run: | 120 | norminette 121 | 122 | make-with-flags: 123 | runs-on: ubuntu-latest 124 | needs: check-norm 125 | steps: 126 | - name: Checkout code 127 | uses: actions/checkout@v3 128 | 129 | - name: Pull Docker image 130 | run: | 131 | docker pull ahlyelamine/minilibx:latest 132 | 133 | - name: Build and run project 134 | run: | 135 | docker run --rm -v ${{ github.workspace }}:/opt ahlyelamine/minilibx:latest 136 | ``` 137 | 138 | ### Explanation 139 | 140 | 1. **`check-norm` Job:** 141 | - Runs on the latest Ubuntu. 142 | - Checks out the code using [actions/checkout@v2](https://github.com/actions/checkout). 143 | - Sets up Python 3.12 using [actions/setup-python@v2](https://github.com/actions/setup-python). 144 | - Installs `setuptools` and `norminette` using pip. 145 | - Runs `norminette` to check the code. 146 | 147 | 2. **`make-with-flags` Job:** 148 | - Runs on the latest Ubuntu and depends on the successful completion of `check-norm`. 149 | - Checks out the code using [actions/checkout@v3](https://github.com/actions/checkout). 150 | - Pulls the Docker image [`ahlyelamine/minilibx:latest`](https://hub.docker.com/r/ahlyelamine/minilibx). 151 | - Builds and runs the project using Docker with the workspace mounted to `/opt` in the container. 152 | 153 | ## Customization 154 | 155 | To customize the branches that trigger these workflows, modify the `on` section: 156 | 157 | ```yaml 158 | on: 159 | push: 160 | branches: 161 | - main 162 | - feature-branch 163 | pull_request: 164 | branches: 165 | - main 166 | - feature-branch 167 | ``` 168 | 169 | This workflow triggers on every push and pull request to the specified branches. 170 | 171 | ## Docker Image 172 | 173 | The Docker image used in Example 2 is available on [Docker Hub](https://hub.docker.com/r/ahlyelamine/minilibx). 174 | -------------------------------------------------------------------------------- /test.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* test.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: aahlyel +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/08/03 04:45:58 by sabato #+# #+# */ 9 | /* Updated: 2024/08/25 03:41:29 by aahlyel ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(void) 16 | { 17 | char login[8]; 18 | 19 | (void)login; 20 | printf("Login: "); 21 | printf("Password: "); 22 | } 23 | --------------------------------------------------------------------------------