Skip to content

Commit

Permalink
Add env argument to all job building functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlyak40wt committed Mar 2, 2024
1 parent 370c945 commit 60a197e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ New
===
* Now you can specify ENV argument to 40ANTS-CI:DEFWORKFLOW and any job. This should be an alist where keys are strings and values are evaluated during GitHub workflow generation phase. Read more in 40ANTS-CI-DOCS/INDEX::@ENV section.
* 40ANTS-CI/JOBS/AUTOTAG:AUTOTAG function now ignores TOKEN-PATTERN argument if ENV argument was given and has GITHUB_TOKEN value for whole job.
Backward incompatible changes
=============================
* When additional keyword arguments to 40ANTS-CI/STEPS/SH:SH function are given, they are transformed into env variables. Previously, their names were taken as is. Now they are uppercased and dash symbols are replaced with underscores.
")
(0.14.0 2024-02-25
"
Expand Down
15 changes: 10 additions & 5 deletions src/jobs/autotag.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(uiop:define-package #:40ants-ci/jobs/autotag
(:use #:cl)
(:import-from #:40ants-ci/jobs/job)
(:import-from #:40ants-ci/jobs/job
#:job-env)
(:import-from #:40ants-ci/steps/action
#:action)
(:export #:autotag
Expand Down Expand Up @@ -48,13 +49,15 @@
(defun autotag (&key (filename *default-filename*)
(regex *default-regex*)
(tag-prefix *default-tag-prefix*)
(token-pattern *default-token-pattern*))
(token-pattern *default-token-pattern*)
env)
"Creates a job which will run autotagger to create a new git tag for release."
(make-instance 'autotag
:filename filename
:regex regex
:tag-prefix tag-prefix
:token-pattern token-pattern))
:token-pattern token-pattern
:env env))


(defmethod 40ants-ci/jobs/job:steps ((job autotag))
Expand All @@ -67,6 +70,8 @@
:root (filename job)
:regex_pattern (regex job)
:tag_prefix (tag-prefix job)
:env (list :github_token
(token-pattern job))))
:env (unless (assoc "GITHUB_TOKEN" (job-env job)
:test #'string=)
(list :github_token
(token-pattern job)))))
(call-next-method)))
5 changes: 3 additions & 2 deletions src/jobs/critic.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:reader ignore-critiques)))


(defun critic (&key asdf-systems asdf-version ignore-critiques)
(defun critic (&key asdf-systems asdf-version ignore-critiques env)
"Creates a job which will run Lisp Critic for given ASDF systems.
If argument ASDF-SYSTEMS is NIL, it will use ASDF system
Expand All @@ -36,7 +36,8 @@
:asdf-system (first asdf-systems)
:asdf-systems asdf-systems
:asdf-version asdf-version
:ignore-critiques ignore-critiques)))
:ignore-critiques ignore-critiques
:env env)))


(defmethod 40ants-ci/jobs/job:steps ((job critic))
Expand Down
18 changes: 10 additions & 8 deletions src/jobs/docs.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
(:documentation "Builds documentation and uploads it to GitHub using [\"40ants/build-docs\" github action](https://40ants.com/build-docs/)."))


;; (defun build-docs (&key asdf-system
;; asdf-version
;; (error-on-warnings t))
;; "Creates a job of class BUILD-DOCS."
;; (make-instance 'build-docs
;; :asdf-system asdf-system
;; :error-on-warnings error-on-warnings
;; :asdf-version asdf-version))
(defun build-docs (&key asdf-system
asdf-version
(error-on-warnings t)
env)
"Creates a job of class BUILD-DOCS."
(make-instance 'build-docs
:asdf-system asdf-system
:error-on-warnings error-on-warnings
:asdf-version asdf-version
:env env))


(defmethod 40ants-ci/jobs/job:steps ((job build-docs))
Expand Down
6 changes: 4 additions & 2 deletions src/jobs/run-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
quicklisp
lisp
exclude
custom)
custom
env)
"Creates a job step of class RUN-TESTS."
(declare (ignore coverage qlfile os quicklisp lisp
asdf-system asdf-version exclude))
asdf-system asdf-version exclude
env))
(check-type custom
(or null string list))
(apply #'make-instance 'run-tests
Expand Down
4 changes: 3 additions & 1 deletion src/workflow.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
- (foo 1 2 3) -> result of foo call.
"
(if (and (listp arg)
(not (symbolp (first arg))))
(or (not (symbolp (first arg)))
;; We don't want to eval plists
(keywordp (first arg))))
arg
(eval arg)))

Expand Down

0 comments on commit 60a197e

Please sign in to comment.