Skip to content

Commit

Permalink
migrate test job from github to circle ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Jan 26, 2021
1 parent 85be98c commit a29af60
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 116 deletions.
128 changes: 128 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,128 @@
version: 2.1

executors:
rust-stable:
docker:
- image: inputoutput/rust:stable
working_directory: /home/circleci/build

jobs:
cargo_fetch:
executor: rust-stable
steps:
- checkout
- run: git --version
- run:
name: Get top commit hash of cargo registry index
command: |
git ls-remote --heads https://github.com/rust-lang/crates.io-index.git master |
cut -f 1 | tee .circleci/crates.io-index.head
- restore_cache:
name: Restore cargo registry index from cache
keys:
- cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }}
- cargo-index-v1-
- restore_cache:
name: Restore dependency crates from cache
keys:
- cargo-deps-v2-{{ checksum "Cargo.lock" }}
- run:
name: Fetch dependencies and update cargo registry index
command: |
cargo fetch
git -C /usr/local/cargo/registry/index/github.com-1ecc6299db9ec823 \
show-ref -s refs/remotes/origin/master |
tee .circleci/crates.io-index.head
- save_cache:
name: Save cargo registry index into cache
key: cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }}
paths:
- /usr/local/cargo/registry/index
- save_cache:
name: Save dependency crates into cache
key: cargo-deps-v2-{{ checksum "Cargo.lock" }}
paths:
- /usr/local/cargo/registry/cache
- /usr/local/cargo/git/db
- persist_to_workspace:
root: .
paths:
- .circleci/crates.io-index.head

test_debug:
executor: rust-stable
environment:
RUSTFLAGS: -D warnings
CARGO_INCREMENTAL: 0
steps:
- test

commands:
test:
description: "Steps for the test jobs"
parameters:
mode:
type: string
default: ''
cargo_behavior:
type: string
default: --verbose
steps:
- checkout
- attach_workspace:
at: .
- restore_cache:
name: Restore cargo registry index from cache
keys:
- cargo-index-v1-{{ checksum ".circleci/crates.io-index.head" }}
- restore_cache:
name: Restore dependency crates from cache
keys:
- cargo-deps-v2-{{ checksum "Cargo.lock" }}
- run:
name: Print version information
command: rustc --version; cargo --version
- run:
name: checkout jormungandr
command: |
git clone https://github.com/input-output-hk/jormungandr.git
- run:
name: install jormungandr
command: |
cd jormungandr
cargo install --path jormungandr
- run:
name: checkout vit-station-service
command: |
git clone
https://github.com/input-output-hk/vit-servicing-station.git
- run:
name: install jormungandr
command: |
cd vit-servicing-station
cargo install --path vit-servicing-station-server
- run:
name: install iapyx
command: |
cd vit-servicing-station
cargo install --path vit-servicing-station-server
- run:
name: install iapyx utils
command: |
cd iapyx
cargo install --path iapyx
- run:
name: Run tests
environment:
RUST_BACKTRACE: 1
command: |
cargo test
workflows:
version: 2
test_all:
jobs:
- cargo_fetch
- test_debug:
requires:
- cargo_fetch
116 changes: 0 additions & 116 deletions .github/workflows/test.yml
Expand Up @@ -52,122 +52,6 @@ jobs:
echo "$hash"
echo "::set-output name=hash::$hash"
update_deps:
name: Update dependencies
needs: cache_info
# Caches on Windows and Unix do not interop:
# https://github.com/actions/cache/issues/330#issuecomment-637701649
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Cache cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ needs.cache_info.outputs.crates-io-index-head }}
restore-keys: cargo-index-

- id: cargo-deps
name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-v1-${{ needs.cache_info.outputs.cargo-lock-hash }}

- name: Check out the repository
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch dependencies and update cargo registry
run: cargo fetch

tests:
name: Tests
needs: [cache_info, update_deps]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
flags: ['', '--release']
toolchain: [stable]
include:
- os: ubuntu-latest
flags: ''
toolchain: nightly
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: 1
CARGO_FLAGS: --verbose
steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
default: true
components: rustfmt

- name: Checkout code
uses: actions/checkout@v2

- name: Restore cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ needs.cache_info.outputs.crates-io-index-head }}

- name: Restore cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-v1-${{ needs.cache_info.outputs.cargo-lock-hash }}

- name: Checkout jormungandr
uses: actions/checkout@master
with:
path: 'jormungandr'
name: input-output-hk/jormungandr

- name: Checkout vit-servicing-station
uses: actions/checkout@master
with: $GITHUB_WORKSPACE to place the repository
path: 'vit-servicing-station'
name: input-output-hk/vit-servicing-station

- name: Build iapyx
uses: actions-rs/cargo@v1
timeout-minutes: 30
with:
command: build
args: -p iapyx ${{ env.CARGO_FLAGS }} ${{ matrix.flags }}

- name: Build vitup
uses: actions-rs/cargo@v1
timeout-minutes: 30
with:
command: build
args: -p vitup ${{ env.CARGO_FLAGS }} ${{ matrix.flags }}

- name: Build tests
uses: actions-rs/cargo@v1
timeout-minutes: 30
with:
command: build
args: --tests ${{ env.CARGO_FLAGS }} ${{ matrix.flags }}

- name: Run tests
timeout-minutes: 30
run: |
cd integration-tests
cargo test ${{ env.CARGO_FLAGS }} ${{ matrix.flags }}
lints:
name: Lints
needs: [cache_info, update_deps]
Expand Down

0 comments on commit a29af60

Please sign in to comment.