Skip to content

Commit

Permalink
[stable/zed] Implement collection release process (#1085)
Browse files Browse the repository at this point in the history
build: build all images + run tests using them (#1069)
ci: fix promotion jobs (#1072)
[stable/zed] Drop conventional-commit requirement (#1082)
[stable/zed] fix(ipmi-exporter): Ignore additional sensor IDs (BP/Entity Presence) (#1077)
Implement collection release process (#1083)
  • Loading branch information
mnaser authored Apr 11, 2024
1 parent a0bbcb7 commit 841686a
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 13 deletions.
12 changes: 0 additions & 12 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ build.venv:
RUN pip install -r requirements.txt
SAVE IMAGE --cache-hint

build.venv.dev:
FROM +build.venv --only main,dev
SAVE ARTIFACT /venv

build.venv.runtime:
FROM +build.venv --only main
SAVE ARTIFACT /venv
Expand Down Expand Up @@ -105,14 +101,6 @@ image:
ARG REGISTRY=ghcr.io/vexxhost/atmosphere
SAVE IMAGE --push ${REGISTRY}:${tag}

pin-images:
FROM +build.venv.dev
COPY roles/defaults/vars/main.yml /defaults.yml
COPY build/pin-images.py /usr/local/bin/pin-images
ARG REGISTRY=ghcr.io/vexxhost/atmosphere
RUN --no-cache /usr/local/bin/pin-images --registry ${REGISTRY} /defaults.yml /pinned.yml
SAVE ARTIFACT /pinned.yml AS LOCAL roles/defaults/vars/main.yml

gh:
FROM alpine:3
RUN apk add --no-cache github-cli
Expand Down
4 changes: 3 additions & 1 deletion build/pin-images.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def main():
parser.add_argument(
"src", help="Path for default values file", type=argparse.FileType("r")
)
parser.add_argument("dst", help="Path for output file", type=argparse.FileType("w"))
parser.add_argument(
"dst", help="Path for output file", type=argparse.FileType("r+")
)
parser.add_argument(
"-r",
"--registry",
Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ passenv =
commands =
{posargs}

[testenv:pin-digests]
deps =
oslo_config
oslo_log
ruyaml
commands =
python3 {toxinidir}/build/pin-images.py roles/defaults/vars/main.yml roles/defaults/vars/main.yml

[testenv:molecule-keycloak]
commands =
molecule test -s keycloak
Expand Down
12 changes: 12 additions & 0 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
# License for the specific language governing permissions and limitations
# under the License.

- job:
name: atmosphere-build-collection
pre-run: zuul.d/playbooks/build-collection/pre.yml
run: zuul.d/playbooks/build-collection/run.yml

- job:
name: atmosphere-publish-collection
parent: atmosphere-build-collection
post-run: zuul.d/playbooks/build-collection/publish.yml
secrets:
- ansible_galaxy_info

- job:
name: atmosphere-molecule
parent: tox
Expand Down
37 changes: 37 additions & 0 deletions zuul.d/playbooks/build-collection/pre.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2024 VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

- hosts: all
roles:
- ensure-python
- ensure-pip
- ensure-tox

- name: Install Ansible
hosts: all
vars:
ansible_venv_path: '{{ ansible_user_dir }}/.local/ansible'
ensure_ansible_version: ''
tasks:
- name: Create local venv
command: '{{ ensure_pip_virtualenv_command }} {{ ansible_venv_path }}'

- name: Install Ansible to local venv
command: '{{ ansible_venv_path }}/bin/pip install ansible{{ ensure_ansible_version }}'

- name: Export installed ansible paths
set_fact:
ansible_executable: '{{ ansible_venv_path }}/bin/ansible'
ansible_galaxy_executable: '{{ ansible_venv_path }}/bin/ansible-galaxy'
cacheable: true
60 changes: 60 additions & 0 deletions zuul.d/playbooks/build-collection/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2024 VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

- hosts: all
tasks:
- name: Find tarballs in the source directory.
find:
file_type: file
paths: "{{ zuul.project.src_dir }}"
patterns: "*.tar.gz"
register: result

- name: Display stat for tarballs and wheels.
stat:
path: "{{ item.path }}"
with_items: "{{ result.files }}"

- name: Publish content to Ansible Galaxy
block:
- name: Create ansible.cfg configuration file tempfile
tempfile:
state: file
suffix: .cfg
register: _ansiblecfg_tmp

- name: Create ansible.cfg configuration file
copy:
dest: "{{ _ansiblecfg_tmp.path }}"
mode: 0600
content: |
[galaxy]
server_list = release_galaxy
[galaxy_server.release_galaxy]
url = {{ ansible_galaxy_info.url }}
token = {{ ansible_galaxy_info.token }}
- name: Publish collection to Ansible Galaxy / Automation Hub
environment:
ANSIBLE_CONFIG: "{{ _ansiblecfg_tmp.path }}"
ansible.builtin.shell: |
{{ ansible_galaxy_executable }} collection publish -vvv {{ item.path }}
args:
chdir: "{{ zuul.project.src_dir }}"
loop: "{{ result.files }}"

always:
- name: Shred ansible-galaxy credentials
command: "shred {{ _ansiblecfg_tmp.path }}"
32 changes: 32 additions & 0 deletions zuul.d/playbooks/build-collection/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2024 VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

- name: Build collection
hosts: all
tasks:
- name: Pin all image digests
ansible.builtin.include_role:
name: tox
vars:
tox_envlist: pin-digests

- name: Print out the new image manifest file
ansible.builtin.command: |
cat {{ zuul.project.src_dir }}/roles/defaults/vars/main.yml
- name: Build Ansible collection
ansible.builtin.shell: |
{{ ansible_galaxy_executable }} collection build -vvv .
args:
chdir: '{{ zuul.project.src_dir }}'
5 changes: 5 additions & 0 deletions zuul.d/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
merge-mode: squash-merge
check:
jobs:
- atmosphere-build-collection
- atmosphere-molecule-aio-keycloak:
dependencies: &molecule_check_dependencies
- name: atmosphere-build-container-image-barbican
Expand Down Expand Up @@ -78,6 +79,7 @@
dependencies: *molecule_check_dependencies
gate:
jobs:
- atmosphere-build-collection
- atmosphere-molecule-aio-keycloak:
dependencies: &molecule_gate_dependencies
- name: atmosphere-upload-container-image-barbican
Expand Down Expand Up @@ -138,3 +140,6 @@
dependencies: *molecule_gate_dependencies
- atmosphere-molecule-csi-rbd:
dependencies: *molecule_gate_dependencies
release:
jobs:
- atmosphere-publish-collection
16 changes: 16 additions & 0 deletions zuul.d/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
k0YnUAItZ64qUR7paEUKGy4rzsZjDYvIj7DrCFvLL2CXcyjPGcmcblpSHe5vJ15CFVH8X
o39FIIhSmehvrYJziGYUgf4JY1B6ktBtFc9l78WeoJRHNce+viSSkBj1fhbUaI=

- secret:
name: ansible_galaxy_info
data:
url: https://galaxy.ansible.com
token: !encrypted/pkcs1-oaep
- GlYV1vSho2Q5FmS2awPcOVKuatGFm7rjrlUl9LpOdqbQa49ZxxEPAJtOcQWm77NYCDsFa
BhD3XBdH8QGgGqy0PqRgw48/kDw+3eVrXsBnaAUO583ElbMumcZdevYxHPRibR3FESinU
zDmc4VIAGJRkE5D0QYyp6jtJhhcaKUnBKNz3qvyTW4Lh03PHIuUR2UcaopJbfJiU+xMcE
gHZj9UZ7HwIE//q10euv/mxDwyICkdcU9UuWrNm16WdzIVtpwygJTaQNRo7pFN3POgmps
aNILKXp7Hfp0J6Hx1Hc7GmpJ9EmyYaNyktvOSf4jqpZCJvQ5CRWKHJC+jryHYBxOoT524
hU3Hoc32DOnytb1EZwzwu4iJbRMe1xEHWqBf9wpf3sV6B5Pvc7/IHTnU91/dlawOh5eOp
8wq45eO5w0c+PcITu9OUhWULKhEJcPunGNr0e96wdfK7L4khiPopHUTSbFF4dOhfF1GfV
GgFTakyVg9jKYKre0aLGW2Gah3gzXuX2IQ9XGXebsnFLdtQL5ac7ET0hKDR8tZBGrwKj6
c8bL2vzVKjOOD+sSnv4h7l+p8igtjczyVV83pn6dJ/v1GCMCFzGdOhaKJ2DIO1KtKK4jV
c80+tpz0x/Cr/4Ld4rJU4mqqC8Y3Kk6AC2cNzsiYh1iPlpw+D/yoE0Lgugjjzc=

- secret:
name: cosign_key
data:
Expand Down

0 comments on commit 841686a

Please sign in to comment.