135 lines
3.7 KiB
YAML
135 lines
3.7 KiB
YAML
# 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]
|
|
|
|
name: Continuous Integration
|
|
|
|
jobs:
|
|
check:
|
|
name: Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v1.2.0
|
|
|
|
- name: Run cargo check
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: check
|
|
|
|
test:
|
|
name: Test Suite
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v1.2.0
|
|
|
|
- name: Run cargo test
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
|
|
lints:
|
|
name: Lints
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install stable toolchain
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
components: rustfmt, clippy
|
|
- name: Rust Cache
|
|
uses: Swatinem/rust-cache@v1.2.0
|
|
|
|
- name: Run cargo fmt
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: fmt
|
|
args: --all -- --check
|
|
|
|
- name: Run cargo clippy
|
|
uses: actions-rs/cargo@v1
|
|
# continue-on-error: true
|
|
with:
|
|
command: clippy
|
|
args: -- -D warnings
|
|
|
|
build:
|
|
name: Build Binaries
|
|
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
|
runs-on: ubuntu-latest
|
|
needs: [check, test, lints]
|
|
strategy:
|
|
matrix:
|
|
target:
|
|
- x86_64-unknown-linux-gnu
|
|
- aarch64-unknown-linux-gnu
|
|
# - powerpc64-unknown-linux-gnu
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
target: ${{ matrix.target }}
|
|
override: true
|
|
# - 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
|
|
- name: Compile
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
use-cross: true
|
|
command: build
|
|
args: --release --target=${{ matrix.target }}
|
|
|
|
publish-docker:
|
|
name: Build and Publish Docker Image
|
|
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
|
runs-on: ubuntu-latest
|
|
needs: [check, test, lints]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Docker layer cache
|
|
uses: satackey/action-docker-layer-caching@v0.0.11
|
|
continue-on-error: true
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: rohansircar
|
|
password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
|
|
- name: Build Image
|
|
run: docker build -t rohansircar/actix-demo:latest .
|
|
- name: Publish Image
|
|
run: docker push rohansircar/actix-demo:latest
|