Skip to content

Commit

Permalink
Simplify github action with scripts (solana-labs#769)
Browse files Browse the repository at this point in the history
* Simplify github action with scripts

* fix deps

* fix path

* feedback

* feedback

* shift some things

* clean up

* Update pull-request.yml
  • Loading branch information
jstarry authored Nov 4, 2020
1 parent e0e46e0 commit 38bccbf
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 254 deletions.
293 changes: 51 additions & 242 deletions .github/workflows/pull-request.yml

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ branches:
notifications:
email: false

cache:
directories:
- "~/.cache"

services:
- docker

env:
global:
- RUST_BACKTRACE=1
- SOLANA_VERSION=v1.4.3

jobs:
include:
# docs pull request or commit to master
Expand Down
42 changes: 42 additions & 0 deletions ci/cargo-build-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -e
cd "$(dirname "$0")"
cd ..

source ./ci/rust-version.sh stable
source ./ci/solana-version.sh install

export RUSTFLAGS="-D warnings"
export RUSTBACKTRACE=1

set -x

# For all BPF programs
for Xargo_toml in $(git ls-files -- '*/Xargo.toml'); do
program_dir=$(dirname "$Xargo_toml")

if [ "$program_dir" == "token-swap/program" ]; then
address="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8"
SWAP_PROGRAM_OWNER_FEE_ADDRESS="$address" cargo build-bpf --manifest-path=token-swap/program/Cargo.toml --dump --features production
mv spl_token_swap.so spl_token_swap_production.so
fi

cargo +"$rust_stable" build-bpf --manifest-path="$program_dir"/Cargo.toml --dump
done


cargo +"$rust_stable" build
cargo +"$rust_stable" test -- --nocapture
cargo +"$rust_stable" run --manifest-path=utils/test-client/Cargo.toml
cargo +"$rust_stable" test --manifest-path=themis/client_ristretto/Cargo.toml -- --nocapture

# # Check generated C headers
# cargo run --manifest-path=utils/cgen/Cargo.toml
#
# git diff --exit-code token/program/inc/token.h
# cc token/program/inc/token.h -o target/token.gch
# git diff --exit-code token-swap/program/inc/token-swap.h
# cc token-swap/program/inc/token-swap.h -o target/token-swap.gch

exit 0
13 changes: 13 additions & 0 deletions ci/install-build-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -ex

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
sudo apt-get update
sudo apt-get install -y clang-7 --allow-unauthenticated
sudo apt-get install -y openssl --allow-unauthenticated
sudo apt-get install -y libssl-dev --allow-unauthenticated
sudo apt-get install -y libssl1.1 --allow-unauthenticated
sudo apt-get install -y libudev-dev
clang-7 --version
15 changes: 15 additions & 0 deletions ci/install-program-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

source ci/rust-version.sh stable
source ci/solana-version.sh install

set -x

cargo --version
cargo install rustfilt || true

export PATH="$HOME"/.local/share/solana/install/active_release/bin:"$PATH"
solana --version
cargo +"$rust_stable" build-bpf --version
16 changes: 16 additions & 0 deletions ci/js-test-token-lending.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -ex
cd "$(dirname "$0")"

(cd ../token/js && npm install)

cd ../token-lending/js
npm install
npm run lint
npm run build
npm run cluster:localnet
npm run localnet:update
npm run localnet:up
npm run start
npm run localnet:down
19 changes: 19 additions & 0 deletions ci/js-test-token-swap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -ex
cd "$(dirname "$0")"

(cd ../token/js && npm install)

cd ../token-swap/js
npm install
npm run lint
npm run flow
npx tsc module.d.ts
npm run cluster:localnet
npm run localnet:update
npm run localnet:up
npm run start
(cd ../../target/bpfel-unknown-unknown/release && mv spl_token_swap_production.so spl_token_swap.so)
SWAP_PROGRAM_OWNER_FEE_ADDRESS="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8" npm run start
npm run localnet:down
16 changes: 16 additions & 0 deletions ci/js-test-token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -ex
cd "$(dirname "$0")"
cd ../token/js

npm install
npm run lint
npm run flow
npx tsc module.d.ts
npm run cluster:localnet
npm run localnet:update
npm run localnet:up
npm run start
PROGRAM_VERSION=2.0.4 npm run start
npm run localnet:down
65 changes: 65 additions & 0 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# This file maintains the rust versions for use by CI.
#
# Obtain the environment variables without any automatic toolchain updating:
# $ source ci/rust-version.sh
#
# Obtain the environment variables updating both stable and nightly, only stable, or
# only nightly:
# $ source ci/rust-version.sh all
# $ source ci/rust-version.sh stable
# $ source ci/rust-version.sh nightly

# Then to build with either stable or nightly:
# $ cargo +"$rust_stable" build
# $ cargo +"$rust_nightly" build
#

if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.47.0
fi

# if [[ -n $RUST_NIGHTLY_VERSION ]]; then
# nightly_version="$RUST_NIGHTLY_VERSION"
# else
# nightly_version=2020-08-17
# fi


export rust_stable="$stable_version"
export rust_stable_docker_image=solanalabs/rust:"$stable_version"

# export rust_nightly=nightly-"$nightly_version"
# export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"

[[ -z $1 ]] || (

rustup_install() {
declare toolchain=$1
if ! cargo +"$toolchain" -V > /dev/null; then
echo "$0: Missing toolchain? Installing...: $toolchain" >&2
rustup install "$toolchain"
cargo +"$toolchain" -V
fi
}

set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
case $1 in
stable)
rustup_install "$rust_stable"
;;
# nightly)
# rustup_install "$rust_nightly"
# ;;
all)
rustup_install "$rust_stable"
rustup_install "$rust_nightly"
;;
*)
echo "$0: Note: ignoring unknown argument: $1" >&2
;;
esac
)
35 changes: 35 additions & 0 deletions ci/solana-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# This file maintains the solana versions for use by CI.
#
# Obtain the environment variables without any automatic updating:
# $ source ci/solana-version.sh
#
# Obtain the environment variables and install update:
# $ source ci/solana-version.sh install

# Then to access the solana version:
# $ echo "$solana_version"
#

if [[ -n $SOLANA_VERSION ]]; then
solana_version="$SOLANA_VERSION"
else
solana_version=v1.4.4
fi

export solana_version="$solana_version"
export solana_docker_image=solanalabs/solana:"$solana_version"

[[ -z $1 ]] || (

set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
case $1 in
install)
sh -c "$(curl -sSfL https://release.solana.com/$solana_version/install)"
;;
*)
echo "$0: Note: ignoring unknown argument: $1" >&2
;;
esac
)

0 comments on commit 38bccbf

Please sign in to comment.