Skip to content

Commit

Permalink
automatic update: test-requirements.txt tox.ini hooks/gh-clean Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
bodsch committed Aug 19, 2024
1 parent 78322a6 commit 3a20c99
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
export TOX_SCENARIO ?= default
export TOX_ANSIBLE ?= ansible_6.1
export TOX_ANSIBLE ?= ansible_8.5

.PHONY: converge destroy verify test lint
.PHONY: converge destroy verify test lint gh-clean

default: converge

Expand All @@ -20,3 +20,6 @@ test:

lint:
@hooks/lint

gh-clean:
@hooks/gh-clean
72 changes: 72 additions & 0 deletions hooks/gh-clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

set -e

org=bodsch
repo=$(basename $(git rev-parse --show-toplevel))

keep_first_two() {
local arr=("$@") # Das Array wird als Argument übergeben
local new_arr=("${arr[@]:0:2}") # Die ersten beiden Elemente werden beibehalten
echo "${new_arr[@]}" # Das neue Array wird ausgegeben
}

remove_elements() {
local arr=("$@")
local result=()
local length=${#arr[@]}

# Check whether the array has more than two elements
if [ $length -le 2 ]
then
return
fi

# Keep the first two elements
for ((i=2; i<length; i++))
do
result+=("${arr[i]}") # Collect removed elements
done

echo "${result[@]}"
}


if [ -n "${org}" ] && [ -n "${repo}" ]
then

# Get workflow IDs with status "active"
workflow_ids=($(gh api repos/$org/$repo/actions/workflows --paginate | jq '.workflows[] | select(.["state"] | contains("active")) | .id'))

for workflow_id in "${workflow_ids[@]}"
do
echo "Listing runs for the workflow ID $workflow_id"
run_ids=( $(gh api repos/$org/$repo/actions/workflows/$workflow_id/runs --paginate | jq '.workflow_runs[].id') )

# echo "${run_ids[@]}"

# count array
count_ids=${#run_ids[@]}
# echo " - ${count_ids} entries"

if [ ${count_ids} -gt 2 ]
then
# remove the first two elements of the list
array=$(remove_elements "${run_ids[@]}")

for run_id in ${array}
do
echo "Deleting Run ID $run_id"
gh api repos/$org/$repo/actions/runs/$run_id -X DELETE >/dev/null
done

echo "-------------------------------------------------"
fi
done
else
echo "missing values:"
echo " - org : '${org}'"
echo " - repo: '${repo}'"

exit 1
fi
3 changes: 1 addition & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ ansible-lint
docker
dnspython
flake8
molecule>=5.0.1
molecule
molecule-plugins[docker]
netaddr
pytest
pytest-testinfra
tox
tox-gh-actions
Expand Down
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tox]
ignore_basepython_conflict = True
skip_missing_interpreters = True

minversion = 3.25
toxworkdir = /tmp/.tox/

envlist = ansible_{2.9,2.10,3.4,4.10,5.1,5.2,6.1}

skipsdist = true

[testenv]
Expand All @@ -26,6 +27,9 @@ deps =
ansible_7.5: ansible>=7.5,<7.6
ansible_8.0: ansible>=8.0,<8.1
ansible_8.5: ansible>=8.5,<8.6
ansible_9.0: ansible>=9.0,<9.1
ansible_9.5: ansible>=9.5,<9.6
ansible_10.0: ansible>=10.0,<10.1

#commands_pre =
# /usr/bin/find {toxinidir} -type f -not -path '{toxworkdir}/*' -path '*/__pycache__/*' -name '*.py[c|o]' -delete
Expand Down

0 comments on commit 3a20c99

Please sign in to comment.