<commit_before>#!/bin/bash
# shellcheck disable=SC2016
set -euo pipefail

cutoff_date=$(date --date='-2 days' +%Y-%m-%d)

echo "--- Deleting stack $AWS_STACK_NAME"
aws cloudformation delete-stack --stack-name "$AWS_STACK_NAME"

echo "--- Deleting test managed secrets buckets created"
aws s3api list-buckets \
  --output text \
  --query "$(printf '[?CreationDate<`%s`].Name' "$cutoff_date" )" \
  | xargs -n1 \
  | grep -E 'buildkite-aws-stack-test(-\d+)?-managed' \
  | xargs -n1 echo rm || true

echo "--- Deleting old cloudformation stacks"
aws cloudformation describe-stacks \
  --output text \
  --query "$(printf 'Stacks[?CreationTime<`%s`].StackName' "$cutoff_date" )" \
  | xargs -n1 \
  | grep -E 'buildkite-aws-stack-test-\d+' \
  | xargs -n1 echo rm || true
<commit_msg>Delete stuff during cleanup<commit_after>#!/bin/bash
# shellcheck disable=SC2016
set -uo pipefail

cutoff_date=$(date --date='-2 days' +%Y-%m-%d)

if [[ -n "${AWS_STACK_NAME:-}" ]] ; then
  echo "--- Deleting stack $AWS_STACK_NAME"
  aws cloudformation delete-stack --stack-name "$AWS_STACK_NAME"
fi

echo "--- Deleting test managed secrets buckets created"
aws s3api list-buckets \
  --output text \
  --query "$(printf 'Buckets[?CreationDate<`%s`].Name' "$cutoff_date" )" \
  | xargs -n1 \
  | grep -E 'buildkite-aws-stack-test-managedsecrets' \
  | xargs -n1 -I% aws s3 rb s3://% --force  

echo "--- Deleting old cloudformation stacks"
aws cloudformation describe-stacks \
  --output text \
  --query "$(printf 'Stacks[?CreationTime<`%s`].StackName' "$cutoff_date" )" \
  | xargs -n1 \
  | grep -E 'buildkite-aws-stack-test-\d+' \
  | xargs -n1 -I% aws cloudformation delete-stack --stack-name "%"

{'fraction_non_alphanumeric': 0.17933491686460806, 'fraction_numerical': 0.013064133016627079, 'mean_word_length': 3.365284974093264, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3714333', 'n_tokens_mistral': 659, 'n_tokens_neox': 631, 'n_words': 151}