Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More sophisticated automation of image set generation #486

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 2 additions & 30 deletions imagesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,36 +125,8 @@ complete:
updating image references in `/config/imagesets.yml`. Make sure to push this
commit upstream (i.e. to `[email protected]:mozilla/community-tc-config.git`).

2) Apply the config changes by running `tc-admin`. Note, here is a script that
does this, if you have not already set something up:


```bash
#!/bin/bash -e
rm -rf tc-admin
mkdir tc-admin
pip3 install --upgrade pip
cd tc-admin
python3 -m venv tc-admin-venv
source tc-admin-venv/bin/activate
pip3 install pytest
pip3 install --upgrade pip
git clone https://github.com/mozilla/community-tc-config
cd community-tc-config
pip3 install -e .
which tc-admin
pass git pull
TASKCLUSTER_ROOT_URL=https://community-tc.services.mozilla.com tc-admin diff || true
echo
echo 'Applying in 60 seconds (Ctrl-C to abort)....'
echo
sleep 60
echo 'Applying!'
echo
TASKCLUSTER_ROOT_URL=https://community-tc.services.mozilla.com tc-admin apply
cd ../..
rm -rf tc-admin
```
2) Apply the config changes by running `run-tc-admin.sh` in the root folder of
this repository.

3) Don't forget to test your image set changes! Try rerunning some tasks that
previously ran successfully.
3 changes: 2 additions & 1 deletion imagesets/imageset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ function deploy {
git push "${OFFICIAL_GIT_REPO}" "+HEAD:refs/heads/main"
log 'Deployment of image sets successful!'
log ''
log 'Be sure to run tc-admin in the community-tc-config repo to apply changes to the community cluster!'
cd ../..
log 'Be sure to run tc-admin to apply changes to the community cluster!'" There is a utility script for doing this: $(pwd)/run-tc-admin.sh"
}

################## AWS ##################
Expand Down
78 changes: 78 additions & 0 deletions run-tc-admin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

function tc_admin {


################################################
# this is temporarily in here while i work out what is needed, then it will be moved into docker image itself...
apt update
apt install -y python3-pip python3.8-venv
pip install --upgrade pip
python3 -m venv tc-admin-venv
pip3 install pytest
pip3 install --upgrade pip
################################################


source tc-admin-venv/bin/activate
export TEMP_DIR="$(mktemp -d -t password-store.XXXXXXXXXX)"
export PASSWORD_STORE_DIR="${TEMP_DIR}/.password-store"
cd "${TEMP_DIR}"
git clone https://github.com/mozilla/community-tc-config
cd community-tc-config
pip3 install -e .
which tc-admin
git clone ssh://[email protected]/taskcluster/secrets.git "${PASSWORD_STORE_DIR}"
export TASKCLUSTER_ROOT_URL='https://community-tc.services.mozilla.com'
export TASKCLUSTER_CLIENT_ID='static/taskcluster/root'
export TASKCLUSTER_ACCESS_TOKEN="$(pass show community-tc/root | head -n 1)"
unset TASKCLUSTER_CERTIFICATE
tc-admin diff || true
tc-admin diff --ids-only || true
echo
done=false
while true; do
read -p "Apply changes (yes/no)? " choice
case "${choice}" in
yes)
echo
echo 'Applying!'
echo
tc-admin apply
break
;;
no)
echo "Ok, ok, 🐥."
break
;;
*)
echo "Invalid response: '${choice}'. Please answer 'yes' or 'no'."
;;
esac
done
cd
rm -rf "${TEMP_DIR}"
}

################## Entry point ##################

cd "$(dirname "${0}")"

if [ "${1-}" == "native" ]; then
tc_admin
else
TAG="$(cat docker/TAG)"
docker run \
--rm \
-ti \
-v "$(pwd):/community-tc-config" \
-v ~/.config:/root/.config \
-v ~/.gitconfig:/root/.gitconfig \
-v ~/.gnupg:/root/.gnupg \
-v ~/.ssh:/root/.ssh \
"${TAG}" \
/community-tc-config/run-tc-admin.sh native
fi