Skip to content

Commit 93dc5fc

Browse files
authored
Merge pull request #49 from linuxserver/Add-builder-info
2 parents 0e01126 + 6553ed5 commit 93dc5fc

10 files changed

Lines changed: 763 additions & 18 deletions

File tree

.github/workflows/tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Test CI
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up Python 3.12
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: "3.12"
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 pytest
30+
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
- name: Test with pytest
38+
run: |
39+
pytest -v

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
.jenkins-external
2-
venv
2+
venv*
33
__pycache__
44
.vscode
55
/output
6+
7+
# Unit test / coverage reports
8+
htmlcov/
9+
.tox/
10+
.nox/
11+
.coverage
12+
.coverage.*
13+
.cache
14+
nosetests.xml
15+
coverage.xml
16+
*.cover
17+
*.py,cover
18+
.hypothesis/
19+
.pytest_cache/
20+
cover/

ci/ci.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self) -> None:
8282
self.logs_timeout: int = (os.environ.get("DOCKER_LOGS_TIMEOUT", "120") or "120")
8383
self.sbom_timeout: int = (os.environ.get("SBOM_TIMEOUT", "900") or "900")
8484
self.port: int = (os.environ.get("PORT", "80") or "80")
85-
85+
self.builder: str = os.environ.get("NODE_NAME", "-")
8686
self.ssl: str = os.environ.get("SSL", "false")
8787
self.region: str = os.environ.get("S3_REGION", "us-east-1")
8888
self.bucket: str = os.environ.get("S3_BUCKET", "ci-tests.linuxserver.io")
@@ -99,6 +99,7 @@ def __init__(self) -> None:
9999

100100
env_data = dedent(f"""
101101
ENVIRONMENT DATA:
102+
NODE_NAME: '{os.environ.get("NODE_NAME")}'
102103
IMAGE: '{os.environ.get("IMAGE")}'
103104
BASE: '{os.environ.get("BASE")}'
104105
META_TAG: '{os.environ.get("META_TAG")}'
@@ -121,9 +122,21 @@ def __init__(self) -> None:
121122
SSL: '{os.environ.get("SSL")}'
122123
S3_REGION: '{os.environ.get("S3_REGION")}'
123124
S3_BUCKET: '{os.environ.get("S3_BUCKET")}'
124-
Docker Engine Version: '{docker.from_env().version().get("Version")}'
125+
Docker Engine Version: '{self.get_docker_engine_version()}'
125126
""")
126127
self.logger.info(env_data)
128+
129+
def get_docker_engine_version(self) -> str:
130+
"""Get the Docker Engine version
131+
132+
Returns:
133+
str: The Docker Engine version
134+
"""
135+
try:
136+
return docker.from_env().version().get("Version")
137+
except Exception:
138+
logger.error("Failed to get Docker Engine version!")
139+
return "Unknown"
127140

