Skip to content

Commit

Permalink
ci - ensure zuul-client installation in src_dir/bin instead of user h…
Browse files Browse the repository at this point in the history
…ome_dir

This change avoids the interaction with the user home directory by
installing zuul-client at a controlled version in the local project bin/
directory.

Change-Id: Ia02f0adf5ff21cc91384ba4d26f29d3ab1943b84
  • Loading branch information
morucci committed Jun 6, 2024
1 parent e557b0a commit fc28a9d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
MKDOCS ?= $(LOCALBIN)/mkdocs/bin/mkdocs
ZC ?= $(LOCALBIN)/zc/bin/zuul-client

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
Expand All @@ -170,12 +171,18 @@ OPERATOR_SDK_VERSION ?= 1.34.2
STATICCHECK_VERSION ?= 2023.1.7
MKDOCS_VERSION ?= 1.5.3
SETUP_ENVTEST_VERSION ?= v0.0.0-20240320141353-395cfc7486e6
ZUUL_CLIENT_VERSION ?= 10.0.0

.PHONY: mkdocs
mkdocs: $(MKDOCS) ## Install material for mkdocs locally if necessary
$(MKDOCS): $(LOCALBIN)
( test -f $(LOCALBIN)/mkdocs/bin/mkdocs && [[ "$(shell $(LOCALBIN)/mkdocs/bin/mkdocs -V)" =~ "$(MKDOCS_VERSION)" ]] ) || ( python -m venv $(LOCALBIN)/mkdocs && $(LOCALBIN)/mkdocs/bin/pip install --upgrade -r mkdocs-requirements.txt )

.PHONY: zuul-client
zuul-client: $(ZC) ## Install zuul-client locally if necessary
$(ZC): $(LOCALBIN)
( test -f $(LOCALBIN)/zc/bin/zuul-client && [[ "$(shell $(LOCALBIN)/zc/bin/zuul-client --version)" =~ "$(ZUUL_CLIENT_VERSION)" ]] ) || ( python -m venv $(LOCALBIN)/zc && $(LOCALBIN)/zc/bin/pip install zuul-client )

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/kustomize/${KUSTOMIZE_VERSION}/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
];
shellHook = ''
echo "Welcome in $name"
export LC_ALL=C.UTF-8
export GOPATH=$(go env GOPATH)
export GOBIN=$(go env GOPATH)/bin
'';
Expand Down
16 changes: 11 additions & 5 deletions roles/health-check/zuul-client-api/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
- name: Ensure zuul-client installation
community.general.make:
target: "zuul-client"
chdir: "{{ zuul.project.src_dir }}"

- set_fact:
zuul_client: "{{ zuul.project.src_dir }}/bin/zc/bin/zuul-client"

- name: Create a zuul-client configuration file
ansible.builtin.shell: >
go run ./main.go --config playbooks/files/sf-operator-cli.yaml zuul create client-config --insecure
Expand All @@ -12,18 +20,16 @@

- name: Create a autohold request with zuul-client and the generated config
ansible.builtin.command: |
zuul-client -c /tmp/zuul-client.conf --use-config internal autohold --project config --job config-update --reason CI_TEST
args:
chdir: "{{ zuul.project.src_dir }}"
{{ zuul_client }} -c /tmp/zuul-client.conf --use-config internal autohold --project config --job config-update --reason CI_TEST
- name: Ensure autohold was set properly
ansible.builtin.command: |
zuul-client -c /tmp/zuul-client.conf --use-config internal autohold-list
{{ zuul_client }} -c /tmp/zuul-client.conf --use-config internal autohold-list
register: _ah_list
failed_when: '"CI_TEST" not in _ah_list.stdout'

- name: Remove autohold
ansible.builtin.shell: >
echo "{{ _ah_list.stdout }}" |
grep -oE "0000[0-9]+" |
xargs zuul-client -c /tmp/zuul-client.conf --use-config internal autohold-delete
xargs {{ zuul_client }} -c /tmp/zuul-client.conf --use-config internal autohold-delete
1 change: 0 additions & 1 deletion roles/setup-env/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@
- kubernetes
- oauthlib>=3.2.2
- websocket-client
- zuul-client

0 comments on commit fc28a9d

Please sign in to comment.