diff --git a/.gitlab-ci/molecule.yml b/.gitlab-ci/molecule.yml index 995aad806..701bba4c1 100644 --- a/.gitlab-ci/molecule.yml +++ b/.gitlab-ci/molecule.yml @@ -16,7 +16,10 @@ script: - ./tests/scripts/molecule_run.sh after_script: - - ./tests/scripts/molecule_logs.sh + - rm -fr molecule_logs + - mkdir -p molecule_logs + - find ~/.cache/molecule/ \( -name '*.out' -o -name '*.err' \) -type f | xargs tar -uf molecule_logs/molecule.tar + - gzip molecule_logs/molecule.tar artifacts: when: always paths: diff --git a/scripts/gen_tags.sh b/scripts/gen_tags.sh deleted file mode 100755 index 1bc94c80b..000000000 --- a/scripts/gen_tags.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -eo pipefail - -#Generate MD formatted tags from roles and cluster yaml files -printf "|%25s |%9s\n" "Tag name" "Used for" -echo "|--------------------------|---------" -tags=$(grep -r tags: . | perl -ne '/tags:\s\[?(([\w\-_]+,?\s?)+)/ && printf "%s ", "$1"'|\ - perl -ne 'print join "\n", split /\s|,/' | sort -u) -for tag in $tags; do - match=$(cat docs/ansible.md | perl -ne "/^\|\s+${tag}\s\|\s+((\S+\s?)+)/ && printf \$1") - printf "|%25s |%s\n" "${tag}" " ${match}" -done diff --git a/scripts/gitlab-branch-cleanup/.gitignore b/scripts/gitlab-branch-cleanup/.gitignore deleted file mode 100644 index 03e7ca8de..000000000 --- a/scripts/gitlab-branch-cleanup/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -openrc -venv diff --git a/scripts/gitlab-branch-cleanup/README.md b/scripts/gitlab-branch-cleanup/README.md deleted file mode 100644 index 6a2b5ffbe..000000000 --- a/scripts/gitlab-branch-cleanup/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# gitlab-branch-cleanup - -Cleanup old branches in a GitLab project - -## Installation - -```shell -pip install -r requirements.txt -python main.py --help -``` - -## Usage - -```console -$ export GITLAB_API_TOKEN=foobar -$ python main.py kargo-ci/kubernetes-sigs-kubespray -Deleting branch pr-5220-containerd-systemd from 2020-02-17 ... -Deleting branch pr-5561-feature/cinder_csi_fixes from 2020-02-17 ... -Deleting branch pr-5607-add-flatcar from 2020-02-17 ... -Deleting branch pr-5616-fix-typo from 2020-02-17 ... -Deleting branch pr-5634-helm_310 from 2020-02-18 ... -Deleting branch pr-5644-patch-1 from 2020-02-15 ... -Deleting branch pr-5647-master from 2020-02-17 ... -``` diff --git a/scripts/gitlab-branch-cleanup/main.py b/scripts/gitlab-branch-cleanup/main.py deleted file mode 100644 index 2d7fe1c2f..000000000 --- a/scripts/gitlab-branch-cleanup/main.py +++ /dev/null @@ -1,38 +0,0 @@ -import gitlab -import argparse -import os -import sys -from datetime import timedelta, datetime, timezone - - -parser = argparse.ArgumentParser( - description='Cleanup old branches in a GitLab project') -parser.add_argument('--api', default='https://gitlab.com/', - help='URL of GitLab API, defaults to gitlab.com') -parser.add_argument('--age', type=int, default=30, - help='Delete branches older than this many days') -parser.add_argument('--prefix', default='pr-', - help='Cleanup only branches with names matching this prefix') -parser.add_argument('--dry-run', action='store_true', - help='Do not delete anything') -parser.add_argument('project', - help='Path of the GitLab project') - -args = parser.parse_args() -limit = datetime.now(timezone.utc) - timedelta(days=args.age) - -if os.getenv('GITLAB_API_TOKEN', '') == '': - print("Environment variable GITLAB_API_TOKEN is required.") - sys.exit(2) - -gl = gitlab.Gitlab(args.api, private_token=os.getenv('GITLAB_API_TOKEN')) -gl.auth() - -p = gl.projects.get(args.project) -for b in p.branches.list(all=True): - date = datetime.fromisoformat(b.commit['created_at']) - if date < limit and not b.protected and not b.default and b.name.startswith(args.prefix): - print("Deleting branch %s from %s ..." % - (b.name, date.date().isoformat())) - if not args.dry_run: - b.delete() diff --git a/scripts/gitlab-branch-cleanup/requirements.txt b/scripts/gitlab-branch-cleanup/requirements.txt deleted file mode 100644 index 4a169edeb..000000000 --- a/scripts/gitlab-branch-cleanup/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -python-gitlab diff --git a/scripts/premoderator.sh b/scripts/premoderator.sh deleted file mode 100644 index ab1a7ef53..000000000 --- a/scripts/premoderator.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# A naive premoderation script to allow Gitlab CI pipeline on a specific PRs' comment -# Exits with 0, if the pipeline is good to go -# Exits with 1, if the user is not allowed to start pipeline -# Exits with 2, if script is unable to get issue id from CI_COMMIT_REF_NAME variable -# Exits with 3, if missing the magic comment in the pipeline to start the pipeline - -CURL_ARGS="-fs --retry 4 --retry-delay 5" -MAGIC="${MAGIC:-ci check this}" -exit_code=0 - -# Get PR number from CI_COMMIT_REF_NAME -issue=$(echo ${CI_COMMIT_REF_NAME} | perl -ne '/^pr-(\d+)-\S+$/ && print $1') - -if [ "$issue" = "" ]; then - echo "Unable to get issue id from: $CI_COMMIT_REF_NAME" - exit 2 -fi - -echo "Fetching labels from PR $issue" -labels=$(curl ${CURL_ARGS} "https://api.github.com/repos/kubernetes-sigs/kubespray/issues/${issue}?access_token=${GITHUB_TOKEN}" | jq '{labels: .labels}' | jq '.labels[].name' | jq -s '') -labels_to_patch=$(echo -n $labels | jq '. + ["needs-ci-auth"]' | tr -d "\n") - -echo "Checking for '$MAGIC' comment in PR $issue" - -# Get the user name from the PR comments with the wanted magic incantation casted -user=$(curl ${CURL_ARGS} "https://api.github.com/repos/kubernetes-sigs/kubespray/issues/${issue}/comments" | jq -M "map(select(.body | contains (\"$MAGIC\"))) | .[0] .user.login" | tr -d '"') - -# Check for the required user group membership to allow (exit 0) or decline (exit >0) the pipeline -if [ "$user" = "" ] || [ "$user" = "null" ]; then - echo "Missing '$MAGIC' comment from one of the OWNERS" - exit_code=3 -else - echo "Found comment from user: $user" - - curl ${CURL_ARGS} "https://api.github.com/orgs/kubernetes-sigs/members/${user}" - - if [ $? -ne 0 ]; then - echo "User does not have permissions to start CI run" - exit_code=1 - else - labels_to_patch=$(echo -n $labels | jq '. - ["needs-ci-auth"]' | tr -d "\n") - exit_code=0 - echo "$user has allowed CI to start" - fi -fi - -# Patch labels on PR -curl ${CURL_ARGS} --request PATCH "https://api.github.com/repos/kubernetes-sigs/kubespray/issues/${issue}?access_token=${GITHUB_TOKEN}" -H "Content-Type: application/json" -d "{\"labels\": ${labels_to_patch}}" - -exit $exit_code diff --git a/tests/scripts/molecule_logs.sh b/tests/scripts/molecule_logs.sh deleted file mode 100755 index 4908d81d5..000000000 --- a/tests/scripts/molecule_logs.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# Ensure a clean environent -rm -fr molecule_logs -mkdir -p molecule_logs - -# Collect and archive the logs -find ~/.cache/molecule/ -name \*.out -o -name \*.err -type f | xargs tar -uf molecule_logs/molecule.tar -gzip molecule_logs/molecule.tar