From 6c59093a67503b1fb8c39ebabbff56b0f2b1be39 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 11 Jun 2020 21:56:20 -0700 Subject: [PATCH] Prepare Travis CI for web3.js and explorer --- .travis.yml | 122 +++++++++++++++++++++++++--------- .travis/affects.sh | 18 +++++ .travis/export-github-repo.sh | 38 +++++++++++ 3 files changed, 145 insertions(+), 33 deletions(-) create mode 100755 .travis/affects.sh create mode 100755 .travis/export-github-repo.sh diff --git a/.travis.yml b/.travis.yml index 3b84c59cd..92dda6405 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,3 @@ -os: - - osx - - windows - -language: rust -rust: - - stable - -install: - - source ci/rust-version.sh - -script: - - source ci/env.sh - - ci/publish-tarball.sh - branches: only: - master @@ -23,21 +8,92 @@ notifications: on_success: change secure: F4IjOE05MyaMOdPRL+r8qhs7jBvv4yDM3RmFKE1zNXnfUOqV4X38oQM1EI+YVsgpMQLj/pxnEB7wcTE4Bf86N6moLssEULCpvAuMVoXj4QbWdomLX+01WbFa6fLVeNQIg45NHrz2XzVBhoKOrMNnl+QI5mbR2AlS5oqsudHsXDnyLzZtd4Y5SDMdYG1zVWM01+oNNjgNfjcCGmOE/K0CnOMl6GPi3X9C34tJ19P2XT7MTDsz1/IfEF7fro2Q8DHEYL9dchJMoisXSkem5z7IDQkGzXsWdWT4NnndUvmd1MlTCE9qgoXDqRf95Qh8sB1Dz08HtvgfaosP2XjtNTfDI9BBYS15Ibw9y7PchAJE1luteNjF35EOy6OgmCLw/YpnweqfuNViBZz+yOPWXVC0kxnPIXKZ1wyH9ibeH6E4hr7a8o9SV/6SiWIlbYF+IR9jPXyTCLP/cc3sYljPWxDnhWFwFdRVIi3PbVAhVu7uWtVUO17Oc9gtGPgs/GrhOMkJfwQPXaudRJDpVZowxTX4x9kefNotlMAMRgq+Drbmgt4eEBiCNp0ITWgh17BiE1U09WS3myuduhoct85+FoVeaUkp1sxzHVtGsNQH0hcz7WcpZyOM+AwistJA/qzeEDQao5zi1eKWPbO2xAhi2rV1bDH6bPf/4lDBwLRqSiwvlWU= -deploy: - - provider: s3 - access_key_id: $AWS_ACCESS_KEY_ID - secret_access_key: $AWS_SECRET_ACCESS_KEY - bucket: release.solana.com - region: us-west-1 - skip_cleanup: true - acl: public_read - local_dir: travis-s3-upload - on: - all_branches: true - - provider: releases - api_key: $GITHUB_TOKEN - skip_cleanup: true - file_glob: true - file: travis-release-upload/* - on: - tags: true +os: linux +dist: bionic +language: minimal + +jobs: + include: + - name: "Export Github Repositories" + if: type = push + language: python + git: + depth: false + script: + - .travis/export-github-repo.sh web3.js test-solana-web3.js + - .travis/export-github-repo.sh explorer test-explorer + + - &release-artifacts + if: type = push + name: "macOS release artifacts" + os: osx + rust: + - stable + install: + - source ci/rust-version.sh + script: + - source ci/env.sh + - ci/publish-tarball.sh + deploy: + - provider: s3 + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + bucket: release.solana.com + region: us-west-1 + skip_cleanup: true + acl: public_read + local_dir: travis-s3-upload + on: + all_branches: true + - provider: releases + token: $GITHUB_TOKEN + skip_cleanup: true + file_glob: true + file: travis-release-upload/* + on: + tags: true + - <<: *release-artifacts + name: "Linux release artifacts" + os: linux + before_install: + - sudo apt-get install libssl-dev libudev-dev + - <<: *release-artifacts + name: "Windows release artifacts" + os: windows + + # explorer pull request + - name: "explorer" + if: branch = master + if: type = pull + language: node_js + node_js: + - "node" + + before_install: + - .travis/affects.sh ^explorer/ || travis_terminate 0 + - cd explorer + + script: + - npm run build + - npm run format + + # web3.js pull request + - name: "web3.js" + if: branch = master + if: type = pull + language: node_js + node_js: + - "lts/*" + + services: + - docker + + cache: + directories: + - ~/.npm + + before_install: + - .travis/affects.sh ^web3.js/ || travis_terminate 0 + - cd explorer + + script: echo todo diff --git a/.travis/affects.sh b/.travis/affects.sh new file mode 100755 index 000000000..ca87b5bc4 --- /dev/null +++ b/.travis/affects.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Check if files in the commit range match a regex +# + +( + set -x + git diff --name-only $TRAVIS_COMMIT_RANGE +) + +for file in $(git diff --name-only $TRAVIS_COMMIT_RANGE); do + if [[ $file =~ ^"$1" ]]; then + exit 0 + fi +done + +echo "No modifications to $1" +exit 1 diff --git a/.travis/export-github-repo.sh b/.travis/export-github-repo.sh new file mode 100755 index 000000000..48a70ab0b --- /dev/null +++ b/.travis/export-github-repo.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Exports a subdirectory into another github repository +# + +set -e +if [[ -z $GITHUB_TOKEN ]]; then + echo GITHUB_TOKEN not defined + exit 1 +fi + +cd "$(dirname "$0")/.." + +pip3 install git-filter-repo + +declare subdir=$1 +declare repo_name=$2 + +[[ -n $subdir ]] || { + echo "Error: subdir not specified" + exit 1 +} +[[ -n $repo_name ]] || { + echo "Error: repo_name not specified" + exit 1 +} + +.travis/affects.sh "^$subdir/" || exit 0 +echo "Exporting $subdir" + +set -x +rm -rf .github_export/"$repo_name" +git clone https://${GITHUB_TOKEN}@github.com/solana-labs/"$repo_name" .github_export/"$repo_name" + +# TODO: Try using `--refs $TRAVIS_COMMIT_RANGE` to speed up the filtering +git filter-repo --subdirectory-filter "$subdir" --target .github_export/"$repo_name" + +git -C .github_export/"$repo_name" push https://${GITHUB_TOKEN}@github.com/solana-labs/"$repo_name"