Rohan Sircar
565e6bc5e4
instead of docker layer caching, build binary in runner itself and copy binary to dockerfile old Dockerfile is now build.Dockerfile whereas new one is ci.Dockerfile caching docker layers was taking more time than building the image from scratch add powerpc build (for the 100th time) but without cross in it's own job
162 lines
4.6 KiB
YAML
162 lines
4.6 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 aarch64 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-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:
|
|
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
|
|
- 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
|
|
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
|