Skip to content

Commit

Permalink
Merge pull request #845 from AlmaLinux/new_gh_ci
Browse files Browse the repository at this point in the history
- GH CI is improved and fixed
  • Loading branch information
soksanichenko authored Jul 31, 2023
2 parents 63f12e3 + 2d34744 commit 5242d75
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ jobs:

- name: Check YAML configs
run: |
mirror_regexp="mirrors.d/.*.(yml|yaml)$"
if ! echo "${{ steps.files.outputs.added_modified }}" | grep -E "${mirror_regexp}" &> /dev/null; then
mirror_regexp="mirrors.d/.*.(yml)$"
modified_files="${{ steps.files.outputs.added_modified }} ${{steps.files.outputs.renamed}}"
if ! echo "${modified_files}" | grep -E "${mirror_regexp}" &> /dev/null; then
# we check only the main config if PR doesn't contain any new or modified mirror config
python3.9 gh_ci/config_checker.py -sc config.yml
else
changed_files=""
for changed_file in ${{ steps.files.outputs.added_modified }}; do
for changed_file in ${modified_files}; do
if echo "${changed_file}" | grep -E "${mirror_regexp}" &> /dev/null; then
changed_files="${changed_file} ${changed_files}"
elif echo "${changed_file}" | grep "mirrors.d" &> /dev/null; then
echo "You add a config with wrong extension. Should be *.yml"
exit 1
fi
done
python3.9 gh_ci/config_checker.py -sc config.yml -mc ${changed_files}
Expand Down
19 changes: 14 additions & 5 deletions gh_ci/config_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ async def are_mirrors_available(
headers={"Connection": "close"}
) as http_session:
for mirror in mirrors:
mirror_name, is_available = await mirror_available(
is_available = await mirror_available(
mirror_info=mirror,
http_session=http_session,
logger=logger,
main_config=main_config,
)
if not is_available:
ret_code = 1
# True is 1, False is 0, so
# we get 1 if a mirror is not available
ret_code += int(not is_available)
return ret_code


Expand All @@ -107,12 +108,12 @@ def do_mirrors_have_valid_geo_data(
ui_url = 'https://nominatim.openstreetmap.org/ui/details.html'
for mirror in mirrors:
if any(getattr(mirror.geolocation, geo_attr) is None for geo_attr in (
'city', 'state', 'country'
'city', 'state_province', 'country'
)):
continue
params = {
'city': mirror.geolocation.city,
'state': mirror.geolocation.state,
'state': mirror.geolocation.state_province,
'country': mirror.geolocation.country,
'format': 'json',
}
Expand Down Expand Up @@ -169,6 +170,13 @@ def main(args):
err,
)
exit(1)
main_config, err_msg = process_main_config(yaml_data=service_config_data)
if err_msg:
logger.error(
'Main config of the mirror service is invalid because "%s"',
err_msg,
)
exit(1)
exit_code = 0
for mirror_config in args.mirror_configs:
mirror_config_data = mirror_config['config_data']
Expand Down Expand Up @@ -200,6 +208,7 @@ def main(args):
process_mirror_config(
yaml_data=mirror_config['config_data'],
logger=logger,
main_config=main_config,
)
for mirror_config in args.mirror_configs
]
Expand Down
11 changes: 6 additions & 5 deletions gh_ci/req.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pyyaml==6.0
jsonschema==4.2.1
aiohttp==3.8.1
requests==2.26.0
pyyaml==6.0.1
jsonschema==4.18.4
aiohttp==3.8.5
aiohttp-retry==2.8.3
requests==2.31.0
dataclasses==0.6
syncer==1.3.0
syncer==2.0.3
2 changes: 1 addition & 1 deletion gh_ci/yaml_snippets
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: mirror.amberit.com.bd
address:
http: http://mirror.dhakacom.com/almalinux/
https:
rsync:
geolocation:
country: BD
state_province: Dhaka
Expand Down
13 changes: 0 additions & 13 deletions mirrors.d/mirror.hoster.kz.yaml

This file was deleted.

File renamed without changes.

0 comments on commit 5242d75

Please sign in to comment.