Skip to content

Commit

Permalink
Merge pull request #49 from linuxserver/Add-builder-info
Browse files Browse the repository at this point in the history
  • Loading branch information
GilbN authored Aug 25, 2024
2 parents 0e01126 + 6553ed5 commit 93dc5fc
Show file tree
Hide file tree
Showing 10 changed files with 763 additions and 18 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -v
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
.jenkins-external
venv
venv*
__pycache__
.vscode
/output

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
36 changes: 31 additions & 5 deletions ci/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self) -> None:
self.logs_timeout: int = (os.environ.get("DOCKER_LOGS_TIMEOUT", "120") or "120")
self.sbom_timeout: int = (os.environ.get("SBOM_TIMEOUT", "900") or "900")
self.port: int = (os.environ.get("PORT", "80") or "80")

self.builder: str = os.environ.get("NODE_NAME", "-")
self.ssl: str = os.environ.get("SSL", "false")
self.region: str = os.environ.get("S3_REGION", "us-east-1")
self.bucket: str = os.environ.get("S3_BUCKET", "ci-tests.linuxserver.io")
Expand All @@ -99,6 +99,7 @@ def __init__(self) -> None:

env_data = dedent(f"""
ENVIRONMENT DATA:
NODE_NAME: '{os.environ.get("NODE_NAME")}'
IMAGE: '{os.environ.get("IMAGE")}'
BASE: '{os.environ.get("BASE")}'
META_TAG: '{os.environ.get("META_TAG")}'
Expand All @@ -121,9 +122,21 @@ def __init__(self) -> None:
SSL: '{os.environ.get("SSL")}'
S3_REGION: '{os.environ.get("S3_REGION")}'
S3_BUCKET: '{os.environ.get("S3_BUCKET")}'
Docker Engine Version: '{docker.from_env().version().get("Version")}'
Docker Engine Version: '{self.get_docker_engine_version()}'
""")
self.logger.info(env_data)

def get_docker_engine_version(self) -> str:
"""Get the Docker Engine version
Returns:
str: The Docker Engine version
"""
try:
return docker.from_env().version().get("Version")
except Exception:
logger.error("Failed to get Docker Engine version!")
return "Unknown"

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

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

