FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 26d10bbb authored by E. Kirk's avatar E. Kirk
Browse files

wip: add tooling configuration

parent b6c1465a
No related branches found
No related tags found
1 merge request!1Initial mean sprint capacity to suite Wilson team style sprints
Pipeline #566396 failed
[flake8]
max-line-length=99
exclude = .venv,venv,.tox,*/migrations/*,*/frontend/*,build/*
# Ignore E203, see explanation here:
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#id1
extend-ignore = E203
include:
- project: 'uis/devops/continuous-delivery/ci-templates'
file: '/auto-devops/common-pipeline.yml'
ref: v4.0.0
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/auto-devops/artifact-registry.yml"
ref: v4.0.0
python:tox:
variables:
TOX_ADDITIONAL_REQUIREMENTS: "poetry>=1.7.1"
variables:
DAST_DISABLED: true
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args:
- --unsafe
- id: check-json
- id: check-toml
- id: check-xml
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: mixed-line-ending
- id: pretty-format-json
args:
- --autofix
- --no-sort-keys
- id: debug-statements
- repo: https://github.com/python-poetry/poetry
rev: 1.8.0
hooks:
- id: poetry-check
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/timothycrosley/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 7.1.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
hooks:
- id: mypy
additional_dependencies: ["types-decorator"]
- repo: local
hooks:
- id: trivy
name: trivy
language: docker_image
pass_filenames: false
entry: aquasec/trivy:latest
args: ["--cache-dir", "/tmp/.trivy-cache", "--skip-dirs", "tests", "config", ".", "--exit-code", "1"]
# Change Log
## [0.0.1]
### Added
- POC/rough code for Wilson team
[tool.poetry]
name = "gitlab-stats"
version = "0.1.0"
version = "0.0.1"
description = ""
authors = ["Edward Kirk <ek599@cam.ac.uk>"]
readme = "README.md"
......
import gitlab
import os
import pprint
import gitlab
# private token or personal token authentication (self-hosted GitLab instance)
gl = gitlab.Gitlab(url='https://gitlab.developers.cam.ac.uk/', private_token=os.environ["GITLAB_TOKEN"])
gl = gitlab.Gitlab(
url="https://gitlab.developers.cam.ac.uk/", private_token=os.environ["GITLAB_TOKEN"]
)
# Test auth
gl.auth()
......@@ -14,32 +16,41 @@ iam_iterations = []
iterations = devops_group.iterations.list(iterator=True, cadence=14)
for iteration in iterations:
iam_iterations.append(iteration)
for iteration in iam_iterations:
iteration_id = iteration.id
issues = gl.issues.list(iterator=True, state="closed", labels=["team::Identity"], iteration_id=iteration_id, order="start_date", scope="all")
issues = gl.issues.list(
iterator=True,
state="closed",
labels=["team::Identity"],
iteration_id=iteration_id,
order="start_date",
scope="all",
)
total_weight = 0
total_time_days = 0
ticket_count = len(issues)
for issue in issues:
try:
if issue.weight:
total_weight += issue.weight
except AttributeError:
pass
#issue.time_stats["time_estimate"] == seconds w/ 8 hours == 1 day
# issue.time_stats["time_estimate"] == seconds w/ 8 hours == 1 day
total_time_days += issue.time_stats["time_estimate"] / 60 / 60 / 8
if ticket_count > 0:
print(f"iteration:{iteration.start_date} id:{iteration.id}")
print(f"estimate days: {total_time_days} weight: {total_weight} ticket count {ticket_count}")
print(
f"estimate days: {total_time_days} weight: {total_weight} ticket count {ticket_count}"
)
print("")
# FIXME
# Calculate mean for last quarter of work performed
# Calculate mean for last quarter of work performed
tox.ini 0 → 100644
# Tox runner configuration
#
# The following optional environment variables can change behaviour. See the
# comments where they are used for more information.
#
# - TOXINI_ARTEFACT_DIR
# - TOXINI_FLAKE8_VERSION
# - TOXINI_WORK_DIR
#
[tox]
# Envs which should be run by default.
envlist=py3
# Allow overriding toxworkdir via environment variable
toxworkdir={env:TOXINI_WORK_DIR:{toxinidir}/.tox}
# We do not actually ship a setup.py file which is used by our deployment.
# Django projects instead prefer to add the project directories to the Python
# path. (Or, with the current working directory being the project.) The
# skipsdist option tells tox it is OK to not run "setup.py install" for our
# project.
skipsdist=True
# The "_vars" section is ignored by tox but we place some useful shared
# variables in it to avoid needless repetition.
[_vars]
# Where to write build artefacts. We default to the "build" directory in the
# tox.ini file's directory. Override with the TOXINI_ARTEFACT_DIR environment
# variable.
build_root={env:TOXINI_ARTEFACT_DIR:{toxinidir}/build}
[testenv]
# Which environment variables should be passed into the environment.
passenv=
EXTERNAL_SETTING_*
# Allow people to override the coverage report location should they so wish.
COVERAGE_FILE
# How to run the test suite. Note that arguments passed to tox are passed on to
# the test command.
allowlist_externals=
poetry
commands_pre=
poetry install --no-root --sync
commands=
# Unlike many other libraries, we are running tests provided in the 'example'
# directory, which is very explicitly not a package. Therefore, we pass the test
# file directly as an argument to pytest.
coverage run --source={toxinidir} -m pytest --junitxml={[_vars]build_root}/junit.xml {posargs}
coverage html --directory {[_vars]build_root}/htmlcov/
coverage report
coverage xml -o {env:COVERAGE_XML_FILE:{[_vars]build_root}/coverage.xml}
[testenv:py3]
basepython=python3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment