From 9cb4bf15fbd9030bfc5d2c24675b573582af3a23 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 14 Sep 2018 14:12:58 +0200 Subject: [PATCH] Automatic deployment scripts - Script for automatically creating a release. - Tag and push new release - Generated documentation and push to `gh-pages` branch - Script for generating the release notes from the PR info --- ci-scripts/deploy.sh | 68 +++++++++++++++++++++++++++++++++++++++ ci-scripts/genrelnotes.py | 55 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100755 ci-scripts/deploy.sh create mode 100755 ci-scripts/genrelnotes.py diff --git a/ci-scripts/deploy.sh b/ci-scripts/deploy.sh new file mode 100755 index 0000000000..113055a51f --- /dev/null +++ b/ci-scripts/deploy.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +oldpwd=$(pwd) + +usage() +{ + echo "Usage: $0 VERSION" +} + +_onerror() +{ + exitcode=$? + echo "$0: ReFrame deployment failed!" + echo "$0: command \`$BASH_COMMAND' failed (exit code: $exitcode)" + cd $oldpwd + exit $exitcode +} + +trap _onerror ERR + +version=$1 +if [ -z $version ]; then + echo "$0: missing version number" >&2 + usage + exit 1 +fi + +py_minor_version=$(python3 -c 'import sys; print(sys.version_info.minor)') +if [ $py_minor_version -ne 5 ]; then + echo "$0: deployment script requires Python 3.5" >&2 + exit 1 +fi + + +tmpdir=$(mktemp -d) +echo "Deploying ReFrame version $version ..." +echo "Working directory: $tmpdir ..." +cd $tmpdir +git clone https://github.com/eth-cscs/reframe.git +cd reframe +found_version=$(./reframe.py -V) +if [ $found_version -ne $version ]; then + echo "$0: version mismatch: found $found_version, but required $version" >&2 + exit 1 +fi + +python3 -m venv venv.docs +source venv.docs/bin/activate +pip install --upgrade pip +pip install -r requirements.txt +pip install -r docs/requirements.txt +./test_reframe.py +git tag -a v$version -m "ReFrame $version" +git push origin --tags +make -C docs +cd .. +git clone -b gh-pages https://github.com/eth-cscs/reframe.git reframe-doc +cd reframe-doc +rsync -avz ../reframe/docs/html/ . +echo "Please visit http://localhost:8000/ and " \ + "check that the documentation is fine." +echo "Press Ctrl-C to continue when ready." +python3 -m http.server +git commit -a -m "ReFrame $version documentation" +git push origin gh-pages +deactivate +cd $oldpwd +echo "Deployment was successful!" diff --git a/ci-scripts/genrelnotes.py b/ci-scripts/genrelnotes.py new file mode 100755 index 0000000000..0ac18340ae --- /dev/null +++ b/ci-scripts/genrelnotes.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +import collections +import re +import sys +import subprocess + + +def usage(): + sys.stderr.write('Usage: %s PREV_RELEASE CURR_RELEASE\n' % sys.argv[0]) + + +def extract_release_notes(git_output, tag): + return re.findall(r'pull request (#\d+).*\s*\[%s\] (.*)' % tag, git_output) + + +if __name__ == '__main__': + if len(sys.argv) < 3: + sys.stderr.write('%s: too few arguments\n' % sys.argv[0]) + usage() + sys.exit(1) + + prev_release, curr_release, *_ = sys.argv[1:] + try: + git_cmd = 'git log --merges v%s..v%s' % (prev_release, curr_release) + completed = subprocess.run(git_cmd.split(), + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True, + check=True) + except subprocess.CalledProcessError as e: + sys.stderr.write('%s: git command failed: %s\n' % + (sys.argv[0], ' '.join(e.cmd))) + sys.stderr.write(e.stdout) + sys.exit(1) + + titles = { + 'feat': '## New features and enhancements', + 'bugfix': '## Bug fixes', + 'test': '## Regression tests' + } + sections = collections.OrderedDict() + for tag in ['feat', 'bugfix', 'test', 'ci', 'doc']: + title_line = titles.get(tag, '## Other') + sections.setdefault(title_line, []) + for pr, descr in extract_release_notes(completed.stdout, tag): + descr_line = '- %s (%s)' % (descr, pr) + sections[title_line].append(descr_line) + + print('# ReFrame %s Release Notes' % curr_release) + for sec_title, sec_lines in sections.items(): + print() + print(sec_title) + print() + print('\n'.join(sec_lines))