Skip to content

set dependencies

set dependencies #746

Workflow file for this run

name: Build-CI
on:
pull_request:
branches: [Develop, main-net-runtime,redux-ci-testing]
push:
branches: [Develop, main-net-runtime,redux-ci-testing]
env:
RUNNER_INSTANCE_TYPE: c5.4xlarge
jobs:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN_REPO }}
ec2-image-id: ami-06de69a4185c962ed
ec2-instance-type: ${{ env.RUNNER_INSTANCE_TYPE }}
subnet-id: subnet-a4d326e8
security-group-id: sg-078363c0f7b5f0b41
iam-role-name: github-runner-role
aws-resource-tags: >
[
{"Key": "Name", "Value": "github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
build:
needs: start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- uses: actions/checkout@v2
- name: set dependencies. # bug self hosted https://github.com/actions-rs/toolchain/issues/137
run: |
cat /etc/issue
echo "HOME=/root" >> ${GITHUB_ENV} # bug
apt install -y clang lldb lld gcc
- name: Cache Rust Dependecies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Add wasm toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
override: true
- name: Add fmt
# v1.5.0 includes fixes of closures formatting
run: |
cd ..
git clone --depth 1 https://github.com/rust-lang/rustfmt
cd rustfmt
git fetch --tags
git checkout v1.5.0
export CFG_RELEASE=nightly
export CFG_RELEASE_CHANNEL=nightly
cargo clean -p rustfmt-nightly
cargo install --path . --force
cd ../Polkadex
- name: Build Project
run: |
cargo clean
# cargo build --release --features runtime-benchmarks
RUSTFLAGS="-D warnings" cargo build
- name: Check Formatting
run: cargo fmt --check
- name: Check Clippy
run: |
rustup component add clippy --toolchain=nightly
cargo +nightly clippy -- -D warnings
- name: Test Project
run: cargo test
- name: Run Cargo Trampulin
uses: actions-rs/tarpaulin@v0.1
with:
args: '--exclude polkadex-node node-polkadex-runtime --workspace --timeout 180'
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true
- name: Archive code coverage results
if: github.event_name == 'push'
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: cobertura.xml
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner
- build
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN_REPO }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}