Skip to content

Commit

Permalink
chore: switch to reusable workflows (#168)
Browse files Browse the repository at this point in the history
* chore: switch to reusable workflows in CI

* Typo
  • Loading branch information
grtlr committed May 17, 2022
1 parent 1c8b0f1 commit 7ca01fb
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 105 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and Test

on:
workflow_call:
inputs:
os:
required: true
type: string
rust:
required: true
type: string

jobs:
build-and-test:
name: '${{ inputs.os }}, ${{ inputs.rust }}'
runs-on: ${{ inputs.os }}
# Unfortunately, we can't do this right now because `indexmap` does not seem to follow semver.
# env:
# RUSTFLAGS: -D warnings -D missing-docs
steps:
- uses: actions/checkout@v2

- name: Install protoc (Ubuntu)
if: contains(inputs.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler
- name: Install protoc (macOS)
if: contains(inputs.os, 'macos')
run: brew install protobuf

- name: Install protoc (Windows)
if: contains(inputs.os, 'windows')
run: choco install protoc

- name: Install Rust (${{ inputs.rust }})
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.rust }}
override: true

- uses: Swatinem/rust-cache@v1

- name: Build with all features
uses: actions-rs/cargo@v1
with:
command: ci-build-all

- name: Build with INX only
if: contains(inputs.os, 'ubuntu')
uses: actions-rs/cargo@v1
with:
command: ci-build-inx

- name: Build with API only
if: contains(inputs.os, 'ubuntu')
uses: actions-rs/cargo@v1
with:
command: ci-build-api

- name: Test
uses: actions-rs/cargo@v1
with:
command: ci-test

- name: Doc Test
uses: actions-rs/cargo@v1
with:
command: ci-doctest
40 changes: 40 additions & 0 deletions .github/workflows/_clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check Clippy

on:
workflow_call:
inputs:
os:
required: true
type: string
rust:
required: true
type: string

jobs:
clippy:
name: '${{inputs.os}}, ${{inputs.rust}}'
runs-on: ${{inputs.os}}
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{inputs.rust}}
override: true
components: clippy

- name: Clippy with all features
uses: actions-rs/cargo@v1
with:
command: ci-clippy-all

- name: Clippy with INX only
uses: actions-rs/cargo@v1
with:
command: ci-clippy-inx

- name: Clippy with API only
uses: actions-rs/cargo@v1
with:
command: ci-clippy-api
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Build Docker
name: Build Docker Image

on:
pull_request:
paths:
- "docker/Dockerfile"
- "docker/docker-compose.yml"
workflow_call:
inputs: {}

jobs:
build:
name: Build Docker
name: docker-compose build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/_fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check Formatting

on:
workflow_call:
inputs:
os:
required: true
type: string
rust:
required: true
type: string

jobs:
format:
name: '${{inputs.os}}, ${{inputs.rust}}'
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ inputs.rust }}
override: true
components: rustfmt

- uses: actions-rs/cargo@v1
with:
command: ci-fmt
24 changes: 24 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ on:

jobs:

build-and-test-1:
name: "build and test"
uses: ./.github/workflows/_build.yml
with: { os: ubuntu-latest, rust: beta }

build-and-test-2:
name: "build and test"
uses: ./.github/workflows/_build.yml
with: { os: windows-latest, rust: beta }

build-and-test-3:
name: "build and test"
uses: ./.github/workflows/_build.yml
with: { os: macos-latest, rust: beta }

docker:
uses: ./.github/workflows/_docker.yml

clippy:
uses: ./.github/workflows/_clippy.yml
with: { os: ubuntu-latest, rust: beta }

udeps:
runs-on: ubuntu-latest
steps:
Expand All @@ -25,3 +47,5 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: ci-udeps


116 changes: 17 additions & 99 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,110 +13,28 @@ concurrency:
cancel-in-progress: true

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
# Unfortunately, we can do this right now because `indexmap` does not seem to follow semver.
# env:
# RUSTFLAGS: -D warnings -D missing-docs
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v2

- name: Install protoc (Ubuntu)
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
sudo apt-get install -y protobuf-compiler
- name: Install protoc (macOS)
if: contains(matrix.os, 'macos')
run: brew install protobuf

- name: Install protoc (Windows)
if: contains(matrix.os, 'windows')
run: choco install protoc

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

- uses: Swatinem/rust-cache@v1

- name: Build with all features
uses: actions-rs/cargo@v1
with:
command: ci-build-all

- name: Build with INX only
if: contains(matrix.os, 'ubuntu')
uses: actions-rs/cargo@v1
with:
command: ci-build-inx

- name: Build with API only
if: contains(matrix.os, 'ubuntu')
uses: actions-rs/cargo@v1
with:
command: ci-build-api

- name: Test
uses: actions-rs/cargo@v1
with:
command: ci-test
build-and-test-1:
name: "build and test"
uses: ./.github/workflows/_build.yml
with: { os: ubuntu-latest, rust: stable }

build-and-test-2:
name: "build and test"
uses: ./.github/workflows/_build.yml
with: { os: windows-latest, rust: stable }

- name: Doc Test
uses: actions-rs/cargo@v1
with:
command: ci-doctest
build-and-test-3:
name: "build and test"
uses: ./.github/workflows/_build.yml
with: { os: macos-latest, rust: stable }

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- uses: actions-rs/cargo@v1
with:
command: ci-fmt
uses: ./.github/workflows/_fmt.yml
with: { os: ubuntu-latest, rust: nightly }

clippy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

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

- name: Clippy with all features
uses: actions-rs/cargo@v1
with:
command: ci-clippy-all

- name: Clippy with INX only
uses: actions-rs/cargo@v1
with:
command: ci-clippy-inx

- name: Clippy with API only
uses: actions-rs/cargo@v1
with:
command: ci-clippy-api
uses: ./.github/workflows/_clippy.yml
with: { os: ubuntu-latest, rust: stable }

check-toml:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Build Docker

on:
pull_request:
paths:
- "docker/Dockerfile"
- "docker/docker-compose.yml"

jobs:
docker:
uses: ./.github/workflows/_docker.yml
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# inx-chronicle

[![CI](https://github.com/iotaledger/inx-chronicle/actions/workflows/ci.yml/badge.svg)](https://github.com/iotaledger/inx-chronicle/actions/workflows/ci.yml)
[![Canary](https://github.com/iotaledger/inx-chronicle/actions/workflows/canary.yml/badge.svg)](https://github.com/iotaledger/inx-chronicle/actions/workflows/canary.yml)

## Usage

The easiest way to start Chronicle is by using our supplied Dockerfile.
Expand Down

0 comments on commit 7ca01fb

Please sign in to comment.