Skip to content

Commit

Permalink
Implement the purge action
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero committed Apr 10, 2024
1 parent 881a94c commit 00447d5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,45 @@ jobs:
- name: Test plugins _TEST.py
run: |
python3 plugins/*_TEST.py
- name: Smoke system tests for repository module
system_tests_setup:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: System smoke test setup
run: |
python3 gzdev.py repository list
repo_to_test="osrf"
repo_type_to_test="stable"
sudo env "PYTHONPATH=$pythonLocation/lib/python${{ matrix.python-version}}/site-packages" \
python3 ./gzdev.py repository enable ${repo_to_test} ${repo_type_to_test}
repo_system_test_precleanup:
runs-on: ubuntu-latest
needs: [system_tests_setup]
steps:
- name: Smoke system tests for repository module
run:
sudo env "PYTHONPATH=$pythonLocation/lib/python${{ matrix.python-version}}/site-packages" \
python3 ./gzdev.py repository --pre-cleanup enable ${repo_to_test} ${repo_type_to_test} >log
grep "/etc/apt/sources.list.d/_gzdev_${repo_to_test}_${repo_type_to_test}.list" log
grep "/usr/share/keyrings/_gzdev_${repo_to_test}_${repo_type_to_test}.gpg" log

repo_system_test_purge:
runs-on: ubuntu-latest
needs: [system_tests_setup]
steps:
- name: Smoke system tests for repository module
run:
sudo env "PYTHONPATH=$pythonLocation/lib/python${{ matrix.python-version}}/site-packages" \
python3 ./gzdev.py repository purge >log
grep "/etc/apt/sources.list.d/_gzdev_${repo_to_test}_${repo_type_to_test}.list" log
grep "/usr/share/keyrings/_gzdev_${repo_to_test}_${repo_type_to_test}.gpg" log

docker_tests:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Smoke system tests for ign-docker module
run: |
python3 gzdev.py ign-docker-env citadel
Expand Down
9 changes: 7 additions & 2 deletions plugins/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
enable Enable repository in the system
disable Disable repository (if present)
list List repositories enabled
purge Remove all configurations installed by gzdev
Options:
-h --help Show this screen
--version Show gzdev's version
--gpg-check Do run a gpg check for validating the key
downloaded in enable action
(need the gpg binary)
--pre-cleanup Remove all repositories and keys installed
by gzdev from the system before proceding
--pre-cleanup Run 'purge' action before proceeding
"""

import distro
Expand Down Expand Up @@ -225,6 +225,9 @@ def normalize_args(args):
force_linux_distro = args['--force-linux-distro']
gpg_check = args['--gpg_check'] if '--gpg_check' in args else False
pre_cleanup = args['--pre-cleanup'] if '--pre-cleanup' in args else False
if pre_cleanup and action != 'enable':
error('--pre-cleanup is only supported in the "enable" action'
f'(not in {action})')
if force_linux_distro:
linux_distro = force_linux_distro
else:
Expand Down Expand Up @@ -277,6 +280,8 @@ def process_input(args, config):
gpg_check)
elif (action == 'disable'):
disable_repo(repo_name)
elif (action == 'purge'):
remove_all_installed()


def remove_file_by_pattern(directory, pattern):
Expand Down

0 comments on commit 00447d5

Please sign in to comment.