Skip to content

Commit

Permalink
Fix build scripts etc..
Browse files Browse the repository at this point in the history
- Fix build scripts
- Update parts of doc
- Add cache
  • Loading branch information
argerus committed Mar 20, 2024
1 parent 032eca7 commit b06f75c
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**/target/

9 changes: 6 additions & 3 deletions .github/workflows/check_license.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
name: spdx
name: Check SPDX headers

on:
pull_request
pull_request:
workflow_call:


concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
check-spdx-headers:
name: Check SPDX headers

runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down
46 changes: 30 additions & 16 deletions .github/workflows/kuksa_databroker-cli_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/

name: kuksa_databroker-cli_build
name: Build kuksa-databroker-cli

on:
push:
Expand All @@ -32,33 +32,50 @@ concurrency:

jobs:
lint:
name: Linting
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: databroker-cli-lint-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: cargo fmt
working-directory: ${{github.workspace}}
run: cargo fmt -- --check
- name: cargo clippy
working-directory: ${{github.workspace}}
run: cargo clippy --all-targets -- -W warnings -D warnings

check_ghcr_push:
name: Check access rights
uses: eclipse-kuksa/kuksa-actions/.github/workflows/check_ghcr_push.yml@2
secrets: inherit

# Run on selfhosted, because our runner has native ARM build in a remote
# builder (no need for qemu)
build-container:
name: Build multiarch container
runs-on: ubuntu-latest
needs: check_ghcr_push

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: databroker-cli-release-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: Building
working-directory: ${{github.workspace}}/
run: |
Expand All @@ -71,7 +88,7 @@ jobs:
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/eclipse-kuksa/kuksa-databrokerdatabroker-cli
ghcr.io/eclipse-kuksa/kuksa-databroker-cli
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
Expand All @@ -80,9 +97,6 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -95,7 +109,7 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build kuksa.val databroker CLI container and push to ghcr.io (and ttl.sh)
- name: Build kuksa-databroker-cli container and push to ghcr.io (and ttl.sh)
id: ghcr-build
if: needs.check_ghcr_push.outputs.push == 'true'
uses: docker/build-push-action@v5
Expand All @@ -109,13 +123,13 @@ jobs:
push: true
tags: |
${{ steps.meta.outputs.tags }}
ttl.sh/kuksa.val/kuksa-databroker-cli-${{github.sha}}
ttl.sh/eclipse-kuksa/kuksa-databroker-cli-${{github.sha}}
labels: ${{ steps.meta.outputs.labels }}
# Provenance to solve that an unknown/unkown image is shown on ghcr.io
# Same problem as described in https://github.com/orgs/community/discussions/45969
provenance: false

- name: Build ephemeral KUKSA Databroker container and push to ttl.sh
- name: Build ephemeral kuksa-databroker-cli container and push to ttl.sh
if: needs.check_ghcr_push.outputs.push == 'false'
id: tmp-build
uses: docker/build-push-action@v5
Expand All @@ -127,7 +141,7 @@ jobs:
file: ./Dockerfile-cli
context: .
push: true
tags: "ttl.sh/kuksa.val/kuksa-databroker-cli-${{github.sha}}"
tags: "ttl.sh/eclipse-kuksa/kuksa-databroker-cli-${{github.sha}}"
labels: ${{ steps.meta.outputs.labels }}
# Provenance to solve that an unknown/unkown image is shown on ghcr.io
# Same problem as described in https://github.com/orgs/community/discussions/45969
Expand All @@ -137,7 +151,7 @@ jobs:
- name: Posting message
uses: ./.github/actions/post-container-location
with:
image: ttl.sh/kuksa.val/kuksa-databroker-cli-${{github.sha}}
image: ttl.sh/eclipse-kuksa/kuksa-databroker-cli-${{github.sha}}

- name: "Archiving AMD64 artifacts"
uses: actions/upload-artifact@v4
Expand All @@ -159,7 +173,7 @@ jobs:


bom:
name: Bill of Material Check
name: Check Bill of Material
runs-on: ubuntu-latest
needs: build-container

Expand Down
100 changes: 58 additions & 42 deletions .github/workflows/kuksa_databroker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/

name: kuksa_databroker_build
name: Build kuksa-databroker

on:
push:
branches: [ master ]
pull_request:
paths:
- ".github/workflows/kuksa_databroker_build.yml"
- "**"
- "proto/**"
- "Cargo.*"
- "Cross.toml"
workflow_call:
workflow_dispatch:

Expand All @@ -31,25 +25,26 @@ concurrency:
cancel-in-progress: true

jobs:
lint-and-test:
name: Linting and Testing
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Seems not neccessary on ubuntu-latest runner
#- uses: dtolnay/rust-toolchain@stable

