Skip to content

enable docker build #108

enable docker build

enable docker build #108

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
env:
toolchain: stable
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install Rust
run: rustup update ${{ env.toolchain }} && rustup default ${{ env.toolchain }}
- name: Install Cargo Tarpaulin
run: cargo install cargo-tarpaulin
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Build
run: cargo build --verbose
- name: Run Tests with Coverage
run: cargo tarpaulin --out Xml
- name: Run Clippy
run: cargo clippy --message-format=json &> clippy.json
- name: Update Sonar
uses: sonarsource/sonarqube-scan-action@v3
if: github.ref == 'refs/heads/main'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Build Release
run: cargo build --release
- uses: actions/upload-artifact@v4
with:
name: mqtt-gateway
path: target/release/mqtt-gateway
# If you wish to fail your job when the Quality Gate is red, uncomment the
# following lines. This would typically be used to fail a deployment.
# - uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}