Skip to content

Commit

Permalink
Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jun 12, 2020
1 parent 4f76139 commit 87edf6a
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 33 deletions.
121 changes: 88 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,21 +8,91 @@ 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
if: type = api
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 checks
- name: "explorer"
if: branch = master
if: type = pull
language: node_js
node_js:
- "node"

before_install:
- .travis/affects.sh ^explorer/ || travis_terminate 0

script:
- npm run build
- npm run format

# web3.js pull request checks
- 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

script: echo todo
18 changes: 18 additions & 0 deletions .travis/affects.sh
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions .travis/export-github-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
#
# Exports subdirectories into their own github repositories
#
# Careful!
#

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
}


if ! .travis/affects.sh "^$subdir/"; then
echo "No changes to $subdir"
exit 0
fi

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 a `--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"

0 comments on commit 87edf6a

Please sign in to comment.