Skip to content

Commit

Permalink
Merge pull request #110 from input-output-hk/ci-improvements
Browse files Browse the repository at this point in the history
CI improvements
  • Loading branch information
Mikhail Zabaluev committed Jan 11, 2021
2 parents 6765dc3 + 10ed6f3 commit 6779115
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 85 deletions.
83 changes: 0 additions & 83 deletions .github/workflows/main.yml

This file was deleted.

138 changes: 138 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,138 @@
on:
push:
branches:
- master
pull_request:

name: CI

jobs:

update-deps:
name: Update dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- id: cargo-deps
name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}

- if: ${{ steps.cargo-deps.outputs.cache-hit != 'true' }}
id: ls-crates-io-index
name: Get head commit hash of crates.io registry index
run: |
commit=$(
git ls-remote --heads https://github.com/rust-lang/crates.io-index.git master |
cut -f 1
)
echo "::set-output name=head::$commit"
- if: ${{ steps.cargo-deps.outputs.cache-hit != 'true' }}
name: Cache cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ steps.ls-crates-io-index.outputs.head }}
restore-keys: |
cargo-index-
- if: ${{ steps.cargo-deps.outputs.cache-hit != 'true' }}
name: Fetch dependencies
run: cargo fetch --locked

test:
name: Test Suite
needs: update-deps
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v2

- if: ${{ runner.os == 'Windows' }}
name: Fix up Cargo.lock hash
run: |
Get-ChildItem . -Recurse -Filter Cargo.lock |
Foreach-Object {
((Get-Content $_.FullName) -join "`n") + "`n" |
Set-Content -NoNewline $_.FullName
}
- name: Restore cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install libsqlite3 (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libsqlite3-dev
- uses: actions-rs/cargo@v1
continue-on-error: false
with:
command: build
args: --locked
- uses: actions-rs/cargo@v1
continue-on-error: false
with:
command: test
args: --locked

lints:
name: Rust lints
needs: update-deps
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
continue-on-error: false
with:
command: fmt
args: -- --check

- name: Restore cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: cargo-deps-${{ hashFiles('**/Cargo.lock') }}

- name: Run cargo clippy
uses: actions-rs/clippy-check@v1
continue-on-error: false
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- --deny warnings
3 changes: 1 addition & 2 deletions vit-servicing-station-cli/src/api_token.rs
Expand Up @@ -4,7 +4,6 @@ use chrono::{Duration, Utc};
use rand::Rng;
use std::collections::HashSet;
use std::io;
use std::iter::FromIterator;
use structopt::StructOpt;
use vit_servicing_station_lib::{
db::{
Expand Down Expand Up @@ -66,7 +65,7 @@ impl APITokenCmd {

fn add_tokens(base64_tokens: &[String], db_conn: &DBConnection) -> io::Result<()> {
// filter duplicated tokens
let base64_tokens: HashSet<String> = HashSet::from_iter(base64_tokens.iter().cloned());
let base64_tokens: HashSet<String> = base64_tokens.iter().cloned().collect();
for base64_token in base64_tokens {
let token =
base64::decode_config(&base64_token, base64::URL_SAFE_NO_PAD).map_err(|e| {
Expand Down

0 comments on commit 6779115

Please sign in to comment.