Skip to content

Commit 38bccbf

Browse files
authored
Simplify github action with scripts (solana-labs#769)
* Simplify github action with scripts * fix deps * fix path * feedback * feedback * shift some things * clean up * Update pull-request.yml
1 parent e0e46e0 commit 38bccbf

10 files changed

+272
-254
lines changed

.github/workflows/pull-request.yml

Lines changed: 51 additions & 242 deletions
Large diffs are not rendered by default.

.travis.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ branches:
88
notifications:
99
email: false
1010

11-
cache:
12-
directories:
13-
- "~/.cache"
14-
15-
services:
16-
- docker
17-
18-
env:
19-
global:
20-
- RUST_BACKTRACE=1
21-
- SOLANA_VERSION=v1.4.3
22-
2311
jobs:
2412
include:
2513
# docs pull request or commit to master

ci/cargo-build-test.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
cd "$(dirname "$0")"
5+
cd ..
6+
7+
source ./ci/rust-version.sh stable
8+
source ./ci/solana-version.sh install
9+
10+
export RUSTFLAGS="-D warnings"
11+
export RUSTBACKTRACE=1
12+
13+
set -x
14+
15+
# For all BPF programs
16+
for Xargo_toml in $(git ls-files -- '*/Xargo.toml'); do
17+
program_dir=$(dirname "$Xargo_toml")
18+
19+
if [ "$program_dir" == "token-swap/program" ]; then
20+
address="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8"
21+
SWAP_PROGRAM_OWNER_FEE_ADDRESS="$address" cargo build-bpf --manifest-path=token-swap/program/Cargo.toml --dump --features production
22+
mv spl_token_swap.so spl_token_swap_production.so
23+
fi
24+
25+
cargo +"$rust_stable" build-bpf --manifest-path="$program_dir"/Cargo.toml --dump
26+
done
27+
28+
29+
cargo +"$rust_stable" build
30+
cargo +"$rust_stable" test -- --nocapture
31+
cargo +"$rust_stable" run --manifest-path=utils/test-client/Cargo.toml
32+
cargo +"$rust_stable" test --manifest-path=themis/client_ristretto/Cargo.toml -- --nocapture
33+
34+
# # Check generated C headers
35+
# cargo run --manifest-path=utils/cgen/Cargo.toml
36+
#
37+
# git diff --exit-code token/program/inc/token.h
38+
# cc token/program/inc/token.h -o target/token.gch
39+
# git diff --exit-code token-swap/program/inc/token-swap.h
40+
# cc token-swap/program/inc/token-swap.h -o target/token-swap.gch
41+
42+
exit 0

ci/install-build-deps.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
6+
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
7+
sudo apt-get update
8+
sudo apt-get install -y clang-7 --allow-unauthenticated
9+
sudo apt-get install -y openssl --allow-unauthenticated
10+
sudo apt-get install -y libssl-dev --allow-unauthenticated
11+
sudo apt-get install -y libssl1.1 --allow-unauthenticated
12+
sudo apt-get install -y libudev-dev
13+
clang-7 --version

ci/install-program-deps.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source ci/rust-version.sh stable
6+
source ci/solana-version.sh install
7+
8+
set -x
9+
10+
cargo --version
11+
cargo install rustfilt || true
12+
13+
export PATH="$HOME"/.local/share/solana/install/active_release/bin:"$PATH"
14+
solana --version
15+
cargo +"$rust_stable" build-bpf --version

ci/js-test-token-lending.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
cd "$(dirname "$0")"
5+
6+
(cd ../token/js && npm install)
7+
8+
cd ../token-lending/js
9+
npm install
10+
npm run lint
11+
npm run build
12+
npm run cluster:localnet
13+
npm run localnet:update
14+
npm run localnet:up
15+
npm run start
16+
npm run localnet:down

ci/js-test-token-swap.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
cd "$(dirname "$0")"
5+
6+
(cd ../token/js && npm install)
7+
8+
cd ../token-swap/js
9+
npm install
10+
npm run lint
11+
npm run flow
12+
npx tsc module.d.ts
13+
npm run cluster:localnet
14+
npm run localnet:update
15+
npm run localnet:up
16+
npm run start
17+
(cd ../../target/bpfel-unknown-unknown/release && mv spl_token_swap_production.so spl_token_swap.so)
18+
SWAP_PROGRAM_OWNER_FEE_ADDRESS="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8" npm run start
19+
npm run localnet:down

ci/js-test-token.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
cd "$(dirname "$0")"
5+
cd ../token/js
6+
7+
npm install
8+
npm run lint
9+
npm run flow
10+
npx tsc module.d.ts
11+
npm run cluster:localnet
12+
npm run localnet:update
13+
npm run localnet:up
14+
npm run start
15+
PROGRAM_VERSION=2.0.4 npm run start
16+
npm run localnet:down

ci/rust-version.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# This file maintains the rust versions for use by CI.
3+
#
4+
# Obtain the environment variables without any automatic toolchain updating:
5+
# $ source ci/rust-version.sh
6+
#
7+
# Obtain the environment variables updating both stable and nightly, only stable, or
8+
# only nightly:
9+
# $ source ci/rust-version.sh all
10+
# $ source ci/rust-version.sh stable
11+
# $ source ci/rust-version.sh nightly
12+
13+
# Then to build with either stable or nightly:
14+
# $ cargo +"$rust_stable" build
15+
# $ cargo +"$rust_nightly" build
16+
#
17+
18+
if [[ -n $RUST_STABLE_VERSION ]]; then
19+
stable_version="$RUST_STABLE_VERSION"
20+
else
21+
stable_version=1.47.0
22+
fi
23+
24+
# if [[ -n $RUST_NIGHTLY_VERSION ]]; then
25+
# nightly_version="$RUST_NIGHTLY_VERSION"
26+
# else
27+
# nightly_version=2020-08-17
28+
# fi
29+
30+
31+
export rust_stable="$stable_version"
32+
export rust_stable_docker_image=solanalabs/rust:"$stable_version"
33+
34+
# export rust_nightly=nightly-"$nightly_version"
35+
# export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
36+
37+
[[ -z $1 ]] || (
38+
39+
rustup_install() {
40+
declare toolchain=$1
41+
if ! cargo +"$toolchain" -V > /dev/null; then
42+
echo "$0: Missing toolchain? Installing...: $toolchain" >&2
43+
rustup install "$toolchain"
44+
cargo +"$toolchain" -V
45+
fi
46+
}
47+
48+
set -e
49+
cd "$(dirname "${BASH_SOURCE[0]}")"
50+
case $1 in
51+
stable)
52+
rustup_install "$rust_stable"
53+
;;
54+
# nightly)
55+
# rustup_install "$rust_nightly"
56+
# ;;
57+
all)
58+
rustup_install "$rust_stable"
59+
rustup_install "$rust_nightly"
60+
;;
61+
*)
62+
echo "$0: Note: ignoring unknown argument: $1" >&2
63+
;;
64+
esac
65+
)

ci/solana-version.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# This file maintains the solana versions for use by CI.
3+
#
4+
# Obtain the environment variables without any automatic updating:
5+
# $ source ci/solana-version.sh
6+
#
7+
# Obtain the environment variables and install update:
8+
# $ source ci/solana-version.sh install
9+
10+
# Then to access the solana version:
11+
# $ echo "$solana_version"
12+
#
13+
14+
if [[ -n $SOLANA_VERSION ]]; then
15+
solana_version="$SOLANA_VERSION"
16+
else
17+
solana_version=v1.4.4
18+
fi
19+
20+
export solana_version="$solana_version"
21+
export solana_docker_image=solanalabs/solana:"$solana_version"
22+
23+
[[ -z $1 ]] || (
24+
25+
set -e
26+
cd "$(dirname "${BASH_SOURCE[0]}")"
27+
case $1 in
28+
install)
29+
sh -c "$(curl -sSfL https://release.solana.com/$solana_version/install)"
30+
;;
31+
*)
32+
echo "$0: Note: ignoring unknown argument: $1" >&2
33+
;;
34+
esac
35+
)

0 commit comments

Comments
 (0)