@ -1,8 +1,4 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
#
# While our "example" application has the platform-specific code,
# for simplicity we are compiling and testing everything on the Ubuntu environment only.
# For multi-OS testing see the `cross.yml` workflow.
on : [ push, pull_request]
on : [ push, pull_request]
@ -15,18 +11,15 @@ jobs:
steps:
steps:
- name : Checkout sources
- name : Checkout sources
uses : actions/checkout@v2
uses : actions/checkout@v2
- name : Install stable toolchain
- name : Install stable toolchain
uses : actions-rs/toolchain@v1
uses : actions-rs/toolchain@v1
with:
with:
profile : minimal
profile : minimal
toolchain : stable
toolchain : stable
override : true
override : true
- name : Rust Cache
- name : Rust Cache
uses : Swatinem/rust-cache@v1.2.0
uses : Swatinem/rust-cache@v1.2.0
- name : Run cargo check
- name : Run Cargo Check
uses : actions-rs/cargo@v1
uses : actions-rs/cargo@v1
with:
with:
command : check
command : check
@ -37,7 +30,6 @@ jobs:
steps:
steps:
- name : Checkout sources
- name : Checkout sources
uses : actions/checkout@v2
uses : actions/checkout@v2
- name : Install stable toolchain
- name : Install stable toolchain
uses : actions-rs/toolchain@v1
uses : actions-rs/toolchain@v1
with:
with:
@ -47,7 +39,7 @@ jobs:
- name : Rust Cache
- name : Rust Cache
uses : Swatinem/rust-cache@v1.2.0
uses : Swatinem/rust-cache@v1.2.0
- name : Run cargo test
- name : Run Tests
uses : actions-rs/cargo@v1
uses : actions-rs/cargo@v1
with:
with:
command : test
command : test
@ -58,7 +50,6 @@ jobs:
steps:
steps:
- name : Checkout sources
- name : Checkout sources
uses : actions/checkout@v2
uses : actions/checkout@v2
- name : Install stable toolchain
- name : Install stable toolchain
uses : actions-rs/toolchain@v1
uses : actions-rs/toolchain@v1
with:
with:
@ -68,31 +59,23 @@ jobs:
components : rustfmt, clippy
components : rustfmt, clippy
- name : Rust Cache
- name : Rust Cache
uses : Swatinem/rust-cache@v1.2.0
uses : Swatinem/rust-cache@v1.2.0
- name : Run cargo fmt
- name : Run Cargo fmt
uses : actions-rs/cargo@v1
uses : actions-rs/cargo@v1
with:
with:
command : fmt
command : fmt
args : --all -- --check
args : --all -- --check
- name : Run cargo clippy
- name : Run Cargo clippy
uses : actions-rs/cargo@v1
uses : actions-rs/cargo@v1
# continue-on-error: true
# continue-on-error: true
with:
with:
command : clippy
command : clippy
args : -- -D warnings
args : -- -D warnings
build:
name : Build Binaries
build-aarch64 :
name : Build aarch64 Binaries
if : github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
if : github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
runs-on : ubuntu-latest
runs-on : ubuntu-latest
needs : [ check, test, lints]
needs : [ check, test, lints]
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
# - powerpc64-unknown-linux-gnu
steps:
steps:
- uses : actions/checkout@v2
- uses : actions/checkout@v2
- uses : actions-rs/toolchain@v1
- uses : actions-rs/toolchain@v1
@ -105,20 +88,47 @@ jobs:
path : |
path : |
~/.cargo/registry
~/.cargo/registry
~/.cargo/git
~/.cargo/git
~/.cargo/bin
~/.cargo/.crates2.json
~/.cargo/.crates.toml
target
target
key : ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# - name: Rust Cache
# uses: Swatinem/rust-cache@v1.2.0
# - name: Install PowerPC GCC
# if: matrix.target == 'powerpc64-unknown-linux-gnu'
# run: |
# sudo apt-get install -y gcc-powerpc-linux-gnu
key : ${{ runner.os }}-aarch64-unknown-linux-gnu-cargo-${{ hashFiles('**/Cargo.lock') }}
- name : Compile
- name : Compile
uses : actions-rs/cargo@v1
uses : actions-rs/cargo@v1
with:
with:
use-cross : true
use-cross : true
command : build
command : build
args : --release --target=${{ matrix.target }}
args : --release --target=aarch64-unknown-linux-gnu
build-ppc:
name : Build PowerPC Binaries
if : github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
continue-on-error : true
runs-on : ubuntu-latest
needs : [ check, test, lints]
steps:
- uses : actions/checkout@v2
- uses : actions-rs/toolchain@v1
with:
toolchain : stable
target : ${{ matrix.target }}
override : true
- uses : actions/cache@v2
with:
path : |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
~/.cargo/.crates2.json
~/.cargo/.crates.toml
target
key : ${{ runner.os }}-powerpc64-unknown-linux-gnu-cargo-${{ hashFiles('**/Cargo.lock') }}
run : sudo apt-get install -y gcc-powerpc-linux-gnu
- name : Compile
uses : actions-rs/cargo@v1
with:
command : build
args : --release --target=powerpc64-unknown-linux-gnu
publish-docker:
publish-docker:
name : Build and Publish Docker Image
name : Build and Publish Docker Image
@ -127,15 +137,25 @@ jobs:
needs : [ check, test, lints]
needs : [ check, test, lints]
steps:
steps:
- uses : actions/checkout@v2
- uses : actions/checkout@v2
- name : Docker layer cache
uses : satackey/action-docker-layer-caching@v0.0.11
continue-on-error : true
- uses : actions-rs/toolchain@v1
with:
toolchain : stable
target : x86_64-unknown-linux-gnu
override : true
- name : Rust Cache
uses : Swatinem/rust-cache@v1.2.0
- name : Login to Docker Hub
- name : Login to Docker Hub
uses : docker/login-action@v1
uses : docker/login-action@v1
with:
with:
username : rohansircar
username : rohansircar
password : ${{ secrets.DOCKER_LOGIN_PASSWORD }}
password : ${{ secrets.DOCKER_LOGIN_PASSWORD }}
- name : Compile
uses : actions-rs/cargo@v1
with:
command : build
args : --release
- name : Build Image
- name : Build Image
run : docker build -t rohansircar/actix-demo:latest .
run : docker build -f ci.Dockerfile -t rohansircar/actix-demo:latest .
env : DOCKER_BUILDKIT=1
- name : Publish Image
- name : Publish Image
run : docker push rohansircar/actix-demo:latest
run : docker push rohansircar/actix-demo:latest