Actix-Demo/.github/workflows/ci.yml
2021-04-26 20:10:43 +05:30

164 lines
4.7 KiB
YAML

# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
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 Tests
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-aarch64:
name: Build ARM64 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]
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 }}-aarch64-unknown-linux-gnu-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Compile
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
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-18.04
needs: [check, test, lints]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: powerpc64-unknown-linux-gnu
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') }}
- name: Install PowerPC gcc
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:
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-18.04
needs: [check, test, lints]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.50.0
target: x86_64-unknown-linux-gnu
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v1.2.0
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: rohansircar
password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
- name: Compile
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Build Image
run: docker build -f ci.Dockerfile -t rohansircar/actix-demo:latest .
env:
DOCKER_BUILDKIT: 1
- name: Publish Image
run: docker push rohansircar/actix-demo:latest