-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (156 loc) · 7.5 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: "ci"
on:
- push
- pull_request
env:
UNIT_TESTS: "./unit_tests"
VALGRIND_REPORTS: "./valgrind-reports.log"
ARTIFACTS: "${{ vars.ARTIFACTS }}"
MIRROR_URL: "${{ vars.MIRROR_URL }}"
SSH_PRIVATE_KEY: "${{ secrets.SSH_PRIVATE_KEY }}"
SSH_PRIVATE_KEY_PASSPHRASE: "${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}"
jobs:
check-basics:
runs-on: "ubuntu-latest"
outputs:
continue: "${{ steps.basic-check.outputs.continue }}"
steps:
- id: "basic-check"
continue-on-error: true
if: "${{ env.ARTIFACTS }}"
run: "echo \"continue=1\" >> $GITHUB_OUTPUT"
basics:
needs:
- "check-basics"
runs-on: "ubuntu-latest"
if: "${{ needs.check-basics.outputs.continue == '1' }}"
container:
image: "ghcr.io/epitech/coding-style-checker:latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4.1.1"
with:
fetch-depth: 0
- name: "Temporary files"
run: "[[ $(find . -type f \\( -name '*.o' -o -name '*.log' -o -name '.env' -o -name '*.so' -o -name '*.a' -o -name '*.gcno' -o -name '*.gcda' \\)) == \"\" ]] && exit 0 || exit 1"
- name: "Checking for the artifacts before compilation"
run: "for a in ${{ env.ARTIFACTS }} ; do [ ! -f \"${a}\" ]; done"
- name: "Checking make on it's own"
timeout-minutes: 1
run: "make && for a in ${{ env.ARTIFACTS }}; do [ -f \"${a}\" ]; done"
- name: "Checking for make relink on it's own"
timeout-minutes: 1
run: "[[ $(make) == \"\" ]] && exit 1 || echo 0"
- name: "Checking 'all' rule"
timeout-minutes: 1
run: "make all && for a in ${{ env.ARTIFACTS }}; do [ -f \"${a}\" ]; done"
- name: "Checking for 'all' make relink"
timeout-minutes: 1
run: "[[ $(make all) == \"\" ]] && exit 1 || echo 0"
- name: "Checking 'clean' rule"
timeout-minutes: 1
run: "make clean && echo $(find . -type d -name '.git' -prune -o \\( -type f \\( -name '*.o' -o -name '.env' -o -name '*.log' -o -name '*.gcno' -o -name '*.gcda' \\) \\) -print) && [[ $(find . -type d -name '.git' -prune -o \\( -type f \\( -name '*.o' -o -name '.env' -o -name '*.log' -o -name '*.gcno' -o -name '*.gcda' \\) \\) -print) == \"\" ]] && exit 0 || exit 1"
- name: "Checking 'fclean' rule"
timeout-minutes: 1
run: |
make
make fclean
for a in ${{ env.ARTIFACTS }}; do [ ! -f "${a}" ]; done
if [[ $(find . -type d -name '.git' -prune -o \( -type f \( -name '*.o' -o -name '*.log' -o -name '.env' -o -name '*.so' -o -name '*.a' -o -name '*.gcno' -o -name '*.gcda' \) \) -print) == "" ]]; then
exit 0
else
exit 1
fi
- name: "Checking 're' rule"
timeout-minutes: 1
run: |
make re
for a in ${{ env.ARTIFACTS }} ; do [ -f "${a}" ]; done
- name: "Checking the artifacts rule"
timeout-minutes: 1
run: |
for a in ${{ env.ARTIFACTS }}; do make "${a}" && [ -f "${a}" ]; done
- name: "Checking for the artifacts make relink"
timeout-minutes: 1
run: |
for a in ${{ env.ARTIFACTS }}; do
if [[ $(make "${a}") == "" ]]; then exit 1; fi;
done
- name: "Check coding style"
run: "/usr/local/bin/check.sh $(pwd) $(pwd)"
- name: "Annotate coding-style errors"
run: |
status=0
while IFS= read -r line; do
file=$(echo "${line}" | cut -d ':' -f1)
pos=$(echo "${line}" | cut -d ':' -f2)
type=$(echo "${line}" | cut -d ':' -f3)
csid=$(echo "${line}" | cut -d ':' -f4)
[[ "${type:1}" == "illegal"* ]] && continue
echo "::error file=${file},line=${pos},title=${type:1} ${csid}::${type:1}: ${csid} at ${file}:${pos}"
status=1
done < coding-style-reports.log
exit "${status}"
run-tests:
needs:
- "basics"
runs-on: "ubuntu-latest"
container:
image: "epitechcontent/epitest-docker:latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4.1.1"
with:
fetch-depth: 0
- name: "Run tests"
timeout-minutes: 1
run: "[[ $(grep -E \"^tests_run:\" Makefile) == \"\" ]] && exit 0 || make tests_run"
- name: "Run valgrind"
run: "[ -f \"${{ env.UNIT_TESTS }}\" ] && valgrind -s --leak-check=full --track-origins=yes --read-var-info=yes --trace-children=yes --show-leak-kinds=all --read-inline-info=yes --errors-for-leak-kinds=all ${{ env.UNIT_TESTS }} 2>${{ env.VALGRIND_REPORTS }}"
- name: "Analyze valgrind report"
run: |
if [[ ! -f "${{ env.VALGRIND_REPORTS }}" ]]; exit 0
status=0
block=""
while IFS= read -r line; do
if [[ "${block}" != "" ]]; then
if [[ $(echo "${line}" | grep '^==.*== $') ]]; then
echo "::error title=Valgrind Error::${block}"
block=""
status=1
else
block="${block}%0A${line}"
fi
fi
if [[ $(echo "${line}" | grep '^==.*== .* bytes in .* blocks are definitely lost in loss record .* of .*$') ]]; then
block="${line}"
fi
done < ${{ env.VALGRIND_REPORTS }}
exit "${status}"
check-mirror-commits:
runs-on: "ubuntu-latest"
needs:
- "run-tests"
outputs:
continue: "${{ steps.mirroring-check.outputs.continue }}"
steps:
- id: "mirroring-check"
continue-on-error: true
if: "${{ env.MIRROR_URL && env.SSH_PRIVATE_KEY }}"
run: "echo \"continue=1\" >> $GITHUB_OUTPUT"
mirror-commits:
needs:
- "check-mirror-commits"
if: "${{ needs.check-mirror-commits.outputs.continue == '1' && github.event_name == 'push' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4.1.1"
with:
fetch-depth: 0
- name: "Mirror commits"
uses: "./.github/workflows/repository-mirroring-action"
with:
target_repo_url: "${{ env.MIRROR_URL }}"
ssh_private_key: "${{ env.SSH_PRIVATE_KEY }}"
ssh_private_key_passphrase: "${{ env.SSH_PRIVATE_KEY_PASSPHRASE }}"