Compare commits

...

21 commits

Author SHA1 Message Date
541134423a keep exit code 2025-01-06 23:22:10 +01:00
82eca2f066 c la fatig 2025-01-06 23:19:41 +01:00
0a94a283eb praying 2025-01-06 23:11:04 +01:00
c40ffa01b7 nsm bash ? 2025-01-06 23:08:01 +01:00
e01b1f534c really use bash 2025-01-06 23:04:53 +01:00
5d0ef236e7 use bash 2025-01-06 23:03:25 +01:00
ac3b72824d fix code 2025-01-06 23:01:44 +01:00
95273215c8 fix exit status 2025-01-06 22:58:14 +01:00
21b17cc34c update lint 2025-01-06 22:55:30 +01:00
b56eff6412 use code block 2025-01-06 22:36:55 +01:00
4e87890108 only comment on PR 2025-01-06 22:35:42 +01:00
fbf8a1b3d9 genoutput 2025-01-06 22:35:18 +01:00
cff7cb02d4 compliqué de faire une condition... 2025-01-06 22:16:19 +01:00
293d1bacf2 don't run ci for other user than manual 2025-01-06 22:13:46 +01:00
6778f34769 update ci 2025-01-06 22:12:46 +01:00
9ecab0328b overkill engineering 2025-01-06 22:08:43 +01:00
72150594f5 test 2025-01-06 21:56:31 +01:00
ceefcdb910 use drone comment plugin 2025-01-06 21:54:44 +01:00
fa5544b324 test2 2025-01-06 21:50:09 +01:00
4d42d2663c comment on pr 2025-01-06 21:47:43 +01:00
315f961731 typo 2025-01-06 21:32:33 +01:00
5 changed files with 69 additions and 19 deletions

28
.ci/gen_output.sh Executable file
View file

@ -0,0 +1,28 @@
echo "\`\`\`" > output.txt
process_output() {
if [ $? -eq 0 ]; then
head -n 5 output_tmp.txt >> output.txt
echo "... [See pipeline output for full details]" >> output.txt
tail -n 5 output_tmp.txt >> output.txt
else
cat output_tmp.txt >> output.txt
fi
}
echo "-- START Port attribution watcher --" | tee -a output.txt
python3 .ci/port_attribution_watcher.py | tee output_tmp.txt
process_output
echo "-- END Port attribution watcher --" | tee -a output.txt
echo "" >> output.txt
echo "-- START Traefik label watcher --" | tee -a output.txt
python3 .ci/traefik_label_watcher.py | tee output_tmp.txt
process_output
echo "-- END Traefik label watcher --" | tee -a output.txt
echo "\`\`\`" >> output.txt # Close the code block

8
.ci/lint_wrap.sh Executable file
View file

@ -0,0 +1,8 @@
set -o pipefail
sh .ci/lint.sh 2>&1 | tee output_tmp.txt
EXIT_CODE=$?
echo "\`\`\`" > output.txt
grep 'msg=' output_tmp.txt | awk -F'msg="' '{print $2}' | sed 's/"$//' | sed 's/\\"/"/g' >> output.txt
echo "\`\`\`" >> output.txt
echo "END"
exit $EXIT_CODE

View file

@ -52,25 +52,20 @@ def main(watchFolder: str):
# Get exposed ports
exposedPorts = getExposedPortsFromDockerComposeFile(dockerComposeFile)
ports[dockerComposeFile] = exposedPorts
if len(exposedPorts) == 0:
if len(exposedPorts) != 0:
print(f"\n📦 {dockerComposeFile}"
f"\n🔴 No exposed ports found"
f"\n")
else:
print(f"\n📦 {dockerComposeFile}"
f"\n🔗 Exposed ports: {exposedPorts}"
f"\n")
f"\n🔗 Exposed ports: {exposedPorts}")
wrong = checkPortUnique(ports)
if wrong:
exit(1)
else:
print("\n\n✅ All ports are unique\n\n")
print("\n✅ All ports are unique")
exit(0)
if __name__ == "__main__":
print("Traefik label watcher CI/CD")
print("Port Attribution Watcher")
# Read folder from env
watchFolder = os.getenv("WATCH_FOLDER")
if watchFolder == None:

View file

@ -85,7 +85,7 @@ def main(watchFolder: str):
if wrong:
exit(1)
else:
print("\n\n✅ All routers are unique\n\n")
print("\n\n✅ All routers are unique")
exit(0)
if __name__ == "__main__":

View file

@ -1,19 +1,38 @@
steps:
check_ports_labels:
image: python:3.12-slim
image: python:3.12
commands:
- pip3 install -r .ci/requirements.txt
- python3 .ci/port_attribution_watcher.py
- python3 .ci/traefik_labels_watcher.py
when:
- event: [push, pull_request]
- ./.ci/gen_output.sh
comment:
image: git.gnous.eu/enpls/gitea-comment-plugin:1.1
settings:
gitea_address: https://git.gnous.eu
gitea_token:
from_secret: gnous_cicd_token
comment_file: output.txt
when:
status: [failure, success]
event: [pull_request]
lint:
image: debian:stable-slim
image: debian:stable
commands:
- rm -rf output.txt
- apt-get update
- apt-get install -y curl
- curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- sh .ci/lint.sh
when:
- event: [push, pull_request]
- bash .ci/lint_wrap.sh
comment_2:
image: git.gnous.eu/enpls/gitea-comment-plugin:1.1
settings:
gitea_address: https://git.gnous.eu
gitea_token:
from_secret: gnous_cicd_token
comment_file: output.txt
when:
status: [failure, success]
event: [pull_request]
when:
- event: [push, pull_request]
- evaluate: 'CI_COMMIT_AUTHOR in ["gnous-ci-bot", "mael", "ada"]'