Skip to content

Commit

Permalink
Adjust CI workflows to use the Rust codebase (#7)
Browse files Browse the repository at this point in the history
* Use Cargo in Build & Test CI jobs

Signed-off-by: Atanas Dinov <[email protected]>

* Use Cargo in Release CI job

Signed-off-by: Atanas Dinov <[email protected]>

* Enforce stricter lint rules

Signed-off-by: Atanas Dinov <[email protected]>

* Update Cargo.toml

Signed-off-by: Atanas Dinov <[email protected]>

* Ignore tags in Build & Test CI workflow

Signed-off-by: Atanas Dinov <[email protected]>

* Replace standard compilation with a container build

While built-in cargo compilation is much faster (especially when targetting aarch64), using the latest Ubuntu version causes incompatible (in the short term) and unreliable (in the long term) builds causing issues for the targeted SUSE distros - Leap / SLE Micro.

Signed-off-by: Atanas Dinov <[email protected]>

---------

Signed-off-by: Atanas Dinov <[email protected]>
  • Loading branch information
atanasdinov authored Nov 10, 2023
1 parent f3aba85 commit f41669d
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 23 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
on: [push, pull_request]
on:
pull_request:
push:
branches:
- "*"

name: Build & Test

env:
CARGO_TERM_COLOR: always

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Format
run: cargo fmt --all -- --check
- name: Lint
run: cargo clippy --all-targets --all-features -- -D warnings
build:
runs-on: ubuntu-latest
needs: [ lint ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Build
run: go build -v ./...
run: cargo build
- name: Test
run: go test -v ./...
run: cargo test --no-fail-fast
env:
RUST_LOG: debug
33 changes: 20 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@ name: Release
permissions:
contents: write

env:
CARGO_TERM_COLOR: always

jobs:
build:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Run tests
run: go test -v ./...
- name: Build binaries
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build x86_64 binary
run: |
docker build -t nmc:amd64 --platform linux/amd64 .
container_id=$(docker create nmc:amd64 --entrypoint /)
docker cp $container_id:/target/release/nmc nmc-x86_64
- name: Build aarch64 binary
run: |
GOOS=linux GOARCH=arm64 go build -o nm-configurator-arm64 main.go
GOOS=linux GOARCH=amd64 go build -o nm-configurator-amd64 main.go
- name: Create a release
docker build -t nmc:arm64 --platform linux/arm64 .
container_id=$(docker create nmc:arm64 --entrypoint /)
docker cp $container_id:/target/release/nmc nmc-aarch64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
nm-configurator-arm64
nm-configurator-amd64
nmc-aarch64
nmc-x86_64
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name = "nmc"
version = "0.1.0"
edition = "2021"
authors = ["Atanas Dinov <[email protected]>"]
license = "Apache-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM registry.suse.com/bci/rust:1.73

COPY . /
WORKDIR /

RUN cargo build --release --config net.git-fetch-with-cli=true
2 changes: 1 addition & 1 deletion testdata/generate/expected/bridge0.nmconnection
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ addr-gen-mode=0
method=link-local

[ethernet]
cloned-mac-address=FE:C4:05:42:8B:AA
cloned-mac-address=FE:C4:05:42:8B:AA
2 changes: 1 addition & 1 deletion testdata/generate/expected/eth0.nmconnection
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ method=link-local

[ethernet]
auto-negotiate=false
cloned-mac-address=0E:4D:C6:B8:C4:72
cloned-mac-address=0E:4D:C6:B8:C4:72
2 changes: 1 addition & 1 deletion testdata/generate/expected/lo.nmconnection
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ method=manual
[ipv6]
addr-gen-mode=0
address0=::1/128
method=manual
method=manual

0 comments on commit f41669d

Please sign in to comment.