Skip to content

Commit 935a30a

Browse files
committed
Github-Actions-for-c-based-42Projects
1 parent d24609c commit 935a30a

File tree

7 files changed

+89
-123
lines changed

7 files changed

+89
-123
lines changed

.github/workflows/pipeline.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: CI Pipeline
2+
name: NORM AND FLAGS CHECKS
33

44
on:
55
push:
@@ -47,23 +47,3 @@
4747
- name: Run Services
4848
run: |
4949
make
50-
51-
# build-microservices:
52-
# needs: [lint-microservices, test-microservices]
53-
# runs-on: ubuntu-latest
54-
# strategy:
55-
# matrix:
56-
# service: [chat, game, ranking, registration, tournament, users, auth]
57-
# steps:
58-
# - name: Checkout code
59-
# uses: actions/checkout@v2
60-
61-
# - name: Log in to Docker Hub
62-
# run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
63-
64-
# - name: Build and push backend images
65-
# run: |
66-
# cd services/${{ matrix.service }}/backend
67-
# docker build -t ${{ secrets.CI_REGISTRY_IMAGE }}-${{ matrix.service }}:${{ github.sha }} -t ${{ secrets.CI_REGISTRY_IMAGE }}-${{ matrix.service }}:latest .
68-
# docker push ${{ secrets.CI_REGISTRY_IMAGE }}-${{ matrix.service }}:${{ github.sha }}
69-
# docker push ${{ secrets.CI_REGISTRY_IMAGE }}-${{ matrix.service }}:latest

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,90 @@
11
# Github-Actions-for-c-based-42Projects
22
offer a github action implementation example for 42Network c based projects
3+
4+
```yml
5+
---
6+
name: NORM AND FLAGS CHECKS
7+
8+
on:
9+
push:
10+
branches:
11+
- '*'
12+
pull_request:
13+
branches:
14+
- '*'
15+
16+
jobs:
17+
check-norm:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.12
27+
28+
- name: Install dependencies
29+
run: |
30+
pip install setuptools norminette
31+
32+
- name: Run norminette checks
33+
run: |
34+
norminette
35+
36+
make-with-flags:
37+
runs-on: ubuntu-latest
38+
needs: check-norm
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
42+
43+
- name: install docker-compose
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y make gcc
47+
48+
- name: Create Makefile for testing
49+
run: |
50+
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
51+
- name: Run Services
52+
run: |
53+
make
54+
```
55+
---
56+
This is a GitHub Actions workflow file written in YAML. It defines two jobs: `check-norm` and `make-with-flags`.
57+
---
58+
1. `check-norm` job:
59+
- It runs on the latest version of Ubuntu.
60+
- It checks out your code using the `actions/checkout@v2` action.
61+
- It sets up Python 3.12 using the `actions/setup-python@v2` action.
62+
- It installs `setuptools` and `norminette` using pip.
63+
- It runs `norminette` to check your code.
64+
65+
66+
---
67+
2. `make-with-flags` job:
68+
- It also runs on the latest version of Ubuntu.
69+
- It depends on the `check-norm` job, meaning it will only run if `check-norm` completes successfully.
70+
- It checks out your code using the `actions/checkout@v2` action.
71+
- It installs `make` and `gcc` using `apt-get`.
72+
- It creates a `Makefile` for testing. The `Makefile` compiles all `.c` files found in the repository and links them into a single executable named `uniq_name_][`.
73+
- It runs `make` to build the executable.
74+
75+
This workflow is triggered on every push and pull request to any branch of your repository.
76+
77+
you can customize it by specifying on which branches to run this workflow :
78+
79+
```yaml
80+
on:
81+
push:
82+
branches:
83+
- main
84+
- and so on for example
85+
pull_request:
86+
branches:
87+
- main
88+
- and so on for example
89+
90+
```

a.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

a.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/a.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/b.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/b.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)