Skip to content

Commit

Permalink
allow repo to be tagged automatically on commit to main branch (airbn…
Browse files Browse the repository at this point in the history
…b) (open-telemetry#2)

* git tagging in CI

* use version from versions.yaml

* only run if airbnb branch

* only run if airbnb branch

* clean up

* tag only component

* dry as a bone
  • Loading branch information
Abdurrahman Allawala authored and edma2 committed Aug 14, 2024
1 parent 1be78ec commit af02473
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
10 changes: 9 additions & 1 deletion _infra/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ ENV PATH="/usr/local/go/bin:$GOPATH/bin:$PATH"
ENV GO=go

# Delete forward-udp to enable statsd_receiver testing
RUN rm -f /usr/local/bin/forward-udp
RUN rm -f /usr/local/bin/forward-udp

# Install yq from artifactory
RUN curl -s0 https://artifactory.d.musta.ch/artifactory/generic-airbnb/yq/4.23.1/yq_linux_amd64 > /usr/local/bin/yq \
&& chmod a+x /usr/local/bin/yq

# Install ssh-client to push to git \
RUN apt-get update --yes \
&& apt-get install --yes ssh-client
9 changes: 8 additions & 1 deletion _infra/ci/dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
# the tag #continuous-integration.

jobs:
- name: receiver/statsdreceiver CI Check
- name: CI Check for receiver/statsdreceiver
path: _infra/ci/jobs/component_ci.yml
options:
env:
COMPONENT_PATH: "receiver/statsdreceiver"

- name: Tag repo for receiver/statsdreceiver
path: _infra/ci/jobs/tag_repo.yml
options:
only_run_if: "env('JORB_GIT_BRANCH') == 'airbnb'"
env:
COMPONENT_PATH: "receiver/statsdreceiver"
93 changes: 93 additions & 0 deletions _infra/ci/jobs/tag_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
# Generated by: onetouch-gen v1.26.3 (titanic: e28693593a57d500d94cdd97ceddff82c776522a)

# This is a simple CI job. A CI job comprises a list of steps that run
# sequentially in a container described by an image or a Dockerfile.
#
# Questions? Visit air.bb/ci-docs or ask a question on Stack Overflow with
# the tag #continuous-integration.

dockerfile: ../Dockerfile

steps:
- type: run
label: set up ssh
env:
GHE_DEPLOY_KEY: "{% secret key=GHE_DEPLOY_KEY %}"
command: |
set -ex
# Make .ssh directory
mkdir ~/.ssh
# Put the deploy key on disk
SSH_KEY=/tmp/ghe-deploy-key
openssl enc -d -aes-256-cbc -in _infra/ci/secrets/id_rsa_otel.enc -out ${SSH_KEY} -pass pass:${GHE_DEPLOY_KEY}
chmod 600 $SSH_KEY
# Set up the SSH configs
SSH_CONFIG=~/.ssh/config
cat <<EOF > $SSH_CONFIG
Host git.musta.ch
IdentityFile $SSH_KEY
StrictHostKeyChecking no
ServerAliveInterval 10
ServerAliveCountMax 10
TCPKeepAlive yes
EOF
chmod 600 $SSH_CONFIG
# Final check, and print the public key and config
git --version
ssh-keygen -y -f $SSH_KEY
cat $SSH_CONFIG
- type: run
label: set up git repo
command: |
set -ex
git_with_retries() {
MAX_ITERATIONS=${MAX_ITERATIONS:-6}
SUCCEEDED=0
echo "Attempting to execute: git $* with $MAX_ITERATIONS retries"
for i in $(seq "$MAX_ITERATIONS"); do
# Try running the command.
if git "$@"; then
echo 'The command succeeded.'
SUCCEEDED=1
break
fi
# If we aren't in the last iteration, sleep and try again.
if [ "$i" -lt "$MAX_ITERATIONS" ]; then
SLEEP_DURATION="$((3 ** i))"
echo "The command failed. Waiting $SLEEP_DURATION seconds..."
sleep "$SLEEP_DURATION"
fi
done
# Fail if the none of the attempts succeeded.
if [ "$SUCCEEDED" -eq 0 ]; then
echo 'The command never succeeded.'
false
fi
}
echo "Update to master for release branch creation..."
git_with_retries clone "$JORB_DISPATCHER_GIT_DIR" /jorb/repo-copy-rw
cd /jorb/repo-copy-rw
git config --global user.email "buildkite@airbnb.com"
git config --global user.name "buildkite"
git rev-parse HEAD
git remote remove origin
git remote add origin git@git.musta.ch:third-party/opentelemetry-collector-contrib.git
- type: run
label: Tag repo
command: |
cd /jorb/repo-copy-rw
TAG=${COMPONENT_PATH}/$(yq '.module-sets.contrib-base.version' versions.yaml)-${JORB_GIT_BRANCH}-$(git rev-parse --short HEAD)
git tag $TAG
git push origin $TAG
14 changes: 14 additions & 0 deletions _infra/ci/secrets/ci.a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"GHE_DEPLOY_KEY": {
"value": "ju6S06bULPkZElVlhEFtcDH/uQPcYV9WDcDj6g==",
"iv": "5lCpHHPZH5E0vSan",
"__keys__": {
"__shared__ci_secrets.production": {
"key": "NFroNnVruir2XerdDt2Xk5x8f8Zll0NpXIf4CWYk1B3lx2oed9n5Ddfo4YOWVluEKk/ru1Wpwo34alQEpe+ckxZVgGuFWdbENGYy1fdtfREIuM4KUfC+dlkCOlBayiVT4YoYWhfqpAwueZRNYMGtG1Dm+JZ9kk+wuQZGQt8+qXtcJXZMn06kZNked2oaR/ZzcWwZUKqgBDeV44BVkdsMnV+jlbSamiJ6RsyAdl+xHvZ0IKFA05WZGEAueoMgqeRwnfzlRzcoQo55aLJT9SKFnPPBgRE/4EEiRl3Hc0HdSWLLn54AWq0mGVyXjMR4vZJ0adlzOw2iCrNjs34gMYA8YQ==",
"sig": "90bff42516bebc2d2d3df04ff0a085b48676a2ccd1438394a0b9eef84b5d5d1c"
}
},
"auth_tag": "1ajbH9mfszNRCVQx87khVQ==",
"annotations": "eyJ1cGRhdGVkX2F0IjoxNjU5NDAzNzAzLCJ1c2FnZV9jb250ZXh0Ijp7ImdpdF9yZXBvX3NsdWciOiJ0aGlyZC1wYXJ0eS9vcGVudGVsZW1ldHJ5LWNvbGxlY3Rvci1jb250cmliIn19"
}
}
Binary file added _infra/ci/secrets/id_rsa_otel.enc
Binary file not shown.

0 comments on commit af02473

Please sign in to comment.