- name: "Install cargo modules"
run: cargo install cargo-tarpaulin

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: databroker-lint-${{ hashFiles('**/Cargo.lock') }}
- name: Show toolchain information
working-directory: ${{github.workspace}}
run: |
rustup toolchain list
cargo --version
- name: cargo fmt
working-directory: ${{github.workspace}}
run: cargo fmt -- --check
Expand All @@ -60,6 +55,29 @@ jobs:
working-directory: ${{github.workspace}}
run: cargo clippy --features viss --all-targets -- -W warnings -D warnings

test:
name: Unit tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: databroker-test-${{ hashFiles('**/Cargo.lock') }}
- name: Show toolchain information
working-directory: ${{github.workspace}}
run: |
rustup toolchain list
cargo --version
- name: Install cargo tarpaulin (unless already installed)
run: |
which cargo-tarpaulin || cargo install cargo-tarpaulin
- name: Run tests and report code coverage
run: |
cargo tarpaulin -o xml \
Expand All @@ -80,29 +98,34 @@ jobs:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# minimum_coverage: 40



check_ghcr_push:
name: Check access rights
uses: eclipse-kuksa/kuksa-actions/.github/workflows/check_ghcr_push.yml@2
secrets: inherit

build-container:
name: Build multiarch container
runs-on: ubuntu-latest

needs: check_ghcr_push

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
submodules: recursive

- name: Building
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: databroker-release-${{ hashFiles('**/Cargo.lock') }}
- name: Build
working-directory: ${{github.workspace}}/
run: |
cargo install cargo-license cross
./build-all-targets.sh
- name: Docker meta
- name: Set container metadata
id: meta
uses: docker/metadata-action@v5
with:
Expand All @@ -117,11 +140,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# only needed for runners without buildx setup, will be slow
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -133,7 +152,7 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build kuksa.val databroker container container and push to ghcr.io (and ttl.sh)
- name: Build kuksa-databroker container and push to ghcr.io (and ttl.sh)
id: ghcr-build
if: needs.check_ghcr_push.outputs.push == 'true'
uses: docker/build-push-action@v5
Expand All @@ -147,13 +166,13 @@ jobs:
push: true
tags: |
${{ steps.meta.outputs.tags }}
ttl.sh/kuksa.val/kuksa-databroker-${{github.sha}}
ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}}
labels: ${{ steps.meta.outputs.labels }}
# Provenance to solve that an unknown/unkown image is shown on ghcr.io
# Same problem as described in https://github.com/orgs/community/discussions/45969
provenance: false

- name: Build ephemeral KUKSA Databroker container and push to ttl.sh
- name: Build ephemeral kuksa-databroker container and push to ttl.sh
if: needs.check_ghcr_push.outputs.push == 'false'
id: tmp-build
uses: docker/build-push-action@v5
Expand All @@ -165,7 +184,7 @@ jobs:
file: ./Dockerfile
context: .
push: true
tags: "ttl.sh/kuksa.val/kuksa-databroker-${{github.sha}}"
tags: "ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}}"
labels: ${{ steps.meta.outputs.labels }}
# Provenance to solve that an unknown/unkown image is shown on ghcr.io
# Same problem as described in https://github.com/orgs/community/discussions/45969
Expand All @@ -174,7 +193,7 @@ jobs:
- name: Posting message
uses: ./.github/actions/post-container-location
with:
image: ttl.sh/kuksa.val/kuksa-databroker-${{github.sha}}
image: ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}}

- name: "Archiving AMD64 artifacts"
uses: actions/upload-artifact@v4
Expand All @@ -201,42 +220,39 @@ jobs:
needs: [build-container]

steps:

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- uses: actions/checkout@v4

- name: Run integration test on AMD64 container
env:
DATABROKER_IMAGE: ttl.sh/kuksa.val/kuksa-databroker-${{github.sha}}
DATABROKER_IMAGE: ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}}
CONTAINER_PLATFORM: linux/amd64
run: |
${{github.workspace}}/integration_test/run.sh
- name: Run integration test on ARM64 container
env:
DATABROKER_IMAGE: ttl.sh/kuksa.val/kuksa-databroker-${{github.sha}}
DATABROKER_IMAGE: ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}}
CONTAINER_PLATFORM: linux/arm64
run: |
${{github.workspace}}/integration_test/run.sh
- name: Run integration test on RISCV64 container
env:
DATABROKER_IMAGE: ttl.sh/kuksa.val/kuksa-databroker-${{github.sha}}
DATABROKER_IMAGE: ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}}
CONTAINER_PLATFORM: linux/riscv64
run: |
${{github.workspace}}/integration_test/run.sh
bom:
name: Bill of Material Check
name: Check Bill of Material
runs-on: ubuntu-latest
needs: build-container

steps:
- uses: actions/checkout@v4

- name: "Createbom: License check and Dash output generation"
- name: "License check and Dash output generation"
working-directory: ${{github.workspace}}/createbom
run: |
cargo install cargo-license
Expand Down
Loading

0 comments on commit b06f75c

Please sign in to comment.