From fa92a41dfe0783a50c85702c0c12a0ebe8f9c4e2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 2 Dec 2019 15:25:45 -0800 Subject: [PATCH] travis: Deploy to github pages and releases. * Deploy markdown files (including generated lint rules) to GitHub pages (IE the gh-pages branch). * Deploy the precompiled binaries to GitHub releases. Signed-off-by: Tim 'mithro' Ansell --- .github/travis/github-pages-setup.sh | 164 ++++++++++++++++++++++++ .github/travis/github-releases-setup.sh | 60 +++++++++ .github/travis/install-bazel.sh | 19 +++ .github/travis/output-logs.sh | 13 ++ .github/travis/set-compiler.sh | 21 +++ .travis.yml | 96 ++++++++++++-- 6 files changed, 363 insertions(+), 10 deletions(-) create mode 100755 .github/travis/github-pages-setup.sh create mode 100755 .github/travis/github-releases-setup.sh create mode 100755 .github/travis/install-bazel.sh mode change 100644 => 100755 .github/travis/output-logs.sh create mode 100755 .github/travis/set-compiler.sh diff --git a/.github/travis/github-pages-setup.sh b/.github/travis/github-pages-setup.sh new file mode 100755 index 000000000..6b94ecbfe --- /dev/null +++ b/.github/travis/github-pages-setup.sh @@ -0,0 +1,164 @@ +#!/bin/bash +# Copyright 2020 The Verible Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# GitHub Pages +# --------------- +# Generate the GitHub pages to deploy + +GIT_DATE=$(git show -s --format=%ci) +GIT_VERSION=$(git describe --match=v*) +GIT_HASH=$(git rev-parse HEAD) + +PAGES_DIR=/tmp/pages +rm -rf $PAGES_DIR +mkdir -p $PAGES_DIR + +# Copy across the current markdown files +# -------------------------------- +cp -a *.md $PAGES_DIR/ +cp -a AUTHORS $PAGES_DIR/AUTHORS.md + +# Generate an index page +# -------------------------------- +INDEX_DOC=$PAGES_DIR/index.md + +# Copy the top of the README.md +sed -e '/## /,$d' README.md > $INDEX_DOC +# Add links to other documents +cat >> $INDEX_DOC < $PAGES_DIR/lint.md +cat >> $PAGES_DIR/lint.md < $SYNTAX_DOC <> $SYNTAX_DOC +cat >> $SYNTAX_DOC < $LINT_DOC <> $LINT_DOC +cat >> $LINT_DOC <<'EOF' +``` + +## Lint Rules + +EOF +bazel-bin/verilog/tools/lint/verilog_lint -generate_markdown >> $LINT_DOC +cat >> $LINT_DOC < $FORMAT_DOC <> $FORMAT_DOC +cat >> $FORMAT_DOC < $MD.new <> $MD.new + mv $MD.new $MD +done diff --git a/.github/travis/github-releases-setup.sh b/.github/travis/github-releases-setup.sh new file mode 100755 index 000000000..9b4db2216 --- /dev/null +++ b/.github/travis/github-releases-setup.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Copyright 2020 The Verible Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# GitHub Releases +# --------------- +# Generate the GitHub Releases to deploy + +RELEASE_DIR=/tmp/releases +rm -rf $RELEASE_DIR + +PREFIX=$RELEASE_DIR/verible-$TRAVIS_TAG +PREFIX_BIN=$PREFIX/bin +PREFIX_DOC=$PREFIX/share/verible +PREFIX_MAN=$PREFIX/share/man/man1 +mkdir -p $PREFIX +mkdir -p $PREFIX_BIN +mkdir -p $PREFIX_DOC +mkdir -p $PREFIX_MAN + +# Binaries +cp -a bazel-bin/verilog/tools/syntax/verilog_syntax $PREFIX_BIN +cp -a bazel-bin/verilog/tools/lint/verilog_lint $PREFIX_BIN +cp -a bazel-bin/verilog/tools/formatter/verilog_format $PREFIX_BIN + +for BIN in $PREFIX_BIN/*; do + ls -l $BIN + file $BIN + ldd $BIN +done + +# Documentation +cp -a /tmp/pages/* $PREFIX_DOC +# Man pages +gflags2man --help_flag="--helpfull" --dest_dir $PREFIX_MAN bazel-bin/verilog/tools/syntax/verilog_syntax +gzip $PREFIX_MAN/verilog_lint.1 +gflags2man --help_flag="--helpfull" --dest_dir $PREFIX_MAN bazel-bin/verilog/tools/lint/verilog_lint +gzip $PREFIX_MAN/verilog_lint.1 +gflags2man --help_flag="--helpfull" --dest_dir $PREFIX_MAN bazel-bin/verilog/tools/formatter/verilog_format +gzip $PREFIX_MAN/verilog_format.1 + +DISTRO=$(lsb_release --short --id) +DISTRO_RELEASE=$(lsb_release --short --release) +DISTRO_CODENAME=$(lsb_release --short --codename) +TARBALL=$RELEASE_DIR/verible-$TRAVIS_TAG-$TRAVIS_OS_NAME-$TRAVIS_CPU_ARCH-$DISTRO-$DISTRO_RELEASE-$DISTRO_CODENAME.tar.gz +( + cd $RELEASE_DIR + tar -zcvf $TARBALL verible-$TRAVIS_TAG +) diff --git a/.github/travis/install-bazel.sh b/.github/travis/install-bazel.sh new file mode 100755 index 000000000..0164734e0 --- /dev/null +++ b/.github/travis/install-bazel.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Copyright 2020 The Verible Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +wget https://github.com/bazelbuild/bazel/releases/download/1.2.0/bazel_1.2.0-linux-x86_64.deb -O /tmp/bazel.deb +sudo dpkg -i /tmp/bazel.deb || true +sudo apt-get -f install +bazel --version diff --git a/.github/travis/output-logs.sh b/.github/travis/output-logs.sh old mode 100644 new mode 100755 index 31031a599..1daee772f --- a/.github/travis/output-logs.sh +++ b/.github/travis/output-logs.sh @@ -1,4 +1,17 @@ #!/bin/bash +# Copyright 2020 The Verible Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. find -L -name \*.log for F in $(find -L -name \*.log); do diff --git a/.github/travis/set-compiler.sh b/.github/travis/set-compiler.sh new file mode 100755 index 000000000..f051a874f --- /dev/null +++ b/.github/travis/set-compiler.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright 2020 The Verible Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +VERSION=$1 + +sudo dpkg --list | grep gcc +sudo ln -sf /usr/bin/gcc-$VERSION /usr/bin/gcc +sudo ln -sf /usr/bin/g++-$VERSION /usr/bin/g++ +gcc --version || true diff --git a/.travis.yml b/.travis.yml index 6c847d927..2df98c634 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,57 @@ -dist: bionic - language: cpp -compiler: - - gcc +# Don't build auto-generated tags +if: NOT tag =~ /v[0-9.]*-.*/ + +git: + depth: false -addons: - apt: - packages: - - g++-8 +jobs: + include: + - stage: "Test" + name: "Ubuntu Trusty" + os: linux + dist: trusty + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-9 + - gcc-9 + - pandoc + - python-gflags + - stage: "Test" + name: "Ubuntu Xenial" + os: linux + dist: xenial + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-9 + - gcc-9 + - pandoc + - python-gflags +# - stage: "Test" +# name: "Ubuntu Bionic" +# os: linux +# dist: bionic +# addons: +# apt: +# sources: +# - ubuntu-toolchain-r-test +# packages: +# - g++-9 +# - gcc-9 +# - pandoc +# - python-gflags before_install: - - wget https://github.com/bazelbuild/bazel/releases/download/1.1.0/bazel_1.1.0-linux-x86_64.deb - - sudo dpkg -i bazel_1.1.0-linux-x86_64.deb + - ./.github/travis/set-compiler.sh 9 + - ./.github/travis/install-bazel.sh 9 + - git fetch --tags script: - bazel build --noshow_progress --cxxopt='-std=c++17' //... @@ -20,3 +59,40 @@ script: after_failure: - source .github/travis/output-logs.sh + +after_success: + - git config --local user.name "Deployment Bot" + - git config --local user.email "verible-dev@googlegroups.com" + # Create a tag of form v0.0-183-gdf2b162-20191112132344 + - export TRAVIS_TAG=${TRAVIS_TAG:-$(git describe --match=v*)} + - git tag $TRAVIS_TAG || true + # Set up things for GitHub Pages deployment + - ./.github/travis/github-pages-setup.sh + # Set up things for GitHub Releases deployment + - ./.github/travis/github-releases-setup.sh + +before_deploy: + - find /tmp/pages | sort + - find /tmp/releases | sort + +# For deploy to work, you must https://travis-ci.org/$USER/verible/settings and +# add the following environment values; +# OCTOKIT_ACCESS_TOKEN - Personal access token from https://github.com/settings/tokens +# OCTOKIT_LOGIN - Your Github username +# OCTOKIT_PASSWORD - Same as OCTOKIT_ACCESS_TOKEN above +deploy: + - provider: pages + skip_cleanup: true + keep_history: true + github_token: $OCTOKIT_ACCESS_TOKEN + local_dir: /tmp/pages + on: + branch: master + - provider: releases + file_glob: true + username: $OCTOKIT_LOGIN + password: $OCTOKIT_PASSWORD + file: + - /tmp/releases/verible-*.tar.gz + overwrite: true + skip_cleanup: true