Skip to content

Commit

Permalink
Add CI pipeline (#6)
Browse files Browse the repository at this point in the history
* feature(ci): Copy workflows from stronghold and adapt for identity.rs

* fix(ci): Use main instead of master for branch trigger

* feature(ci): Build and test on Windows as well

* fix(ci): Remove toolchain from cache keys
  • Loading branch information
rajivshah3 authored Aug 12, 2020
1 parent 8dc6cf7 commit ce99390
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Audit

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
paths:
- "**/Cargo.lock"
- "**/Cargo.toml"
pull_request:
branches:
- main
paths:
- "**/Cargo.lock"
- "**/Cargo.toml"

jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
80 changes: 80 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build and run tests

on:
push:
branches:
- main
pull_request:
branches:
- main
- dev
paths-ignore:
- 'docs/**'

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
project: [identity_account, identity_communication, identity_doc_manager, identity_integration, identity_resolver, identity_schema, identity_vc]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Get current date
if: matrix.os == 'ubuntu-latest'
run: echo "::set-env name=CURRENT_DATE::$(date +'%Y-%m-%d')"

- name: Get current date
if: matrix.os == 'windows-latest'
run: echo "::set-env name=CURRENT_DATE::$(Get-Date -Format "yyyy-MM-dd")"

- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.project }}-${{ matrix.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.project }}-${{ matrix.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.project }}-${{ matrix.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.project }}-${{ matrix.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}
- name: Cache cargo target
uses: actions/cache@v2
with:
path: ${{ matrix.project}}/target
# Add date to the cache to keep it up to date
key: ${{ matrix.project }}-${{ matrix.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.project }}-${{ matrix.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}
- name: Build ${{ matrix.project }}
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path=${{ matrix.project }}/Cargo.toml --all --release

- name: Run tests for ${{ matrix.project }}
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=${{ matrix.project }}/Cargo.toml --all --release
33 changes: 33 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Clippy

on:
push:
branches:
- main
pull_request:
branches:
- main
- dev

jobs:
clippy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [identity_account, identity_communication, identity_doc_manager, identity_integration, identity_resolver, identity_schema, identity_vc]

steps:
- uses: actions/checkout@v2
- name: Install clippy with stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path=${{ matrix.project }}/Cargo.toml --all-targets --all-features -- -D warnings
name: clippy-${{ matrix.project }}
4 changes: 2 additions & 2 deletions .github/workflows/deploy_docs_to_github_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: deploy docs to github pages
on:
push:
branches:
- master
- main

jobs:
deploy:
Expand All @@ -23,4 +23,4 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./book
publish_dir: ./book
32 changes: 32 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Format

on:
push:
branches:
- main
pull_request:
branches:
- main
- dev

jobs:
format:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [identity_account, identity_communication, identity_doc_manager, identity_integration, identity_resolver, identity_schema, identity_vc]

steps:
- uses: actions/checkout@v2
- name: Install rustfmt with nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path=${{ matrix.project }}/Cargo.toml --all -- --check

0 comments on commit ce99390

Please sign in to comment.