Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CI to create PRs to bump to latest Ark timestamps #505

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a6d5ace
Added CI to create PRs to bump repos on main
wtripp180901 Dec 18, 2024
aedd0ec
merged refactor (won't be working in this commit)
wtripp180901 Dec 19, 2024
856541a
reworked for new repo list structure
wtripp180901 Dec 19, 2024
056e98b
fatimage build now integrated into timestamp bump
wtripp180901 Dec 20, 2024
9eedb46
now points fatimage on local branch
wtripp180901 Dec 20, 2024
04555a0
temporarily added pr trigger for testing
wtripp180901 Dec 20, 2024
f1f486b
fixed outputs
wtripp180901 Dec 20, 2024
333ac6e
fixed fatimage outputs
wtripp180901 Dec 20, 2024
90f8e7a
fixed environment
wtripp180901 Dec 20, 2024
bf14c8a
testing on branch
wtripp180901 Dec 20, 2024
4771f5c
moved to one step environment
wtripp180901 Dec 20, 2024
664c9db
prevent exit on failure checks
wtripp180901 Dec 20, 2024
94b5eef
auto sets upstream branch
wtripp180901 Dec 20, 2024
5088fdf
fixed outdated var and moved fatimage to bumped branch
wtripp180901 Dec 20, 2024
a59e6f7
fixed not picking up existing changes on automation branch
wtripp180901 Dec 20, 2024
e45bb31
should now checkout branches correctly
wtripp180901 Dec 20, 2024
58e0af8
fixes
wtripp180901 Dec 20, 2024
dd4ace0
fatimage now only created if head is timestamp commit
wtripp180901 Jan 2, 2025
a2b05ba
ci rerun
wtripp180901 Jan 2, 2025
7242f6c
fixed notes not being pushed
wtripp180901 Jan 2, 2025
1efd678
fixed notes
wtripp180901 Jan 2, 2025
533bb7c
fixed fatimage check
wtripp180901 Jan 2, 2025
b2302ee
debug logging
wtripp180901 Jan 2, 2025
cacce15
testing with strings
wtripp180901 Jan 2, 2025
1a5d3a3
ci test
wtripp180901 Jan 2, 2025
022f2a5
fixed outputs
wtripp180901 Jan 2, 2025
16fdb9c
fixed inputs not being passed
wtripp180901 Jan 2, 2025
762a241
separate input for workflow_call
wtripp180901 Jan 2, 2025
4a1cfc0
comment
wtripp180901 Jan 2, 2025
636cee3
added gh token
wtripp180901 Jan 2, 2025
3f76a7c
made more idempotent + terraform typo
wtripp180901 Jan 2, 2025
a709ee7
added body to PR
wtripp180901 Jan 2, 2025
7ba077a
fixed idempotency
wtripp180901 Jan 2, 2025
365e54f
fixed not failing if branch hasn't been created
wtripp180901 Jan 3, 2025
0e8a242
Merge branch 'main' into feat/auto-bump-timestamps
wtripp180901 Jan 3, 2025
011640b
typo
wtripp180901 Jan 3, 2025
71b2226
Automatically triggers CI and comments result
wtripp180901 Jan 3, 2025
efe42b6
fixed comment on wrong PR + CI secrets
wtripp180901 Jan 3, 2025
5e71afa
fixed PR idempotency
wtripp180901 Jan 3, 2025
57fc6c7
Merge branch 'main' into feat/auto-bump-timestamps
wtripp180901 Jan 3, 2025
921b565
CI now always runs on image bump
wtripp180901 Jan 6, 2025
726dba2
fixed fatimage and ci not running on target branch
wtripp180901 Jan 6, 2025
6782308
Release train support for ceph repos
wtripp180901 Jan 6, 2025
5f8346b
bump images
wtripp180901 Jan 7, 2025
08a2a99
Update requirements.yml
wtripp180901 Jan 7, 2025
7f074cf
merge
wtripp180901 Jan 7, 2025
0edc12b
bumped rocky 9 ceph repos to reef
wtripp180901 Jan 7, 2025
b03caaf
updated rl9 ceph version number
wtripp180901 Jan 7, 2025
3677f26
merge ark ceph
wtripp180901 Jan 7, 2025
0c3ea76
pinned github runners to ubuntu-22.04
wtripp180901 Jan 7, 2025
82719fc
fixed missing token in PR check
wtripp180901 Jan 7, 2025
3e6b2cf
fixed pr not being created
wtripp180901 Jan 7, 2025
b8581ba
missing token
wtripp180901 Jan 8, 2025
3bed0b8
templating fix
wtripp180901 Jan 8, 2025
eca4ea0
Merge branch 'main' into feat/auto-bump-timestamps
wtripp180901 Jan 8, 2025
b1d60de
rename
wtripp180901 Jan 8, 2025
433a9ca
comment update
wtripp180901 Jan 9, 2025
9ff34cb
removed redundant checks and made is_callee checking clearer
wtripp180901 Jan 13, 2025
12effec
Merge branch 'main' into feat/auto-bump-timestamps
wtripp180901 Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/update-timestamps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check for new Release Train snapshots
on:
workflow_dispatch:
schedule:
- cron: '0 7 * * *' # Run at 7am on default branch

jobs:
upstream_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup environment
run: |
. venv/bin/activate
. environments/.stackhpc/activate

- name: Check for updated Ark timestamps and replace in defaults.yml
run: ansible-playbook ansible/ci/update_timestamps.yml

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
add-paths: environments/common/inventory/group_vars/all/defaults.yml
commit-message: "[automated] bumped repo timestamps to latest"
branch: auto/bump-timestamps
title: "[Automation] Bumped repo timestamps to latest"
body: Automated changes by .github/workflows/update-timestamps.yml
88 changes: 88 additions & 0 deletions ansible/ci/library/latest_timestamps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/python

# Copyright: (c) 2018, Terry Jones <terry.jones@example.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = r'''
---
module: latest_timestamps

short_description: Gets the latest set of snapshots from Pulp and overwrites

version_added: "1.0.0"

description: Gets the latest set of snapshots from given source URLs and returns dictionary in to replace 'appliances_repo_timestamps' with

author:
- William Tripp
'''

EXAMPLES = r'''
# Pass in a message
- name: Get latest timestamps
latest_timestamps:
current_timestamps_dict: "{{ appliances_repo_timestamps }}"
sources_dict: "{{ appliances_repo_timestamp_sources }}"
register: result

'''

RETURN = r'''
# These are examples of possible return values, and in general should use other names for return values.
latest_dict:
description: Dictionary with updated timestamps
type: dict
returned: always
changed_timestamps:
description: List of repos that've been updated
type: str[]
returned: always
'''

from ansible.module_utils.basic import AnsibleModule
import requests
from bs4 import BeautifulSoup

def run_module():
module_args = dict(
current_timestamps_dict=dict(type='dict', required=True),
sources_dict=dict(type='dict', required=True)
)

result = dict(
changed=False,
original_message='',
message=''
)

module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True
)

latest_timestamps = {}
changed_timestamps = []
for repo in module.params['sources_dict']:
latest_timestamps[repo] = module.params['sources_dict'][repo]
for version in module.params['sources_dict'][repo]:
html_txt = requests.get(url=module.params['sources_dict'][repo][version]).text
timestamp_link_list = BeautifulSoup(html_txt,features="html.parser").body.find('pre').find_all()
timestamp_link_list = map(lambda x: x.string,timestamp_link_list) # xml tags
latest_timestamps[repo][version] = list(timestamp_link_list)[-1][:-1] # last timestamp in list with trailing / removed
if module.params['sources_dict'][repo][version] != module.params['current_timestamps_dict'][repo][version]:
changed_timestamps.append(repo+' '+version)

result['latest_dict'] = latest_timestamps
result['changed_timestamps'] = changed_timestamps

module.exit_json(**result)


def main():
run_module()


if __name__ == '__main__':
main()
28 changes: 28 additions & 0 deletions ansible/ci/update_timestamps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- hosts: localhost
tasks:
- name: Check sources are defined for all repos
ansible.builtin.assert:
that: appliances_repo_timestamps[item].keys() == appliances_repo_timestamp_sources[item].keys()
fail_msg: "'appliances_repo_timestamps.{{ item }}' is missing a source definition in 'appliances_repo_timestamp_sources'"
loop: "{{ appliances_repo_timestamps.keys() }}"

- name: Get latest timestamps from sources
latest_timestamps:
sources_dict: "{{ appliances_repo_timestamp_sources }}"
current_timestamps_dict: "{{ appliances_repo_timestamps }}"
register: _result

- name: Print updated timestamps
ansible.builtin.debug:
var: _result.changed_timestamps

- name: Overwrite repo timestamps with latest
ansible.builtin.blockinfile:
path: "{{ playbook_dir }}/../../environments/common/inventory/group_vars/all/defaults.yml"
marker: "# {mark} Marker for ansible/ci/update_timestamps.yml (GH workflow managed)"
block: |
{{ yaml_template | to_nice_yaml(indent=2) }}
vars:
yaml_template:
appliances_repo_timestamps: "{{ _result.latest_dict }}"
when: (_result.changed_timestamps | count) > 0
15 changes: 15 additions & 0 deletions environments/common/inventory/group_vars/all/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ appliances_local_users: "{{ appliances_local_users_default + appliances_local_us

###########################################################################################

# BEGIN Marker for ansible/ci/update_timestamps.yml (GH workflow managed)
appliances_repo_timestamps:
baseos:
'9.4': 20240816T002610
Expand All @@ -93,3 +94,17 @@ appliances_repo_timestamps:
'9.4': 20240816T002610
epel:
'9': 20240902T080424
# END Marker for ansible/ci/update_timestamps.yml (GH workflow managed)

# For CI
appliances_repo_timestamp_sources:
baseos:
'9.4': https://ark.stackhpc.com/pulp/content/rocky/9.4/BaseOS/x86_64/os/
appstream:
'9.4': https://ark.stackhpc.com/pulp/content/rocky/9.4/AppStream/x86_64/os/
crb:
'9.4': https://ark.stackhpc.com/pulp/content/rocky/9.4/CRB/x86_64/os/
extras:
'9.4': https://ark.stackhpc.com/pulp/content/rocky/9.4/extras/x86_64/os/
epel:
'9': https://ark.stackhpc.com/pulp/content/epel/9/Everything/x86_64/
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ selinux # this is a shim to avoid having to use --system-site-packages, you stil
netaddr
matplotlib
pulp-cli==0.29.2
beautifulsoup4==4.12.3