128141
def validate_attrs(self) -> None:
129142
"""Validate the numeric environment variables"""
@@ -148,8 +161,8 @@ def _split_key_value_string(self, kv:str, make_list:bool = False) -> dict[str,st
148161
dict[str,str]: Returns a dictionary with our keys and values.
149162
"""
150163
if make_list:
151-
return [f"{k}:{v}" for k,v in (item.split("=") for item in kv.split("|"))]
152-
return dict((item.split('=') for item in kv.split('|')))
164+
return [f"{k}:{v}" for k,v in (item.split("=") for item in kv.split("|") if item and "=" in item and item.split('=')[1])]
165+
return dict((item.split('=') for item in kv.split('|') if item and "=" in item and item.split('=')[1]))
153166

154167
def convert_env(self, envs:str = None) -> dict[str,str]:
155168
"""Convert env DOCKER_ENV to dictionary
@@ -236,7 +249,7 @@ def __init__(self) -> None:
236249
self.total_runtime: float = 0.0
237250
logging.getLogger("botocore.auth").setLevel(logging.INFO) # Don't log the S3 authentication steps.
238251

239-
self.client: DockerClient = docker.from_env()
252+
self.client: DockerClient = self.create_docker_client()
240253
self.tags = list(self.tags_env.split("|"))
241254
self.tag_report_tests:dict[str,dict[str,dict]] = {tag: {"test":{}} for tag in self.tags} # Adds all the tags as keys with an empty dict as value to the dict
242255
self.report_containers: dict[str,dict[str,dict]] = {}
@@ -507,6 +520,7 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
507520
"created": "xxxx-xx-xx",
508521
"size": "100MB",
509522
"maintainer": "user"
523+
"builder": "node"
510524
}
511525
```
512526
"""
@@ -519,6 +533,7 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
519533
"created": container.attrs["Config"]["Labels"]["org.opencontainers.image.created"],
520534
"size": "%.2f" % float(int(container.image.attrs["Size"])/1000000) + "MB",
521535
"maintainer": container.attrs["Config"]["Labels"]["maintainer"],
536+
"builder": self.builder
522537
}
523538
self._add_test_result(tag, test, "PASS", "-", start_time)
524539
self.logger.success("Get build info on tag '%s': PASS", tag)
@@ -847,6 +862,17 @@ def create_s3_client(self) -> boto3.client:
847862
aws_access_key_id=self.s3_key,
848863
aws_secret_access_key=self.s3_secret)
849864
return s3_client
865+
866+
def create_docker_client(self) -> DockerClient|None:
867+
"""Create and return a docker client object
868+
869+
Returns:
870+
DockerClient: A docker client object
871+
"""
872+
try:
873+
return docker.from_env()
874+
except Exception:
875+
self.logger.error("Failed to create Docker client!")
850876

851877
class CIError(Exception):
852878
pass

ci/template.html

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,18 +593,11 @@ <h2 class="section-header-h2">
593593
{% endif %}
594594
<div class="build-section">Build Information</div>
595595
<div class="build-info-section build">
596-
<div class="build-summary">
597-
<span class="build-header">Version:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["version"] }}</span>
598-
</div>
599-
<div class="build-summary">
600-
<span class="build-header">Created:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["created"] }}</span>
601-
</div>
602-
<div class="build-summary">
603-
<span class="build-header">Size:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["size"] }}</span>
604-
</div>
605-
<div class="build-summary">
606-
<span class="build-header">Maintainer:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["maintainer"] }}</span>
607-
</div>
596+
{% for key, value in report_containers[tag]["build_info"].items() %}
597+
<div class="build-summary">
598+
<span class="build-header">{{ key|capitalize }}:</span> <span class="build-info">{{ value }}</span>
599+
</div>
600+
{% endfor %}
608601
</div>
609602
<summary class="summary">
610603
<a href="{{ tag }}.log.html" target="_blank">View Container Logs</a>

dev-requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-r requirements.txt
2+
pytest
3+
pytest-cov
4+
pytest-mock
5+
wheel

tests/log_blob.log

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2024-08-24T10:50:17.122835042Z s6-rc: info: service s6rc-oneshot-runner: starting
2+
2024-08-24T10:50:17.124912597Z s6-rc: info: service s6rc-oneshot-runner successfully started
3+
2024-08-24T10:50:17.124973716Z s6-rc: info: service fix-attrs: starting
4+
2024-08-24T10:50:17.125050965Z s6-rc: info: service init-migrations: starting
5+
2024-08-24T10:50:17.125146673Z s6-rc: info: service init-envfile: starting
6+
2024-08-24T10:50:17.128569035Z [migrations] started
7+
2024-08-24T10:50:17.128588625Z s6-rc: info: service fix-attrs successfully started
8+
2024-08-24T10:50:17.128612144Z [migrations] no migrations found
9+
2024-08-24T10:50:17.128687663Z s6-rc: info: service legacy-cont-init: starting
10+
2024-08-24T10:50:17.129015388Z s6-rc: info: service init-migrations successfully started
11+
2024-08-24T10:50:17.129110196Z s6-rc: info: service init-adduser: starting
12+
2024-08-24T10:50:17.130271146Z s6-rc: info: service init-envfile successfully started
13+
2024-08-24T10:50:17.132198574Z s6-rc: info: service legacy-cont-init successfully started
14+
2024-08-24T10:50:17.276658044Z usermod: no changes
15+
2024-08-24T10:50:17.277582028Z ───────────────────────────────────────
16+
2024-08-24T10:50:17.277599098Z
17+
2024-08-24T10:50:17.277603338Z ██╗ ███████╗██╗ ██████╗
18+
2024-08-24T10:50:17.277607428Z ██║ ██╔════╝██║██╔═══██╗
19+
2024-08-24T10:50:17.277611307Z ██║ ███████╗██║██║ ██║
20+
2024-08-24T10:50:17.277615167Z ██║ ╚════██║██║██║ ██║
21+
2024-08-24T10:50:17.277619017Z ███████╗███████║██║╚██████╔╝
22+
2024-08-24T10:50:17.277622717Z ╚══════╝╚══════╝╚═╝ ╚═════╝
23+
2024-08-24T10:50:17.277626577Z
24+
2024-08-24T10:50:17.277630167Z Brought to you by linuxserver.io
25+
2024-08-24T10:50:17.277633967Z ───────────────────────────────────────
26+
2024-08-24T10:50:17.277812604Z
27+
2024-08-24T10:50:17.277820684Z To support LSIO projects visit:
28+
2024-08-24T10:50:17.277824054Z https://www.linuxserver.io/donate/
29+
2024-08-24T10:50:17.277827204Z
30+
2024-08-24T10:50:17.277830024Z ───────────────────────────────────────
31+
2024-08-24T10:50:17.277833524Z GID/UID
32+
2024-08-24T10:50:17.277836354Z ───────────────────────────────────────
33+
2024-08-24T10:50:17.280318612Z
34+
2024-08-24T10:50:17.280328742Z User UID: 911
35+
2024-08-24T10:50:17.280340991Z User GID: 911
36+
2024-08-24T10:50:17.280344011Z ───────────────────────────────────────
37+
2024-08-24T10:50:17.290792965Z s6-rc: info: service init-adduser successfully started
38+
2024-08-24T10:50:17.290863793Z s6-rc: info: service init-os-end: starting
39+
2024-08-24T10:50:17.291607871Z s6-rc: info: service init-os-end successfully started
40+
2024-08-24T10:50:17.291684610Z s6-rc: info: service init-kasmvnc: starting
41+
2024-08-24T10:50:17.291768548Z s6-rc: info: service init-crontab-config: starting
42+
2024-08-24T10:50:17.292426547Z s6-rc: info: service init-kasmvnc successfully started
43+
2024-08-24T10:50:17.292495636Z s6-rc: info: service init-nginx: starting
44+
2024-08-24T10:50:17.297762517Z s6-rc: info: service init-crontab-config successfully started
45+
2024-08-24T10:50:17.433126600Z .............+.+.....+............+..........+..+....+..+....+...........+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.......+..+....+............+.........+.....+...+.......+........+..........+...+..+.+...............+..+...+......+.+...............+...............+...+......+...+........+...+....+........+.......+...........+......+.+............+........+...+..........+.........+..+.+..................+.....+....+.....+...+....+...............+.........+......+.....+.+..+............+.+...+............+............+.....+..................+....+........+..................+...+.+...+.....+.......+...+...........+....+.....+...+............+...+...+...............+.+...+..+....+......+......+...+.....+......+.........+.+.........+...............+......+...+.....+.+......+...+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46+
2024-08-24T10:50:17.521335090Z ..+...+...+..+......+..........+.....+....+..+.+...+..+....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+..+..........+...+..+.........+.........+.......+...+.....+......+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+....+...............+.....+..........+...........+...+..................+...+......................+..+...+............+.+............+...+......+..............+.+......+...+..+......................+..+....+.....+....+..+.+.....+............+......+.+...+........+....+.........+..............+.......+.....+...+......+.+...+...+........+....+..+...+...+....+...+...........+.+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47+
2024-08-24T10:50:17.523934416Z -----
48+
2024-08-24T10:50:17.534042865Z s6-rc: info: service init-nginx successfully started
49+
2024-08-24T10:50:17.534141954Z s6-rc: info: service init-kasmvnc-config: starting
50+
2024-08-24T10:50:17.578754430Z s6-rc: info: service init-kasmvnc-config successfully started
51+
2024-08-24T10:50:17.579685815Z s6-rc: info: service init-video: starting
52+
2024-08-24T10:50:17.586924972Z s6-rc: info: service init-video successfully started
53+
2024-08-24T10:50:17.587018161Z s6-rc: info: service init-kasmvnc-end: starting
54+
2024-08-24T10:50:17.587849567Z s6-rc: info: service init-kasmvnc-end successfully started
55+
2024-08-24T10:50:17.588260720Z s6-rc: info: service init-config: starting
56+
2024-08-24T10:50:17.589203354Z s6-rc: info: service init-config successfully started
57+
2024-08-24T10:50:17.589295582Z s6-rc: info: service init-config-end: starting
58+
2024-08-24T10:50:17.590151768Z s6-rc: info: service init-config-end successfully started
59+
2024-08-24T10:50:17.590226156Z s6-rc: info: service init-mods: starting
60+
2024-08-24T10:50:17.590921155Z s6-rc: info: service init-mods successfully started
61+
2024-08-24T10:50:17.590990383Z s6-rc: info: service init-mods-package-install: starting
62+
2024-08-24T10:50:17.594913657Z s6-rc: info: service init-mods-package-install successfully started
63+
2024-08-24T10:50:17.594981996Z s6-rc: info: service init-mods-end: starting
64+
2024-08-24T10:50:17.595687814Z s6-rc: info: service init-mods-end successfully started
65+
2024-08-24T10:50:17.595757153Z s6-rc: info: service init-custom-files: starting
66+
2024-08-24T10:50:17.598857481Z [custom-init] No custom files found, skipping...
67+
2024-08-24T10:50:17.599207205Z s6-rc: info: service init-custom-files successfully started
68+
2024-08-24T10:50:17.599285493Z s6-rc: info: service init-services: starting
69+
2024-08-24T10:50:17.599980762Z s6-rc: info: service init-services successfully started
70+
2024-08-24T10:50:17.600063090Z s6-rc: info: service svc-pulseaudio: starting
71+
2024-08-24T10:50:17.600142799Z s6-rc: info: service svc-cron: starting
72+
2024-08-24T10:50:17.601347238Z s6-rc: info: service svc-pulseaudio successfully started
73+
2024-08-24T10:50:17.601456507Z s6-rc: info: service svc-kasmvnc: starting
74+
2024-08-24T10:50:17.601586164Z s6-rc: info: service svc-cron successfully started
75+
2024-08-24T10:50:17.602806224Z s6-rc: info: service svc-kasmvnc successfully started
76+
2024-08-24T10:50:17.602933032Z s6-rc: info: service svc-kclient: starting
77+
2024-08-24T10:50:17.604124731Z s6-rc: info: service svc-kclient successfully started
78+
2024-08-24T10:50:17.604230550Z s6-rc: info: service svc-nginx: starting
79+
2024-08-24T10:50:17.605527468Z s6-rc: info: service svc-nginx successfully started
80+
2024-08-24T10:50:17.605638686Z s6-rc: info: service svc-de: starting
81+
2024-08-24T10:50:17.607027492Z s6-rc: info: service svc-de successfully started
82+
2024-08-24T10:50:17.607146910Z s6-rc: info: service svc-docker: starting
83+
2024-08-24T10:50:17.608408179Z s6-rc: info: service svc-docker successfully started
84+
2024-08-24T10:50:17.608492298Z s6-rc: info: service legacy-services: starting
85+
2024-08-24T10:50:17.613769568Z _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
86+
2024-08-24T10:50:17.614036994Z
87+
2024-08-24T10:50:17.614045764Z Xvnc KasmVNC 1.2.0 - built Aug 17 2024 19:02:57
88+
2024-08-24T10:50:17.614050214Z Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
89+
2024-08-24T10:50:17.614053934Z See http://kasmweb.com for information on KasmVNC.
90+
2024-08-24T10:50:17.614057574Z Underlying X server release 12014000, The X.Org Foundation
91+
2024-08-24T10:50:17.614070483Z
92+
2024-08-24T10:50:17.614802321Z s6-rc: info: service legacy-services successfully started
93+
2024-08-24T10:50:17.614884720Z s6-rc: info: service ci-service-check: starting
94+
2024-08-24T10:50:17.615947832Z [ls.io-init] done.
95+
2024-08-24T10:50:17.616290966Z s6-rc: info: service ci-service-check successfully started
96+
2024-08-24T10:50:17.703191248Z Obt-Message: Xinerama extension is not present on the server
97+
2024-08-24T10:50:17.779509218Z Traceback (most recent call last):
98+
2024-08-24T10:50:17.779525098Z File \"<string>\", line 8, in <module>
99+
2024-08-24T10:50:17.779529558Z FileNotFoundError: [Errno 2] No such file or directory: '/lsiopy/bin/activate_this.py'
100+
2024-08-24T10:50:17.869610146Z FreeCAD 0.20.2, Libs: 0.20.2R
101+
2024-08-24T10:50:17.869629786Z © Juergen Riegel, Werner Mayer, Yorik van Havre and others 2001-2022
102+
2024-08-24T10:50:17.869633766Z FreeCAD is free and open-source software licensed under the terms of LGPL2+ license.
103+
2024-08-24T10:50:17.869636936Z FreeCAD wouldn't be possible without FreeCAD community.
104+
2024-08-24T10:50:17.869639846Z ##### #### ### ####
105+
2024-08-24T10:50:17.869643056Z # # # # # #
106+
2024-08-24T10:50:17.869645926Z # ## #### #### # # # # #
107+
2024-08-24T10:50:17.869648846Z #### # # # # # # # ##### # #
108+
2024-08-24T10:50:17.869651696Z # # #### #### # # # # #
109+
2024-08-24T10:50:17.869654495Z # # # # # # # # # ## ## ##
110+
2024-08-24T10:50:17.869657395Z # # #### #### ### # # #### ## ## ##
111+
2024-08-24T10:50:17.869660235Z
112+
2024-08-24T10:50:18.114299083Z 17
113+
2024-08-24T10:50:21.902274200Z [350:356:0824/035021.902000:ERROR:command_buffer_proxy_impl.cc(141)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
114+
2024-08-24T10:51:53.810828279Z 2024-08-24 03:51:53,810 [INFO] websocket 0: got client connection from 127.0.0.1
115+
2024-08-24T10:51:53.827898731Z 2024-08-24 03:51:53,827 [PRIO] Connections: accepted: @172.17.0.2_1724496713.810946::websocket
116+
2024-08-24T10:52:03.966292085Z 2024-08-24 03:52:03,966 [PRIO] Connections: closed: @172.17.0.2_1724496713.810946::websocket (Clean disconnection)

0 commit comments

Comments
 (0)