Skip to content

Commit

Permalink
feat: migrate 'update-metric-reference' job from Screwdriver to Githu…
Browse files Browse the repository at this point in the history
…b Actions
  • Loading branch information
esolitos authored and gitbutler-client committed Aug 12, 2024
1 parent 1fe9464 commit 2d15a08
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 40 deletions.
73 changes: 68 additions & 5 deletions .github/workflows/auto-update-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
sudo apt-get install -y xq
- name: Get Latest Vespa version
env:
ENABLE_PUSH: ${{ contains(fromJSON('["workflow_dispatch", "schedule"]'), github.event_name) && github.ref_name == 'master' }}
run: |
VESPA_VERSION=$(curl -sSL https://repo1.maven.org/maven2/com/yahoo/vespa/parent/maven-metadata.xml | \
xq -x '/metadata/versioning/latest')
Expand All @@ -54,9 +56,15 @@ jobs:
echo "Updating Vespa version in documentation to ${VESPA_VERSION}" >> $GITHUB_STEP_SUMMARY
git config --global user.email "[email protected]"
git config --global user.name "${{ github.actor}}"
git commit -m "Update Vespa-version to ${VESPA_VERSION} - MERGEOK" _config.yml
git add _config.yml
git commit -m "Update Vespa-version to ${VESPA_VERSION}. MERGEOK"
git pull --rebase
git push
# Only push if the event is a push and the branch is the default branch.
if [[ "${{ env.ENABLE_PUSH }}" == "true" ]]; then
git push
fi
fi
update-vespa-cli-doc:
Expand All @@ -67,6 +75,7 @@ jobs:

env:
VESPA_CLI_DOC_DIR: en/reference/vespa-cli
ENABLE_PUSH: ${{ contains(fromJSON('["workflow_dispatch", "schedule"]'), github.event_name) && github.ref_name == 'master' }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -95,13 +104,67 @@ jobs:
git diff
# Check if there are changes to commit.
if [[ -n "$(git status --porcelain)" ]]; then
if [[ -n "$(git status --short)" ]]; then
echo "Updating Vespa CLI reference documentation" >> $GITHUB_STEP_SUMMARY
git config --global user.email "[email protected]"
git config --global user.name "${{ github.actor}}"
git add vespa*.md
git commit -m "Update Vespa-CLI reference doc MERGEOK"
git commit -m "Update 'Vespa-CLI' reference documentation. MERGEOK"
git pull --rebase
if [[ "${{ env.ENABLE_PUSH }}" == "true" ]]; then
git push
fi
fi
update-metric-reference:
#
# This job updates the Vespa metric reference documentation.
# Ref https://github.com/vespa-engine/vespa/blob/master/metrics/src/main/java/ai/vespa/metrics/docs/MetricDocumentation.java
#
runs-on: ubuntu-24.04 # Use Ubuntu 24.04 for the xq dependency

env:
ENABLE_PUSH: ${{ contains(fromJSON('["workflow_dispatch", "schedule"]'), github.event_name) && github.ref_name == 'master' }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"

- name: Setup xq
run: |
sudo apt-get install -y xq
- name: Get Latest Vespa version
id: vespa-metadata
run: |
VESPA_VERSION=$(curl -sSL https://repo1.maven.org/maven2/com/yahoo/vespa/parent/maven-metadata.xml | \
xq -x '/metadata/versioning/latest')
echo "Using version: $VESPA_VERSION"
echo "version=$VESPA_VERSION" >> $GITHUB_OUTPUT
- name: Update to latest
env:
VESPA_VERSION: ${{ steps.vespa-metadata.outputs.version }}
run: |
curl -SsLo metrics.jar "https://repo1.maven.org/maven2/com/yahoo/vespa/metrics/${VESPA_VERSION}/metrics-${VESPA_VERSION}.jar"
java -cp metrics.jar ai.vespa.metrics.docs.DocumentationGenerator en/reference
if [[ -n "$(git status --short en/reference/*-metrics-reference.html)" ]]; then
echo "Updating metric reference" >> $GITHUB_STEP_SUMMARY
git config --global user.email "[email protected]"
git config --global user.name "${{ github.actor}}"
git add en/reference/*-metrics-reference.html
git commit -m "Update 'Metric' reference documentation. MERGEOK"
git pull --rebase
git push
if [[ "${{ env.ENABLE_PUSH }}" == "true" ]]; then
git push
fi
fi
70 changes: 35 additions & 35 deletions screwdriver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,38 +142,38 @@ jobs:
# EOF
# /usr/bin/ssh-agent /bin/bash pushtogit.sh

generate-metric-reference:
image: buildpack-deps
annotations:
screwdriver.cd/buildPeriodically: H H(0-5) * * 1 # some time between 12:00 AM UTC (midnight) to 5:59 AM UTC Mon
secrets:
- VESPA_DOC_DEPLOY_KEY
environment:
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
steps:
- update-to-latest: |
# Ref https://github.com/vespa-engine/vespa/blob/master/metrics/src/main/java/ai/vespa/metrics/docs/MetricDocumentation.java
apt-get update && apt-get -y install openjdk-17-jdk
# must checkout the repo again using ssh for the credentials to work
cat << EOF > pushtogit.sh
#!/bin/bash
set -e
ssh-add -D
set +x
ssh-add <(echo \$VESPA_DOC_DEPLOY_KEY | base64 -d)
set -x
git clone [email protected]:vespa-engine/documentation.git documentation && cd documentation
VESPA_VERSION=\$(curl -sSL https://repo1.maven.org/maven2/com/yahoo/vespa/metrics/maven-metadata.xml | \
grep -oP '<latest>\K([0-9]+\.[0-9]+\.[0-9]+)')
curl -SsLo metrics.jar "https://repo1.maven.org/maven2/com/yahoo/vespa/metrics/\${VESPA_VERSION}/metrics-\${VESPA_VERSION}.jar"
java -cp metrics.jar ai.vespa.metrics.docs.DocumentationGenerator en/reference
git diff en/reference/*-metrics-reference.html
changes=\$(git status --porcelain en/reference/*-metrics-reference.html | wc -l)
if (( changes > 0 )); then
echo "Updating metric reference"
git commit -m "Update metric reference" en/reference/*-metrics-reference.html
git pull --rebase
git push
fi
EOF
/usr/bin/ssh-agent /bin/bash pushtogit.sh
# generate-metric-reference:
# image: buildpack-deps
# annotations:
# screwdriver.cd/buildPeriodically: H H(0-5) * * 1 # some time between 12:00 AM UTC (midnight) to 5:59 AM UTC Mon
# secrets:
# - VESPA_DOC_DEPLOY_KEY
# environment:
# GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
# steps:
# - update-to-latest: |
# # Ref https://github.com/vespa-engine/vespa/blob/master/metrics/src/main/java/ai/vespa/metrics/docs/MetricDocumentation.java
# apt-get update && apt-get -y install openjdk-17-jdk
# # must checkout the repo again using ssh for the credentials to work
# cat << EOF > pushtogit.sh
# #!/bin/bash
# set -e
# ssh-add -D
# set +x
# ssh-add <(echo \$VESPA_DOC_DEPLOY_KEY | base64 -d)
# set -x
# git clone [email protected]:vespa-engine/documentation.git documentation && cd documentation
# VESPA_VERSION=\$(curl -sSL https://repo1.maven.org/maven2/com/yahoo/vespa/metrics/maven-metadata.xml | \
# grep -oP '<latest>\K([0-9]+\.[0-9]+\.[0-9]+)')
# curl -SsLo metrics.jar "https://repo1.maven.org/maven2/com/yahoo/vespa/metrics/\${VESPA_VERSION}/metrics-\${VESPA_VERSION}.jar"
# java -cp metrics.jar ai.vespa.metrics.docs.DocumentationGenerator en/reference
# git diff en/reference/*-metrics-reference.html
# changes=\$(git status --porcelain en/reference/*-metrics-reference.html | wc -l)
# if (( changes > 0 )); then
# echo "Updating metric reference"
# git commit -m "Update metric reference" en/reference/*-metrics-reference.html
# git pull --rebase
# git push
# fi
# EOF
# /usr/bin/ssh-agent /bin/bash pushtogit.sh

0 comments on commit 2d15a08

Please sign in to comment.