Merge lp:~verterok/ols-jenkaas/job-lint into lp:~ols-jenkaas-admins/ols-jenkaas/trunk

Proposed by Guillermo Gonzalez
Status: Merged
Merged at revision: 892
Proposed branch: lp:~verterok/ols-jenkaas/job-lint
Merge into: lp:~ols-jenkaas-admins/ols-jenkaas/trunk
Diff against target: 56 lines (+39/-0)
2 files modified
Makefile (+19/-0)
testing/setup-job-lint-env (+20/-0)
To merge this branch: bzr merge lp:~verterok/ols-jenkaas/job-lint
Reviewer Review Type Date Requested Status
Przemysław Suliga (community) Approve
Online Services Jenkaas Administrators Pending
Review via email: mp+442785@code.launchpad.net

Commit message

Add very basic job linting target to the Makefile

This will render the jobs in ./tmp/test and barf in case of syntax errors (yaml identation, etc)

To post a comment you must log in.
Revision history for this message
Przemysław Suliga (suligap) wrote :

lgtm.

(Maybe it makes sense to start using ols pypi too.)

review: Approve
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

> lgtm.
>
> (Maybe it makes sense to start using ols pypi too.)

Indeed, but didn't want to pull too much things at once.

My aim with this is to allow anyone changing a job to render and inspect the generated jobs, even if that means using upstream pypi for the time being.

Need to collect the dependencies and probably submit a couple of sdists to ols-goodyear before we can use the pypi.ols.

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

updated it to use pypi.ols

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2017-01-04 15:39:20 +0000
+++ Makefile 2023-05-16 14:21:29 +0000
@@ -1,4 +1,9 @@
1FLAKE8 = flake81FLAKE8 = flake8
2ENV = $(CURDIR)/env
3PIP = $(ENV)/bin/pip
4TMPDIR = $(CURDIR)/tmp
5
6OLS_WHEELS_URI ?= https://pypi.ols.canonical.com
27
3test:8test:
4 PYTHONPATH=`pwd` ols-run-tests29 PYTHONPATH=`pwd` ols-run-tests2
@@ -6,3 +11,17 @@
6lint:11lint:
7 $(FLAKE8) --filename='*.py' . testing/jenkaas-run \12 $(FLAKE8) --filename='*.py' . testing/jenkaas-run \
8 testing/new-launchpad-oauth-token13 testing/new-launchpad-oauth-token
14
15$(ENV):
16 python3 -m venv $(ENV)
17 $(PIP) install -f $(OLS_WHEELS_URI) --no-index jenkins-job-builder==2.10.1 jenkins-jobs-mattermost
18
19$(TMPDIR):
20 mkdir -p $@
21
22lint-jobs: $(ENV) $(TMPDIR)
23 testing/setup-job-lint-env $(TMPDIR)/job-lint
24 cd $(TMPDIR)/job-lint && $(ENV)/bin/jenkins-jobs --ignore-cache --flush-cache --conf $(TMPDIR)/job-lint/jenkins_jobs.ini test $(CURDIR)/jobs -o $(TMPDIR)/test/
25
26clean:
27 rm -rf $(TMPDIR)
928
=== added file 'testing/setup-job-lint-env'
--- testing/setup-job-lint-env 1970-01-01 00:00:00 +0000
+++ testing/setup-job-lint-env 2023-05-16 14:21:29 +0000
@@ -0,0 +1,20 @@
1#!/bin/bash
2# create a barebones config that alllow us to just render the jobs
3BASE_DIR=$1
4INCLUDE_DIR=$BASE_DIR/includes
5SECRETS_DIR=$BASE_DIR/secrets
6mkdir -p ${INCLUDE_DIR} ${SECRETS_DIR}
7echo true > ${INCLUDE_DIR}/is-testing.yaml
8echo false > ${INCLUDE_DIR}/is-production.yaml
9echo '[worker1,worker2]' > ${INCLUDE_DIR}/slaves.yaml
10echo "" > ${INCLUDE_DIR}/create-slave-envrc
11echo "" > ${SECRETS_DIR}/mattermost.endpoint
12cat << EOF > ${BASE_DIR}/jenkins_jobs.ini
13[job_builder]
14# Reminder: this is the default
15allow_duplicates=False
16keep_descriptions=True
17ignore_cache=True
18include_path=.:${INCLUDE_DIR}
19recursive=False
20EOF

Subscribers

People subscribed via source and target branches