self.client: DockerClient = docker.from_env()
self.client: DockerClient = self.create_docker_client()
self.tags = list(self.tags_env.split("|"))
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
self.report_containers: dict[str,dict[str,dict]] = {}
Expand Down Expand Up @@ -507,6 +520,7 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
"created": "xxxx-xx-xx",
"size": "100MB",
"maintainer": "user"
"builder": "node"
}
```
"""
Expand All @@ -519,6 +533,7 @@ def get_build_info(self,container:Container,tag:str) -> dict[str,str]:
"created": container.attrs["Config"]["Labels"]["org.opencontainers.image.created"],
"size": "%.2f" % float(int(container.image.attrs["Size"])/1000000) + "MB",
"maintainer": container.attrs["Config"]["Labels"]["maintainer"],
"builder": self.builder
}
self._add_test_result(tag, test, "PASS", "-", start_time)
self.logger.success("Get build info on tag '%s': PASS", tag)
Expand Down Expand Up @@ -847,6 +862,17 @@ def create_s3_client(self) -> boto3.client:
aws_access_key_id=self.s3_key,
aws_secret_access_key=self.s3_secret)
return s3_client

def create_docker_client(self) -> DockerClient|None:
"""Create and return a docker client object
Returns:
DockerClient: A docker client object
"""
try:
return docker.from_env()
except Exception:
self.logger.error("Failed to create Docker client!")

class CIError(Exception):
pass
17 changes: 5 additions & 12 deletions ci/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -593,18 +593,11 @@ <h2 class="section-header-h2">
{% endif %}
<div class="build-section">Build Information</div>
<div class="build-info-section build">
<div class="build-summary">
<span class="build-header">Version:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["version"] }}</span>
</div>
<div class="build-summary">
<span class="build-header">Created:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["created"] }}</span>
</div>
<div class="build-summary">
<span class="build-header">Size:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["size"] }}</span>
</div>
<div class="build-summary">
<span class="build-header">Maintainer:</span> <span class="build-info">{{ report_containers[tag]["build_info"]["maintainer"] }}</span>
</div>
{% for key, value in report_containers[tag]["build_info"].items() %}
<div class="build-summary">
<span class="build-header">{{ key|capitalize }}:</span> <span class="build-info">{{ value }}</span>
</div>
{% endfor %}
</div>
<summary class="summary">
<a href="{{ tag }}.log.html" target="_blank">View Container Logs</a>
Expand Down
5 changes: 5 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-r requirements.txt
pytest
pytest-cov
pytest-mock
wheel
116 changes: 116 additions & 0 deletions tests/log_blob.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
2024-08-24T10:50:17.122835042Z s6-rc: info: service s6rc-oneshot-runner: starting
2024-08-24T10:50:17.124912597Z s6-rc: info: service s6rc-oneshot-runner successfully started
2024-08-24T10:50:17.124973716Z s6-rc: info: service fix-attrs: starting
2024-08-24T10:50:17.125050965Z s6-rc: info: service init-migrations: starting
2024-08-24T10:50:17.125146673Z s6-rc: info: service init-envfile: starting
2024-08-24T10:50:17.128569035Z [migrations] started
2024-08-24T10:50:17.128588625Z s6-rc: info: service fix-attrs successfully started
2024-08-24T10:50:17.128612144Z [migrations] no migrations found
2024-08-24T10:50:17.128687663Z s6-rc: info: service legacy-cont-init: starting
2024-08-24T10:50:17.129015388Z s6-rc: info: service init-migrations successfully started
2024-08-24T10:50:17.129110196Z s6-rc: info: service init-adduser: starting
2024-08-24T10:50:17.130271146Z s6-rc: info: service init-envfile successfully started
2024-08-24T10:50:17.132198574Z s6-rc: info: service legacy-cont-init successfully started
2024-08-24T10:50:17.276658044Z usermod: no changes
2024-08-24T10:50:17.277582028Z ───────────────────────────────────────
2024-08-24T10:50:17.277599098Z
2024-08-24T10:50:17.277603338Z ██╗ ███████╗██╗ ██████╗
2024-08-24T10:50:17.277607428Z ██║ ██╔════╝██║██╔═══██╗
2024-08-24T10:50:17.277611307Z ██║ ███████╗██║██║ ██║
2024-08-24T10:50:17.277615167Z ██║ ╚════██║██║██║ ██║
2024-08-24T10:50:17.277619017Z ███████╗███████║██║╚██████╔╝
2024-08-24T10:50:17.277622717Z ╚══════╝╚══════╝╚═╝ ╚═════╝
2024-08-24T10:50:17.277626577Z
2024-08-24T10:50:17.277630167Z Brought to you by linuxserver.io
2024-08-24T10:50:17.277633967Z ───────────────────────────────────────
2024-08-24T10:50:17.277812604Z
2024-08-24T10:50:17.277820684Z To support LSIO projects visit:
2024-08-24T10:50:17.277824054Z https://www.linuxserver.io/donate/
2024-08-24T10:50:17.277827204Z
2024-08-24T10:50:17.277830024Z ───────────────────────────────────────
2024-08-24T10:50:17.277833524Z GID/UID
2024-08-24T10:50:17.277836354Z ───────────────────────────────────────
2024-08-24T10:50:17.280318612Z
2024-08-24T10:50:17.280328742Z User UID: 911
2024-08-24T10:50:17.280340991Z User GID: 911
2024-08-24T10:50:17.280344011Z ───────────────────────────────────────
2024-08-24T10:50:17.290792965Z s6-rc: info: service init-adduser successfully started
2024-08-24T10:50:17.290863793Z s6-rc: info: service init-os-end: starting
2024-08-24T10:50:17.291607871Z s6-rc: info: service init-os-end successfully started
2024-08-24T10:50:17.291684610Z s6-rc: info: service init-kasmvnc: starting
2024-08-24T10:50:17.291768548Z s6-rc: info: service init-crontab-config: starting
2024-08-24T10:50:17.292426547Z s6-rc: info: service init-kasmvnc successfully started
2024-08-24T10:50:17.292495636Z s6-rc: info: service init-nginx: starting
2024-08-24T10:50:17.297762517Z s6-rc: info: service init-crontab-config successfully started
2024-08-24T10:50:17.433126600Z .............+.+.....+............+..........+..+....+..+....+...........+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.......+..+....+............+.........+.....+...+.......+........+..........+...+..+.+...............+..+...+......+.+...............+...............+...+......+...+........+...+....+........+.......+...........+......+.+............+........+...+..........+.........+..+.+..................+.....+....+.....+...+....+...............+.........+......+.....+.+..+............+.+...+............+............+.....+..................+....+........+..................+...+.+...+.....+.......+...+...........+....+.....+...+............+...+...+...............+.+...+..+....+......+......+...+.....+......+.........+.+.........+...............+......+...+.....+.+......+...+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2024-08-24T10:50:17.521335090Z ..+...+...+..+......+..........+.....+....+..+.+...+..+....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+..+..........+...+..+.........+.........+.......+...+.....+......+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+....+...............+.....+..........+...........+...+..................+...+......................+..+...+............+.+............+...+......+..............+.+......+...+..+......................+..+....+.....+....+..+.+.....+............+......+.+...+........+....+.........+..............+.......+.....+...+......+.+...+...+........+....+..+...+...+....+...+...........+.+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2024-08-24T10:50:17.523934416Z -----
2024-08-24T10:50:17.534042865Z s6-rc: info: service init-nginx successfully started
2024-08-24T10:50:17.534141954Z s6-rc: info: service init-kasmvnc-config: starting
2024-08-24T10:50:17.578754430Z s6-rc: info: service init-kasmvnc-config successfully started
2024-08-24T10:50:17.579685815Z s6-rc: info: service init-video: starting
2024-08-24T10:50:17.586924972Z s6-rc: info: service init-video successfully started
2024-08-24T10:50:17.587018161Z s6-rc: info: service init-kasmvnc-end: starting
2024-08-24T10:50:17.587849567Z s6-rc: info: service init-kasmvnc-end successfully started
2024-08-24T10:50:17.588260720Z s6-rc: info: service init-config: starting
2024-08-24T10:50:17.589203354Z s6-rc: info: service init-config successfully started
2024-08-24T10:50:17.589295582Z s6-rc: info: service init-config-end: starting
2024-08-24T10:50:17.590151768Z s6-rc: info: service init-config-end successfully started
2024-08-24T10:50:17.590226156Z s6-rc: info: service init-mods: starting
2024-08-24T10:50:17.590921155Z s6-rc: info: service init-mods successfully started
2024-08-24T10:50:17.590990383Z s6-rc: info: service init-mods-package-install: starting
2024-08-24T10:50:17.594913657Z s6-rc: info: service init-mods-package-install successfully started
2024-08-24T10:50:17.594981996Z s6-rc: info: service init-mods-end: starting
2024-08-24T10:50:17.595687814Z s6-rc: info: service init-mods-end successfully started
2024-08-24T10:50:17.595757153Z s6-rc: info: service init-custom-files: starting
2024-08-24T10:50:17.598857481Z [custom-init] No custom files found, skipping...
2024-08-24T10:50:17.599207205Z s6-rc: info: service init-custom-files successfully started
2024-08-24T10:50:17.599285493Z s6-rc: info: service init-services: starting
2024-08-24T10:50:17.599980762Z s6-rc: info: service init-services successfully started
2024-08-24T10:50:17.600063090Z s6-rc: info: service svc-pulseaudio: starting
2024-08-24T10:50:17.600142799Z s6-rc: info: service svc-cron: starting
2024-08-24T10:50:17.601347238Z s6-rc: info: service svc-pulseaudio successfully started
2024-08-24T10:50:17.601456507Z s6-rc: info: service svc-kasmvnc: starting
2024-08-24T10:50:17.601586164Z s6-rc: info: service svc-cron successfully started
2024-08-24T10:50:17.602806224Z s6-rc: info: service svc-kasmvnc successfully started
2024-08-24T10:50:17.602933032Z s6-rc: info: service svc-kclient: starting
2024-08-24T10:50:17.604124731Z s6-rc: info: service svc-kclient successfully started
2024-08-24T10:50:17.604230550Z s6-rc: info: service svc-nginx: starting
2024-08-24T10:50:17.605527468Z s6-rc: info: service svc-nginx successfully started
2024-08-24T10:50:17.605638686Z s6-rc: info: service svc-de: starting
2024-08-24T10:50:17.607027492Z s6-rc: info: service svc-de successfully started
2024-08-24T10:50:17.607146910Z s6-rc: info: service svc-docker: starting
2024-08-24T10:50:17.608408179Z s6-rc: info: service svc-docker successfully started
2024-08-24T10:50:17.608492298Z s6-rc: info: service legacy-services: starting
2024-08-24T10:50:17.613769568Z _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
2024-08-24T10:50:17.614036994Z
2024-08-24T10:50:17.614045764Z Xvnc KasmVNC 1.2.0 - built Aug 17 2024 19:02:57
2024-08-24T10:50:17.614050214Z Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
2024-08-24T10:50:17.614053934Z See http://kasmweb.com for information on KasmVNC.
2024-08-24T10:50:17.614057574Z Underlying X server release 12014000, The X.Org Foundation
2024-08-24T10:50:17.614070483Z
2024-08-24T10:50:17.614802321Z s6-rc: info: service legacy-services successfully started
2024-08-24T10:50:17.614884720Z s6-rc: info: service ci-service-check: starting
2024-08-24T10:50:17.615947832Z [ls.io-init] done.
2024-08-24T10:50:17.616290966Z s6-rc: info: service ci-service-check successfully started
2024-08-24T10:50:17.703191248Z Obt-Message: Xinerama extension is not present on the server
2024-08-24T10:50:17.779509218Z Traceback (most recent call last):
2024-08-24T10:50:17.779525098Z File \"<string>\", line 8, in <module>
2024-08-24T10:50:17.779529558Z FileNotFoundError: [Errno 2] No such file or directory: '/lsiopy/bin/activate_this.py'
2024-08-24T10:50:17.869610146Z FreeCAD 0.20.2, Libs: 0.20.2R
2024-08-24T10:50:17.869629786Z © Juergen Riegel, Werner Mayer, Yorik van Havre and others 2001-2022
2024-08-24T10:50:17.869633766Z FreeCAD is free and open-source software licensed under the terms of LGPL2+ license.
2024-08-24T10:50:17.869636936Z FreeCAD wouldn't be possible without FreeCAD community.
2024-08-24T10:50:17.869639846Z ##### #### ### ####
2024-08-24T10:50:17.869643056Z # # # # # #
2024-08-24T10:50:17.869645926Z # ## #### #### # # # # #
2024-08-24T10:50:17.869648846Z #### # # # # # # # ##### # #
2024-08-24T10:50:17.869651696Z # # #### #### # # # # #
2024-08-24T10:50:17.869654495Z # # # # # # # # # ## ## ##
2024-08-24T10:50:17.869657395Z # # #### #### ### # # #### ## ## ##
2024-08-24T10:50:17.869660235Z
2024-08-24T10:50:18.114299083Z 17
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.
2024-08-24T10:51:53.810828279Z 2024-08-24 03:51:53,810 [INFO] websocket 0: got client connection from 127.0.0.1
2024-08-24T10:51:53.827898731Z 2024-08-24 03:51:53,827 [PRIO] Connections: accepted: @172.17.0.2_1724496713.810946::websocket
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)
Loading

0 comments on commit 93dc5fc

Please sign in to comment.