Skip to content
Snippets Groups Projects
Unverified Commit 8eb5f943 authored by Roman Azarenko's avatar Roman Azarenko
Browse files

CI: add job to update code-analysis Dockerfile

parent 44569d81
No related branches found
No related tags found
1 merge request!16CI: add job to update code-analysis Dockerfile
code-analysis-update:
stage: build
image: iopsys/sdk-builder:latest
variables:
GIT_STRATEGY: none
script:
- git clone --depth=1 -b "$CI_COMMIT_BRANCH" "https://token:${CODE_ANALYSIS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git/" gitlab-ci-pipeline
- cd gitlab-ci-pipeline/docker/code-analysis
- ./bump_code_analysis_lib_versions.py Dockerfile
- |
if ! git diff-index --name-status --exit-code HEAD; then
git config user.name 'IOWRT code-analysis updater'
git config user.email 'noreply@iopsys.eu'
git add .
git commit -m 'Bump IOWRT library versions'
git push
fi
rules:
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
interruptible: true
# Job retry is useful if somebody happened to push to the code-analysis repo while this job was running
retry:
max: 2
when: script_failure
pages:
stage: deploy
image: alpine:latest
......
{
"ubus": "https://dev.iopsys.eu/iopsys/iopsyswrt/-/raw/devel/package/system/ubus/Makefile",
"uci": "https://dev.iopsys.eu/iopsys/iopsyswrt/-/raw/devel/package/system/uci/Makefile",
"rpcd": "https://dev.iopsys.eu/iopsys/iopsyswrt/-/raw/devel/package/system/rpcd/Makefile",
"libubox": "https://dev.iopsys.eu/iopsys/iopsyswrt/-/raw/devel/package/libs/libubox/Makefile"
}
#!/usr/bin/python3
import argparse
import json
import logging
import pathlib
import re
import requests
PKG_SOURCE_VERSION = re.compile(r'PKG_SOURCE_VERSION:=(\S+)')
def get_package_version(makefile_url: str) -> str:
resp = requests.get(makefile_url)
version = PKG_SOURCE_VERSION.search(resp.text).group(1)
return version
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
config_path = pathlib.Path(__file__).absolute().parent / 'bump_code_analysis_lib_versions.json'
with config_path.open('r') as f:
config = json.load(f)
logging.info(f'Configuration: {config}')
parser = argparse.ArgumentParser()
parser.add_argument(
'dockerfile',
help='Dockerfile to update version arguments in',
metavar='DOCKERFILE',
type=argparse.FileType('r'),
)
args = parser.parse_args()
with args.dockerfile as f:
dockerfile = f.read()
dockerfile_orig = dockerfile
for package_name, makefile_url in config.items():
logging.info(f'Fetching Makefile for package {package_name}')
package_version = get_package_version(makefile_url)
logging.info(f'Package {package_name} has version {package_version} in Makefile')
docker_arg = f'{package_name.upper()}_VERSION'
dockerfile = re.sub(fr'(?<=ARG {docker_arg}=)\S+', package_version, dockerfile)
if dockerfile != dockerfile_orig:
logging.info('Dockerfile changed, writing to disk')
with open(args.dockerfile.name, 'w') as f:
f.write(dockerfile)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment