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

135 lines
3.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
#
# 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
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 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
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 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
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 cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy
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:
2021-04-21 10:18:58 +00:00
name: Build 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]
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
2021-04-21 07:54:44 +00:00
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
2021-04-21 08:11:02 +00:00
- name: Rust Cache
uses: Swatinem/rust-cache@v1.2.0
2021-04-22 18:30:44 +00:00
- name: Install PowerPC GCC
if: ${{ matrix.target }} == 'powerpc64-unknown-linux-gnu'
run: |
2021-04-22 18:35:53 +00:00
sudo apt-get install -y gcc-powerpc-linux-gnu
- 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=${{ matrix.target }}
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-21 10:18:58 +00:00
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 }}
2021-04-21 10:18:58 +00:00
- name: Build Image
run: docker build -t rohansircar/actix-demo:latest .
- name: Publish Image
2021-04-22 18:01:23 +00:00
run: docker push rohansircar/actix-demo:latest