Skip to content

fix(ota)

fix(ota) #234

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
ALL_FEATURES: "ota_mqtt_data,ota_http_data"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Build (library)
run: cargo build --all --target thumbv7em-none-eabihf
# - name: Build (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo build)
# done
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Doc Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --doc --features "std,log"
- name: Unit Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --features "std,log"
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Run rustfmt (library)
run: cargo fmt --all -- --check --verbose
# - name: Run rustfmt (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo fmt --all -- --check --verbose)
# done
clippy:
name: clippy
runs-on: ubuntu-latest
env:
CLIPPY_PARAMS: -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
steps:
- name: Checkout source code
uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Run clippy (library)
run: cargo clippy --features "log" -- ${{ env.CLIPPY_PARAMS }}
# - name: Run clippy (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo clippy -- ${{ env.CLIPPY_PARAMS }})
# done
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: ["build", "test", "rustfmt", "clippy"]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Create OTA Job
run: |
./scripts/create_ota.sh
env:
AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}
- name: Integration Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --test '*' --features "ota_mqtt_data,log" --target x86_64-unknown-linux-gnu
env:
IDENTITY_PASSWORD: ${{ secrets.DEVICE_ADVISOR_PASSWORD }}
AWS_HOSTNAME: a1vq3mi5y3c6j5-ats.iot.eu-west-1.amazonaws.com
- name: Cleanup OTA Jobs
if: ${{ always() }}
run: |
./scripts/cleanup_ota.sh
env:
AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}
# device_advisor:
# name: AWS IoT Device Advisor
# runs-on: ubuntu-latest
# needs: test
# env:
# AWS_EC2_METADATA_DISABLED: true
# AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
# AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}
# SUITE_ID: 1gaev57dq6i5
# THING_ARN: arn:aws:iot:eu-west-1:411974994697:thing/embedded-mqtt
# steps:
# - name: Checkout source code
# uses: actions/checkout@v4
# - uses: dsherret/rust-toolchain-file@v1
# - name: Get AWS_HOSTNAME
# id: hostname
# run: |
# hostname=$(aws iotdeviceadvisor get-endpoint --thing-arn ${{ env.THING_ARN }} --output text --query endpoint)
# ret=$?
# echo "::set-output name=AWS_HOSTNAME::$hostname"
# exit $ret
# - name: Build test binary
# env:
# AWS_HOSTNAME: ${{ steps.hostname.outputs.AWS_HOSTNAME }}
# run: cargo build --features=log --example aws_device_advisor --release
# - name: Start test suite
# id: test_suite
# run: |
# suite_id=$(aws iotdeviceadvisor start-suite-run --suite-definition-id ${{ env.SUITE_ID }} --suite-run-configuration "primaryDevice={thingArn=${{ env.THING_ARN }}},parallelRun=true" --output text --query suiteRunId)
# ret=$?
# echo "::set-output name=SUITE_RUN_ID::$suite_id"
# exit $ret
# - name: Execute test binary
# id: binary
# env:
# DEVICE_ADVISOR_PASSWORD: ${{ secrets.DEVICE_ADVISOR_PASSWORD }}
# RUST_LOG: trace
# run: |
# nohup ./target/release/examples/aws_device_advisor > device_advisor_integration.log &
# echo "::set-output name=PID::$!"
# - name: Monitor test run
# run: |
# chmod +x ./scripts/da_monitor.sh
# echo ${{ env.SUITE_ID }} ${{ steps.test_suite.outputs.SUITE_RUN_ID }} ${{ steps.binary.outputs.PID }}
# ./scripts/da_monitor.sh ${{ env.SUITE_ID }} ${{ steps.test_suite.outputs.SUITE_RUN_ID }} ${{ steps.binary.outputs.PID }}
# - name: Kill test binary process
# if: ${{ always() }}
# run: kill ${{ steps.binary.outputs.PID }} || true
# - name: Log binary output
# if: ${{ always() }}
# run: cat device_advisor_integration.log
# - name: Stop test suite
# if: ${{ failure() }}
# run: aws iotdeviceadvisor stop-suite-run --suite-definition-id ${{ env.SUITE_ID }} --suite-run-id ${{ steps.test_suite.outputs.SUITE_RUN_ID }}