Skip to content

Commit

Permalink
Merge pull request #54 from sdr-enthusiasts/rust_dev
Browse files Browse the repository at this point in the history
Rust dev
  • Loading branch information
fredclausen authored Jul 28, 2022
2 parents 02430e0 + 32948fd commit 3cbf94b
Show file tree
Hide file tree
Showing 57 changed files with 5,468 additions and 218 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
crate
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.github
.gitattributes
READMETEMPLATE.md
README.md
README.md
target
5 changes: 2 additions & 3 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

version: 2

updates:
Expand All @@ -16,7 +15,7 @@ updates:
interval: "daily"

# Maintain pip packages for acars_router
- package-ecosystem: "pip"
directory: "/acars_router"
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
8 changes: 4 additions & 4 deletions .github/workflows/cancel_dupes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Cancelling Duplicates
on:
workflow_run:
workflows:
- 'Pull Request'
- 'Deploy'
- 'Linting (Hadolint)'
types: ['requested']
- "Pull Request"
- "Deploy"
- "Linting (Hadolint)"
types: ["requested"]

jobs:
cancel-duplicate-workflow-runs:
Expand Down
192 changes: 183 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ on:
inputs:
reason:
required: true
description: 'Reason for running this workflow'
description: "Reason for running this workflow"
push:
branches:
- main

# Don't trigger if it's just a documentation update
paths-ignore:
- '**.md'
- '**.MD'
- '**.yml'
- 'LICENSE'
- '.gitattributes'
- '.gitignore'
- '.dockerignore'
- "**.md"
- "**.MD"
- "**.yml"
- "**.yaml"
- "LICENSE"
- ".gitattributes"
- ".gitignore"
- ".dockerignore"

jobs:

workflow-dispatch:
name: Workflow Dispatch
# only run this step if workflow dispatch triggered
Expand All @@ -39,13 +39,187 @@ jobs:
echo "Workflow dispatch reason: $INPUTS_REASON"
echo "::notice title=${{ github.job }}: Workflow Dispatch Reason::${INPUTS_REASON}"
binary_build:
name: Build Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Install OS dependencies: armhf"
uses: ryankurte/action-apt@v0.3.0
with:
arch: armhf
packages: "libzmq3-dev:armhf"

- name: "Install OS dependencies: arm64"
uses: ryankurte/action-apt@v0.3.0
with:
arch: arm64
packages: "libzmq3-dev:arm64"

# i386 currently does not work...
# - name: "Install OS dependencies: i386"
# uses: ryankurte/action-apt@v0.3.0
# with:
# arch: i386
# packages: "libzmq3-dev:i386"

- name: "Install OS dependencies: arm64"
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libzmq3-dev
- name: "Install rust targets/toolchains for cross build"
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
g++-arm-linux-gnueabihf \
libc6-dev-armhf-cross \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross
rustup target add armv7-unknown-linux-gnueabihf
rustup toolchain install stable-armv7-unknown-linux-gnueabihf
rustup target add aarch64-unknown-linux-gnu
rustup toolchain install stable-aarch64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-gnu
rustup toolchain install stable-x86_64-unknown-linux-gnu
- name: Build armv7
run: |
PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf RUSTFLAGS="-C linker=/usr/bin/arm-linux-gnueabihf-gcc" cargo build --release --target armv7-unknown-linux-gnueabihf
- name: Build arm64
run: |
PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu RUSTFLAGS="-C linker=/usr/bin/aarch64-linux-gnu-gcc" cargo build --release --target aarch64-unknown-linux-gnu
- name: Build amd64
run: |
cargo build --release
- name: Consolidate binaries
run: |
mkdir -p ./bin
cp -v ./target/release/acars_router ./bin/acars_router.amd64
cp -v ./target/armv7-unknown-linux-gnueabihf/release/acars_router ./bin/acars_router.armv7
cp -v ./target/aarch64-unknown-linux-gnu/release/acars_router ./bin/acars_router.arm64
- name: Upload artifact amd64 binary
uses: actions/upload-artifact@v3
with:
name: acars_router.amd64
path: ./bin/acars_router.amd64

- name: Upload artifact armv7 binary
uses: actions/upload-artifact@v3
with:
name: acars_router.armv7
path: ./bin/acars_router.armv7

- name: Upload artifact arm64 binary
uses: actions/upload-artifact@v3
with:
name: acars_router.arm64
path: ./bin/acars_router.arm64

- name: Cache Cargo Build Output
uses: actions/cache@v3
with:
path: bin/
key: ${{ github.run_id }}

# # Allows troubleshooting via SSH
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# limit-access-to-users: mikenye

release_binaries:
name: Release Binaries
needs: [binary_build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache cargo build output
id: get_cache
uses: actions/cache@v3
with:
path: bin/
key: ${{ github.run_id }}

- name: Check cache
if: steps.get_cache.outputs.cache-hit != 'true'
run: |
echo "::error title=${{ github.job }}: Could not get binaries from action cache"
exit 1
- name: Prepare binary release tarballs
if: steps.get_cache.outputs.cache-hit == 'true'
run: |
ORIGDIR=$(pwd)
# Make release tarballs
mkdir -vp ./release
pushd ./bin
tar cJvf "$ORIGDIR/release/acars_router.amd64.tar.xz" ./acars_router.amd64
tar cJvf "$ORIGDIR/release/acars_router.armv7.tar.xz" ./acars_router.armv7
tar cJvf "$ORIGDIR/release/acars_router.arm64.tar.xz" ./acars_router.arm64
popd
- name: Get binary version from Cargo.toml
if: steps.get_cache.outputs.cache-hit == 'true'
id: release_version
run: |
# Get version from Cargo.toml
RELEASE_VERSION=$(cat Cargo.toml | grep '\[package\]' -A9999 | grep -m 1 'version = ' | tr -d " " | tr -d '"' | tr -d "'" | cut -d = -f 2)
echo "::set-output name=RELEASE_VERSION::$RELEASE_VERSION"
- name: Create tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.release_version.outputs.RELEASE_VERSION }}

- name: Create binary release
if: steps.get_cache.outputs.cache-hit == 'true'
uses: ncipollo/release-action@v1
with:
artifacts: ./release/*.tar.xz
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.release_version.outputs.RELEASE_VERSION }}
tag: ${{ steps.release_version.outputs.RELEASE_VERSION }}

deploy:
name: Deploy
needs: [binary_build]
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main
with:
push_enabled: true
push_destinations: ghcr.io
ghcr_repo_owner: ${{ github.repository_owner }}
ghcr_repo: ${{ github.repository }}
build_with_tmpfs: true
# ====
# Temporarily changed:
# get_version_method: cargo_toml_file_in_repo:file=/Cargo.toml
# ...to...
build_latest: false
build_version_specific: true
get_version_method: file_in_container:file=/IMAGE_VERSION
# This has been done to facilitate testing of the rust release
# See also the project's Dockerfile:38 for where /IMAGE_VERSION is created.
# ====
build_nohealthcheck: false
cache_enabled: true
cache_path: bin/
cache_key: ${{ github.run_id }}
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/hadolint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ on:
branches:
- main
paths:
- 'Dockerfile'
- "Dockerfile"

jobs:

hadolint:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- main
# only run these if markdown files are updated
paths:
- '**.md'
- '**.MD'
- "**.md"
- "**.MD"

jobs:
markdownlint:
Expand Down
Loading

0 comments on commit 3cbf94b

Please sign in to comment.