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
1=== modified file 'Makefile'
2--- Makefile 2017-01-04 15:39:20 +0000
3+++ Makefile 2023-05-16 14:21:29 +0000
4@@ -1,4 +1,9 @@
5 FLAKE8 = flake8
6+ENV = $(CURDIR)/env
7+PIP = $(ENV)/bin/pip
8+TMPDIR = $(CURDIR)/tmp
9+
10+OLS_WHEELS_URI ?= https://pypi.ols.canonical.com
11
12 test:
13 PYTHONPATH=`pwd` ols-run-tests2
14@@ -6,3 +11,17 @@
15 lint:
16 $(FLAKE8) --filename='*.py' . testing/jenkaas-run \
17 testing/new-launchpad-oauth-token
18+
19+$(ENV):
20+ python3 -m venv $(ENV)
21+ $(PIP) install -f $(OLS_WHEELS_URI) --no-index jenkins-job-builder==2.10.1 jenkins-jobs-mattermost
22+
23+$(TMPDIR):
24+ mkdir -p $@
25+
26+lint-jobs: $(ENV) $(TMPDIR)
27+ testing/setup-job-lint-env $(TMPDIR)/job-lint
28+ 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/
29+
30+clean:
31+ rm -rf $(TMPDIR)
32
33=== added file 'testing/setup-job-lint-env'
34--- testing/setup-job-lint-env 1970-01-01 00:00:00 +0000
35+++ testing/setup-job-lint-env 2023-05-16 14:21:29 +0000
36@@ -0,0 +1,20 @@
37+#!/bin/bash
38+# create a barebones config that alllow us to just render the jobs
39+BASE_DIR=$1
40+INCLUDE_DIR=$BASE_DIR/includes
41+SECRETS_DIR=$BASE_DIR/secrets
42+mkdir -p ${INCLUDE_DIR} ${SECRETS_DIR}
43+echo true > ${INCLUDE_DIR}/is-testing.yaml
44+echo false > ${INCLUDE_DIR}/is-production.yaml
45+echo '[worker1,worker2]' > ${INCLUDE_DIR}/slaves.yaml
46+echo "" > ${INCLUDE_DIR}/create-slave-envrc
47+echo "" > ${SECRETS_DIR}/mattermost.endpoint
48+cat << EOF > ${BASE_DIR}/jenkins_jobs.ini
49+[job_builder]
50+# Reminder: this is the default
51+allow_duplicates=False
52+keep_descriptions=True
53+ignore_cache=True
54+include_path=.:${INCLUDE_DIR}
55+recursive=False
56+EOF

Subscribers

People subscribed via source and target branches