Switch to Github Actions for CI (#768)

This commit is contained in:
Justin Starry 2020-11-01 18:42:51 +08:00 committed by GitHub
parent beaa05ece5
commit 138ca68a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 376 additions and 175 deletions

363
.github/workflows/pull-request.yml vendored Normal file
View File

@ -0,0 +1,363 @@
name: Pull Request
on:
pull_request:
push:
branches: [master]
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Run fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: clippy
- name: Install dependencies
run: |
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
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-clippy-
- name: Run clippy
if: always()
uses: actions-rs/cargo@v1
with:
command: clippy
args: -Zunstable-options --workspace --all-targets -- --deny=warnings
list_bpf_programs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.list-bpf-programs.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- id: list-bpf-programs
run: |
JSON="{\"include\":["
for Xargo_toml in $(git ls-files -- '*/Xargo.toml'); do
program_dir=$(dirname "$Xargo_toml")
JSONline="{\"path\": \"$program_dir\"},"
if [[ "$JSON" != *"$JSONline"* ]]; then
JSON="$JSON$JSONline"
fi
done
# Remove last "," and add closing brackets
if [[ $JSON == *, ]]; then
JSON="${JSON%?}"
fi
JSON="$JSON]}"
echo $JSON
# Set output
echo "::set-output name=matrix::$( echo "$JSON" )"
build_bpf_programs:
name: Build Program ${{ matrix.path }}
needs: list_bpf_programs
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.list_bpf_programs.outputs.matrix)}}
env:
SOLANA_VERSION: v1.4.3
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0 # MSRV
override: true
profile: minimal
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-bpf-${{ matrix.path }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-bpf-${{ matrix.path }}-
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/rustfilt
key: cargo-bpf-bins-${{ runner.os }}
restore-keys: |
cargo-bpf-bins-${{ runner.os }}-
- uses: actions/cache@v2
with:
path: |
~/.cache
key: solana-${{ env.SOLANA_VERSION }}-nonce-1
restore-keys: |
solana-nonce-1
- name: Install dependencies
run: |
cargo install rustfilt || true
sh -c "$(curl -sSfL https://release.solana.com/$SOLANA_VERSION/install)"
echo "PATH=/home/runner/.local/share/solana/install/active_release/bin:$PATH" >> $GITHUB_ENV
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
cargo build-bpf --version
- name: Production check
run: |
if [ "${{ matrix.path }}" == "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
- name: Build
uses: actions-rs/cargo@v1
with:
command: build-bpf
args: --manifest-path=${{ matrix.path }}/Cargo.toml --dump
- name: Upload program for later jobs
uses: actions/upload-artifact@v2
with:
name: programs
path: "*.so"
if-no-files-found: error
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0 # MSRV
override: true
profile: minimal
- name: Install dependencies
run: |
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
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-test-
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
excluded_project_tests:
needs: build_bpf_programs
name: Test ${{ matrix.path }}
runs-on: ubuntu-latest
strategy:
matrix:
path:
- shared-memory/client
- token/perf-monitor
- themis/client_ristretto
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- name: Install dependencies
run: |
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
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
${{ matrix.path }}/target
key: cargo-excluded-${{ matrix.path }}-${{ hashFiles('**/Cargo.lock') }}-nonce-1
restore-keys: |
cargo-excluded-${{ matrix.path }}-
- uses: actions/download-artifact@v2
with:
name: programs
path: target/bpfel-unknown-unknown/release
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=${{ matrix.path }}/Cargo.toml -- --nocapture
js_token:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
defaults:
run:
working-directory: token/js
needs: build_bpf_programs
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-token-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-token-
- uses: actions/download-artifact@v2
with:
name: programs
path: target/bpfel-unknown-unknown/release
- run: npm install
- run: npm run lint
- run: npm run flow
- run: tsc module.d.ts
- run: |
npm run cluster:localnet
npm run localnet:update
npm run localnet:up
- run: npm run start
- run: PROGRAM_VERSION=2.0.4 npm run start
- run: npm run localnet:down
js_token_swap:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
defaults:
run:
working-directory: token-swap/js
needs: build_bpf_programs
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-token-swap-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-token-swap
- uses: actions/download-artifact@v2
with:
name: programs
path: target/bpfel-unknown-unknown/release
- run: (cd ../../token/js && npm install)
- run: npm install
- run: npm run lint
- run: npm run flow
- run: tsc module.d.ts
- run: |
npm run cluster:localnet
npm run localnet:update
npm run localnet:up
- run: npm run start
- name: run production test
run: |
(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
- run: npm run localnet:down
js_token_lending:
runs-on: ubuntu-latest
env:
NODE_VERSION: 12.x
defaults:
run:
working-directory: token-lending/js
needs: build_bpf_programs
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-token-lending-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-token-lending-
- uses: actions/download-artifact@v2
with:
name: programs
path: target/bpfel-unknown-unknown/release
- run: (cd ../../token/js && npm install)
- run: npm install
- run: npm run lint
- run: npm run build
- run: |
npm run cluster:localnet
npm run localnet:update
npm run localnet:up
- run: npm run start
- run: npm run localnet:down

View File

@ -22,13 +22,6 @@ env:
jobs:
include:
- name: "Build programs"
language: rust
install:
source .travis/install-program-deps.sh
script:
- ci/script.sh
# docs pull request or commit to master
- name: "Build Docs"
if: type IN (push, pull_request) AND branch = master

View File

@ -1,28 +0,0 @@
# |source| this file
cargo --version
rustup install nightly
rustup component add rustfmt
rustup component add clippy --toolchain nightly
cargo install rustfilt
docker --version
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
nvm install node
npm install -g typescript
node --version
if [[ -n $SOLANA_VERSION ]]; then
sh -c "$(curl -sSfL https://release.solana.com/$SOLANA_VERSION/install)"
fi
export PATH=/home/travis/.local/share/solana/install/active_release/bin:"$PATH"
solana --version
cargo build-bpf --version

26
Cargo.lock generated
View File

@ -604,19 +604,6 @@ dependencies = [
"subtle 2.2.3",
]
[[package]]
name = "curve25519-dalek"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5"
dependencies = [
"byteorder",
"digest 0.8.1",
"rand_core",
"subtle 2.2.3",
"zeroize",
]
[[package]]
name = "curve25519-dalek"
version = "2.1.0"
@ -631,6 +618,19 @@ dependencies = [
"zeroize",
]
[[package]]
name = "curve25519-dalek"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5"
dependencies = [
"byteorder",
"digest 0.8.1",
"rand_core",
"subtle 2.2.3",
"zeroize",
]
[[package]]
name = "derivative"
version = "2.1.1"

View File

@ -1,127 +0,0 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
travis_cmd_prelude() {
if [[ -n "$TRAVIS" ]]; then
echo "travis_fold:start:_"
fi
}
travis_cmd_postlude() {
declare elapsed_seconds=$1
if [[ -n "$TRAVIS" ]]; then
echo "travis_fold:end:_"
# TODO: Use "travis_time" annotations instead of this fold hack:
echo "travis_fold:start:${elapsed_seconds}s"
echo "travis_fold:end:${elapsed_seconds}s"
fi
}
_() {
travis_cmd_prelude
SECONDS=
(
set -x
"$@"
) || exit 1
travis_cmd_postlude $SECONDS
}
export RUSTFLAGS="-D warnings"
export RUSTBACKTRACE=1
_ cargo fmt --all -- --check
_ cargo +nightly clippy -Zunstable-options --workspace --all-targets -- --deny=warnings
_ cargo build
_ cargo test
_ cargo run --manifest-path=utils/test-client/Cargo.toml
# # 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
# For all BPF programs
for Xargo_toml in $(git ls-files -- '*/Xargo.toml'); do
program_dir=$(dirname "$Xargo_toml")
_ cargo build-bpf --manifest-path="$program_dir"/Cargo.toml --dump
done
# Run client tests
_ cargo test --manifest-path=shared-memory/client/Cargo.toml -- --nocapture
_ cargo test --manifest-path=token/perf-monitor/Cargo.toml -- --nocapture
_ cargo test --manifest-path=themis/client_ristretto/Cargo.toml -- --nocapture
# Test token js bindings
js_token() {
cd token/js
time npm install || exit $?
time npm run lint || exit $?
time npm run flow || exit $?
tsc module.d.ts || exit $?
npm run cluster:localnet || exit $?
npm run localnet:down
npm run localnet:update || exit $?
npm run localnet:up || exit $?
time npm run start || exit $?
time PROGRAM_VERSION=2.0.4 npm run start || exit $?
npm run localnet:down
}
_ js_token
# Test token-swap js bindings
js_token_swap() {
cd token-swap/js
time npm install || exit $?
time npm run lint || exit $?
time npm run flow || exit $?
tsc module.d.ts || exit $?
npm run cluster:localnet || exit $?
npm run localnet:down
npm run localnet:update || exit $?
npm run localnet:up || exit $?
time npm run start || exit $?
npm run localnet:down
}
_ js_token_swap
# Test token-swap js bindings with "production" feature
production_token_swap() {
address="SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8"
SWAP_PROGRAM_OWNER_FEE_ADDRESS="$address" cargo build-bpf --manifest-path=token-swap/program/Cargo.toml --dump --features production
cd token-swap/js
npm run cluster:localnet || exit $?
npm run localnet:down
npm run localnet:update || exit $?
npm run localnet:up || exit $?
SWAP_PROGRAM_OWNER_FEE_ADDRESS="$address" npm run start || exit $?
npm run localnet:down
}
_ production_token_swap
# Test token-lending js bindings
js_token_lending() {
cd token-lending/js
time npm install || exit $?
time npm run lint || exit $?
time npm run build || exit $?
npm run cluster:localnet || exit $?
npm run localnet:down
npm run localnet:update || exit $?
npm run localnet:up || exit $?
time npm run start || exit $?
npm run localnet:down
}
_ js_token_lending
exit 0