#227 CI/CD: Add Makefile for updating CI/CD OpenShift Pipeline jobs
Merged by csomh. Opened by rayson.
rayson/waiverdb cicd-updating-script  into  master

Download 227.patch

OpenShift templates for WaiverDB pipelines are almost ready.
Let's put all pieces togerther by creating a script for batch updating the manifests installed on OpenShift.

This Makefile is used to update the OpenShift manifests for all pipeline jobs with a single run.
Parameters of the templates are configured by the script for the upstream WaiverDB
CI/CD workflow and service locations.

NOTE: Secrets and images in your OpenShift project are not touched by this script. You have to manually
manage them.

Log into your OpenShift project that is dedicated for CI/CD workloads.
You must have the admin access to the OpenShift project.

oc login <your-cluster>
oc project <your-project>

To install or update all CI/CD pipelines, just run

make install

To delete all manifests created by this script, run

make uninstall

rebased onto bccee55ba47eb2b75ed8aed2f4209d0def78184e

After running ./update-pipelines.sh install, following pipeline jobs are created in your OpenShift project:

  1. waiverdb-dev-pipeline
    This pipeline job should be triggered when a PR is created,updated, or merged, which matches the C3I pre-merge/post-merge workflows. Build parameter WAIVERDB_GIT_REF must be provided for the Git commid ID/branch when triggering a build.
    It will
  2. Run Flake8 and Pylint checks
  3. Run unit tests
  4. Build Docs
  5. Publish Docs (only when it's build against the master branch)
  6. Build SRPM
  7. Build RPM
  8. Invoke Rpmlint
  9. Build container
  10. Run functional tests
  11. Push container (only when it's build against the master branch)

  12. waiverdb-dev-integration-test
    It runs integration test against the current :latest (dev) image.

  13. waiverdb-stage-integration-test
    It runs integration test against the current :stage image.

  14. waiverdb-prod-integration-test
    It runs integration test against the current :prod image.

  15. waiverdb-integration-test
    It runs integration test against a user-specified image. Build parameter IMAGE must be provided.

  16. waiverdb-promoting-to-stage
    It promotes the current :latest image to :stage.

  17. waiverdb-promoting-to-prod
    It promotes the current :stage image to :prod.

rebased onto 060cf76ce87d0ac09d3851b816d689b6135d62fb

I am also thinking moving the parameter values to separated files. Any good idea for tracking pipeline job instances and their parameter values?

Nice, I was not aware of this syntax. Though SpellCheck warns: "This default assignment may cause DoS due to globbing. Quote it."

s/Intergration/Integration/
s/intergration/integration/

rebased onto 600900899bc1e446420a143576a14bada0b9a58a

Updated.

This depends on #223 and #225, right?

Did you consider using make or ansible for the purpose of putting all the things together?

Writing code for this feels a little bit exaggerated.

@csomh Makefile sounds a good choice. I would prefer not using ansible for this purpose because it seems to be too heavy.
I am thinking creating some new directories in openshift/, moving the templates and parameters to corresponding directories, then using a Makefile to batch update them.

For example, the directory structure for pipeline jobs waiverdb-dev-integration-test, waiverdb-stage-integration-test, and waiverdb-prod-integration-test coming from the template waiverdb-integration-test-template.yml:

openshift
├── containers
│   ├── jenkins-slave
│   │   ├── Dockerfile
│   └── waiverdb
│       └── Dockerfile
├── pipelines
│   ├── jobs
│   │   ├── waiverdb-dev-integration-test.env
│   │   └── waiverdb-dev-integration-test.tmpl
│   │   ├── waiverdb-stage-integration-test.env
│   │   └── waiverdb-stage-integration-test.tmpl
│   │   ├── waiverdb-prod-integration-test.env
│   │   └── waiverdb-prod-integration-test.tmpl
│   ├── Makefile
│   └── templates
│       ├── waiverdb-integration-test.Jenkinsfile
│       └── waiverdb-integration-test-template.yml
├── README.md

Parameters for a job are stored in file jobs/<job-name>.env, and the template the job uses is stored in file jobs/<job-name>.tmpl

For waiverdb-stage-integration-test pipeline job, api resources are created by:
oc process -f ./templates/waiverdb-integration-test-template.yml --param-file=./jobs/waiverdb-stage-integration-test.env.

Cool! This seems to be a good direction to follow!

@csomh I've updated https://pagure.io/waiverdb/pull-request/225 to match this new pattern.

rebased onto 6cf0507842544842d774676a51a823845dc4f3d9

Did you forgot to commit some files? The commit now contains only *.tmpl and *.env files and commit message doesn't match.

rebased onto 5cd8e15db1056f6ea71af73253cd872fedf26666

rebased onto a70f9ad564815daeb20273fb44c6442dbcdca8c7

@lholecek Updated.

You can mention how JOBS_DIR Makefile variable and*.env/*.tmpl files are used.

@lhellebr updated

rebased onto e6466faec157d0b4a0778e3f9623d02e5d40f9dc

@csomh Is this OK to merge or do you have any comments?

rebased onto eda922f65d579926d6887444677109751c59809c

Commit db3670a2 fixes this pull-request

Pull-Request has been merged by csomh

Pull-Request has been merged by csomh

Metadata