Skip to content
Snippets Groups Projects
Commit a7530abc authored by Benedikt Steinbusch's avatar Benedikt Steinbusch
Browse files

update CI configuration to use public runner

parent cdb99806
Branches
No related tags found
No related merge requests found
variables:
VERSION: '1.1'
python_3_lint:
default:
image: python:3
tags:
- public-docker
lint:
before_script:
- pip install pylint
script:
- pylint -j 8 --disable=wrong-import-position,deprecated-lambda setup.py xenv
python_3_flake:
image: python:3
flake:
before_script:
- pip install flake8
script:
- flake8
python_3_radon:
image: python:3
radon:
before_script:
- pip install radon
script:
......@@ -25,15 +24,6 @@ python_3_radon:
- radon raw .
- radon hal .
python_3_tar:
image: python:3
script:
- tar --warning=no-file-changed --exclude=.git* --exclude=Makefile --exclude modules.sh --exclude tar.py --exclude xenv.ini --transform "s,^\.,xenv-${VERSION}-$(date +%Y%m%d)git${CI_COMMIT_SHA:0:7}," -cvzf xenv-${VERSION}-$(date +%Y%m%d)git${CI_COMMIT_SHA:0:7}.tar.gz . || ( export ret=$?; [[ $ret -eq 1 ]] || exit "$ret" )
artifacts:
paths:
- xenv-${VERSION}-$(date +%Y%m%d)git${CI_COMMIT_SHA:0:7}.tar.gz
python_3_install:
image: python:3
install:
script:
- python setup.py install
#!/usr/bin/env python
"""helper script for creating a tar archive of given python module"""
import datetime
import os
import shutil
import subprocess
import sys
import time
def create_process(argv):
"""
Create a process and return the handle
:param argv:
:return:
"""
process = subprocess.Popen(argv,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return process
def wait_for_process(process):
"""
Wait for termination of a process.
:param process:
:return:
"""
out, err = process.communicate()
return_code = process.wait()
return return_code, out, err
def _create_process_and_wait(argv):
"""
Create a subprocess and wait for it to exit. Return the exit
code and standard output/exit as a triplet.
:param argv:
:return: process handle
"""
return wait_for_process(create_process(argv))
def create_process_and_wait(argv):
"""
Variant of createProcessAndWait which does not return the exit code but
raises an exception if the command failed.
:param argv:
:return: tuple containing process stdout/stderr
"""
code, out, err = _create_process_and_wait(argv)
if code:
raise Exception(
'Command "{}" failed with exit code {}.'.format(argv, code))
return out.decode('utf-8'), err.decode('utf-8')
def git_head_commit():
"""
Get the short form of the HEAD commit of a git repostitory
:return: string
"""
return create_process_and_wait(
['git', 'rev-parse', '--verify', '--short', 'HEAD'])[0].strip()
def main(name, version):
"""
Create a archive for given sources with naming scheme following the Fedora
naming guidelines:
https://fedoraproject.org/wiki/Packaging:NamingGuidelines
:param name: package name for prefixinf result archive
:param version: version string for later archive
:return:
"""
date = datetime.datetime.fromtimestamp(time.time()).strftime('%Y%m%d')
commit = git_head_commit()
files = os.listdir('.')
archive = '{}-{}-{}git{}'.format(name, version, date, commit)
os.mkdir(archive)
for fle in files:
if fle in ['.git', '.gitignore', '.idea', 'tar.py', 'Makefile',
'modules.sh', 'xenv.ini' '.gitlab-ci.yml']:
continue
if os.path.isdir(fle):
copy = shutil.copytree
else:
copy = shutil.copy
copy(fle, archive + '/' + fle)
create_process_and_wait(['tar', '-czf', archive + '.tar.gz', archive])
shutil.rmtree(archive)
return 0
main(sys.argv[1], sys.argv[2])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment