Skip to content

Commit

Permalink
Add scripts for automatically updating K Nighly, opening PR into repo (
Browse files Browse the repository at this point in the history
…#503)

* Makefile, include.mk: hardcode the nightly URL used

* scripts/update-k-nightly.sh: script for automatically updating the K nightly release version

* scripts/update-k-nightly-pr.sh: script to also open the PR for you

* scripts/update-k-nightly-pr: upstream branch, not remote

* scripts/update-k-nightly-pr: also specify reviewer to use
  • Loading branch information
ehildenb authored Mar 13, 2019
1 parent d6e46a1 commit ea92c22
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ kore-exec: $(KORE_EXEC)
k-frontend:
mkdir -p $(BUILD_DIR)
rm -rf $(K_DIST_DEFAULT) $(K_NIGHTLY)
curl --location --output $(K_NIGHTLY) \
$$(curl 'https://api.github.com/repos/kframework/k/releases' | jq --raw-output '.[${K_NIGHTLY_OFFSET}].assets[].browser_download_url | match(".*nightly.tar.gz").string')
curl --location --output $(K_NIGHTLY) $(K_NIGHTLY_URL)
mkdir -p $(K_DIST_DEFAULT)
tar --extract --file $(K_NIGHTLY) --strip-components 1 --directory $(K_DIST_DEFAULT)
$(KRUN) --version
Expand Down
2 changes: 1 addition & 1 deletion include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ UPSTREAM_BRANCH = origin/master

BUILD_DIR = $(TOP)/.build
K_NIGHTLY = $(BUILD_DIR)/nightly.tar.gz
K_NIGHTLY_OFFSET ?= 0
K_NIGHTLY_URL = https://github.com/kframework/k/releases/download/nightly-4375ba02b/nightly.tar.gz
K_DIST_DEFAULT = $(BUILD_DIR)/k
K_DIST ?= $(K_DIST_DEFAULT)
K_DIST_BIN = $(K_DIST)/bin
Expand Down
34 changes: 34 additions & 0 deletions scripts/update-k-nightly-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -exuo pipefail

export TOP=${TOP:-$(git rev-parse --show-toplevel)}
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-origin}
UPSTREAM_BRANCH=master
BRANCH_NAME=update-k-nightly

$TOP/scripts/git-assert-clean.sh

if [[ $(git rev-parse HEAD) != $(git rev-parse $UPSTREAM_BRANCH) ]]; then
echo "Must run with $UPSTREAM_BRANCH checked out!!!"
exit 1
fi

$TOP/scripts/update-k-nightly.sh

if $TOP/scripts/git-assert-clean.sh; then
echo "No update..."
exit 0
fi

git checkout -B "$BRANCH_NAME" "$UPSTREAM_REMOTE/$UPSTREAM_BRANCH"

git add $TOP/include.mk

git commit --message 'include.mk: update K nightly version'

hub pull-request --push --force --head "$BRANCH_NAME" --base "$UPSTREAM_BRANCH" --reviewer ehildenb --file - <<MSG
Update K Nightly version used for integration testing
PR generated by '$0'
MSG
9 changes: 9 additions & 0 deletions scripts/update-k-nightly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -exuo pipefail

export TOP=${TOP:-$(git rev-parse --show-toplevel)}

new_nightly="$(curl 'https://api.github.com/repos/kframework/k/releases' | jq --raw-output '.[0].assets[].browser_download_url | match(".*nightly.tar.gz").string')"

sed -i '/K_NIGHTLY_URL.*/c\'"K_NIGHTLY_URL = $new_nightly" "$TOP/include.mk"

0 comments on commit ea92c22

Please sign in to comment.