Merge pull request 'dev/outout/fix_ci' (#58) from dev/outout/fix_ci into main
Reviewed-on: #58
This commit is contained in:
commit
60cb231f97
5 changed files with 71 additions and 24 deletions
28
.ci/gen_output.sh
Executable file
28
.ci/gen_output.sh
Executable 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
|
||||
|
11
.ci/lint_wrap.sh
Executable file
11
.ci/lint_wrap.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
set -o pipefail
|
||||
sh .ci/lint.sh 2>&1 | tee output_tmp.txt
|
||||
EXIT_CODE=$?
|
||||
echo "\`\`\`" > output.txt
|
||||
|
||||
grep -n 'msg=' output_tmp.txt | awk -F'msg="' '{print $2}' | sed 's/"$//' | sed 's/\\"/"/g' >> output.txt
|
||||
grep -v 'msg=' output_tmp.txt >> output.txt
|
||||
|
||||
echo "\`\`\`" >> output.txt
|
||||
echo "END"
|
||||
exit $EXIT_CODE
|
|
@ -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:
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -3,23 +3,36 @@ steps:
|
|||
image: python:3.13-slim
|
||||
commands:
|
||||
- pip3 install -r .ci/requirements.txt
|
||||
- python3 .ci/port_attribution_watcher.py
|
||||
- python3 .ci/traefik_labels_watcher.py
|
||||
when:
|
||||
- event: pull_request
|
||||
repo: gnouseu/docker-services
|
||||
- event: push
|
||||
branch: main
|
||||
- ./.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: pull_request
|
||||
repo: gnouseu/docker-services
|
||||
- event: push
|
||||
branch: main
|
||||
- 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"]'
|
Loading…
Add table
Reference in a new issue