Actix-Demo/.github/workflows/ci.yml

164 lines
4.7 KiB
YAML
Raw Normal View History

2021-04-21 07:54:44 +00:00
# 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
2021-04-21 08:11:02 +00:00
- name: Rust Cache
uses: Swatinem/rust-cache@v1.2.0
- name: Run Cargo Check
2021-04-21 07:54:44 +00:00
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
2021-04-21 08:11:02 +00:00
- name: Rust Cache
uses: Swatinem/rust-cache@v1.2.0
2021-04-21 07:54:44 +00:00
- name: Run Tests
2021-04-21 07:54:44 +00:00
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
2021-04-21 08:11:02 +00:00
- name: Rust Cache
uses: Swatinem/rust-cache@v1.2.0
- name: Run Cargo fmt
2021-04-21 07:54:44 +00:00
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run Cargo clippy
2021-04-21 07:54:44 +00:00
uses: actions-rs/cargo@v1
2021-04-22 15:05:48 +00:00
# continue-on-error: true
2021-04-21 07:54:44 +00:00
with:
command: clippy
args: -- -D warnings
build-aarch64:
2021-04-24 17:35:41 +00:00
name: Build ARM64 Binaries
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
2021-04-21 07:54:44 +00:00
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
2021-04-23 12:18:54 +00:00
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
~/.cargo/.crates2.json
~/.cargo/.crates.toml
2021-04-23 12:18:54 +00:00
target
key: ${{ runner.os }}-aarch64-unknown-linux-gnu-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Compile
uses: actions-rs/cargo@v1
2021-04-21 07:54:44 +00:00
with:
use-cross: true
2021-04-21 07:54:44 +00:00
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
2021-04-24 18:09:19 +00:00
runs-on: ubuntu-18.04
needs: [check, test, lints]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
2021-04-24 17:35:41 +00:00
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') }}
2021-04-24 17:22:59 +00:00
- 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
2021-04-21 10:18:58 +00:00
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'))
2021-04-24 18:09:19 +00:00
runs-on: ubuntu-18.04
2021-04-21 10:18:58 +00:00
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
2021-04-25 19:33:00 +00:00
- 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
2021-04-21 10:18:58 +00:00
- name: Build Image
run: docker build -f ci.Dockerfile -t rohansircar/actix-demo:latest .
2021-04-24 17:24:12 +00:00
env:
DOCKER_BUILDKIT: 1
- name: Publish Image
2021-04-22 18:01:23 +00:00
run: docker push rohansircar/actix-demo:latest