From 377b10b980318a985f7bc7f7e87b2f6c9b1cb112 Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Tue, 11 Mar 2025 12:11:26 +0100 Subject: [PATCH 1/4] fix(cmd): generate-config u-boot was empty Signed-off-by: AtomicFS --- cmd/firmware-action/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/firmware-action/main.go b/cmd/firmware-action/main.go index 6f3129cc..2eda5600 100644 --- a/cmd/firmware-action/main.go +++ b/cmd/firmware-action/main.go @@ -235,9 +235,10 @@ func parseCli() (string, error) { // Create empty config myConfig := recipes.Config{ Coreboot: map[string]recipes.CorebootOpts{"coreboot-example": {}}, - Linux: map[string]recipes.LinuxOpts{"linux-example": {}}, Edk2: map[string]recipes.Edk2Opts{"edk2-example": {}}, FirmwareStitching: map[string]recipes.FirmwareStitchingOpts{"stitching-example": {}}, + Linux: map[string]recipes.LinuxOpts{"linux-example": {}}, + UBoot: map[string]recipes.UBootOpts{"uboot-example": {}}, URoot: map[string]recipes.URootOpts{"uroot-example": {}}, Universal: map[string]recipes.UniversalOpts{"universal-example": {}}, } From d037bf9d3418f5565dfce5bcab2c8e4f211b2de9 Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Tue, 11 Mar 2025 12:17:48 +0100 Subject: [PATCH 2/4] fix(example): use shallow fetch Signed-off-by: AtomicFS --- .github/workflows/example.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 05560cb8..58bb10f6 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -131,8 +131,6 @@ jobs: rm -rf ./.??* || true - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached coreboot repo uses: actions/cache/restore@v4 @@ -198,8 +196,6 @@ jobs: rm -rf ./.??* || true - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached linux source id: cache-repo @@ -275,8 +271,6 @@ jobs: rm -rf ./.??* || true - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached edk2 repo uses: actions/cache/restore@v4 @@ -356,8 +350,6 @@ jobs: rm -rf ./.??* || true - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached coreboot-blobs repo uses: actions/cache/restore@v4 @@ -416,8 +408,6 @@ jobs: rm -rf ./.??* || true - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached u-root repo uses: actions/cache/restore@v4 @@ -476,8 +466,6 @@ jobs: rm -rf ./.??* || true - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached u-boot repo uses: actions/cache/restore@v4 @@ -538,8 +526,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached u-root repo uses: actions/cache/restore@v4 From a31649caf573ff8f3aa273bd6a14cacfaab7400c Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Tue, 11 Mar 2025 12:19:09 +0100 Subject: [PATCH 3/4] test: add universal module into examples Signed-off-by: AtomicFS --- .github/workflows/example.yml | 34 ++++++++++++++++++++++++++++ tests/example_config.json | 19 ++++++++++++++++ tests/example_config__universal.json | 21 +++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 tests/example_config__universal.json diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 58bb10f6..1ba9e7db 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -510,6 +510,40 @@ jobs: retention-days: 14 # ANCHOR_END: example_build_uboot + # Example of using universal module + # ANCHOR: example_build_universal + build-universal: + needs: + - changes + - skip-check + runs-on: ubuntu-latest + if: ${{ ! (github.event_name == 'pull_request_review' && github.actor != 'github-actions[bot]') && needs.skip-check.outputs.changes == 'true' }} + # Skip if pull_request_review on PR not made by a bot + steps: + - name: Cleanup + run: | + rm -rf ./* || true + rm -rf ./.??* || true + - name: Checkout + uses: actions/checkout@v4 + + - name: firmware-action + uses: ./ + # uses: 9elements/firmware-action + with: + config: 'tests/example_config__universal.json' + target: 'universal-example' + recursive: 'false' + compile: ${{ needs.changes.outputs.compile }} + + - name: Get artifacts + uses: actions/upload-artifact@v4 + with: + name: universal + path: output-universal + retention-days: 14 + # ANCHOR_END: example_build_universal + # Example of running on non-Linux systems test-operating-systems: strategy: diff --git a/tests/example_config.json b/tests/example_config.json index 2516fece..ac5bc731 100644 --- a/tests/example_config.json +++ b/tests/example_config.json @@ -97,6 +97,25 @@ "input_files": null } }, + "universal": { + "universal-example": { + "depends": null, + "sdk_url": "golang:latest", + "repo_path": "./", + "container_output_dirs": null, + "container_output_files": [ + "test.txt" + ], + "output_dir": "output-universal/", + "input_dirs": null, + "input_files": null, + "container_input_dir": "inputs/", + "build_commands": [ + "echo 'hello world'", + "touch test.txt" + ] + } + }, "u-root": { "u-root-example": { "depends": null, diff --git a/tests/example_config__universal.json b/tests/example_config__universal.json new file mode 100644 index 00000000..192ffdb8 --- /dev/null +++ b/tests/example_config__universal.json @@ -0,0 +1,21 @@ +{ + "universal": { + "universal-example": { + "depends": null, + "sdk_url": "golang:latest", + "repo_path": "./", + "container_output_dirs": null, + "container_output_files": [ + "test.txt" + ], + "output_dir": "output-universal/", + "input_dirs": null, + "input_files": null, + "container_input_dir": "inputs/", + "build_commands": [ + "echo 'hello world'", + "touch test.txt" + ] + } + } +} From 98be3d25d4a4e60bb601385d5344c65d10ae4341 Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Tue, 11 Mar 2025 12:22:00 +0100 Subject: [PATCH 4/4] docs: move examples into separate section - also add missing modules such as u-boot, u-root and universal Signed-off-by: AtomicFS --- docs/src/SUMMARY.md | 1 + docs/src/firmware-action/usage_examples.md | 111 +++++++++++++++++++++ docs/src/firmware-action/usage_github.md | 54 ---------- 3 files changed, 112 insertions(+), 54 deletions(-) create mode 100644 docs/src/firmware-action/usage_examples.md diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 736be630..0c0d5da5 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -17,6 +17,7 @@ - [TLDR; Usage](firmware-action/usage.md) - [Local system](firmware-action/usage_local.md) - [GitHub CI](firmware-action/usage_github.md) + - [Examples](firmware-action/usage_examples.md) - [Configuration](firmware-action/config.md) - [Troubleshooting](firmware-action/troubleshooting.md) - [Tips and Tricks](firmware-action/tips.md) diff --git a/docs/src/firmware-action/usage_examples.md b/docs/src/firmware-action/usage_examples.md new file mode 100644 index 00000000..364ef3bd --- /dev/null +++ b/docs/src/firmware-action/usage_examples.md @@ -0,0 +1,111 @@ +# Examples + +There is a separate directory with examples called [firmware-action-example](https://github.com/9elements/firmware-action-example/). It is a great source of information to get started. + +In addition, the main repository also contains multiple examples (even though rather simple ones) defined in [.github/workflows/example.yml](https://github.com/9elements/firmware-action/blob/main/.github/workflows/example.yml). These are there to function as tests to verify the functionality, as such they are made with this specific task in mind. Please take that into account when going though them. + + +## Coreboot + +```admonish example collapsible=true title="Coreboot - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_coreboot}} +~~~ +``` + +```admonish example collapsible=true title="Coreboot - Configuration file" +~~~json +{{#include ../../../tests/example_config__coreboot.json}} +~~~ +``` + + +## Linux Kernel + +```admonish example collapsible=true title="Linux Kernel - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_linux_kernel}} +~~~ +``` + +```admonish example collapsible=true title="Linux Kernel - Configuration file" +~~~json +{{#include ../../../tests/example_config__linux.json}} +~~~ +``` + + +## Edk2 + +```admonish example collapsible=true title="Edk2 - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_edk2}} +~~~ +``` + +```admonish example collapsible=true title="Edk2 - Configuration file" +~~~json +{{#include ../../../tests/example_config__edk2.json}} +~~~ +``` + + +## Firmware Stitching + +```admonish example collapsible=true title="Firmware Stitching - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_stitch}} +~~~ +``` + +```admonish example collapsible=true title="Firmware Stitching - Configuration file" +~~~json +{{#include ../../../tests/example_config__firmware_stitching.json}} +~~~ +``` + + +## u-root + +```admonish example collapsible=true title="u-root - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_uroot}} +~~~ +``` + +```admonish example collapsible=true title="u-root - Configuration file" +~~~json +{{#include ../../../tests/example_config__uroot.json}} +~~~ +``` + + +## u-boot + +```admonish example collapsible=true title="u-boot - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_uboot}} +~~~ +``` + +```admonish example collapsible=true title="u-boot - Configuration file" +~~~json +{{#include ../../../tests/example_config__uboot.json}} +~~~ +``` + + +## Universal + +```admonish example collapsible=true title="Universal - GitHub CI" +~~~yaml +{{#include ../../../.github/workflows/example.yml:example_build_universal}} +~~~ +``` + +```admonish example collapsible=true title="Universal - Configuration file" +~~~json +{{#include ../../../tests/example_config__universal.json}} +~~~ +``` + diff --git a/docs/src/firmware-action/usage_github.md b/docs/src/firmware-action/usage_github.md index e9b47bd5..715c5274 100644 --- a/docs/src/firmware-action/usage_github.md +++ b/docs/src/firmware-action/usage_github.md @@ -55,57 +55,3 @@ jobs: COREBOOT_VERSION: ${{ matrix.coreboot_version }} ~~~ ``` - - -## Examples - -In our repository we have multiple examples (even though rather simple ones) defined in [.github/workflows/example.yml](https://github.com/9elements/firmware-action/blob/main/.github/workflows/example.yml). - -```admonish example collapsible=true title="Coreboot" -`.github/workflows/example.yml`: -~~~yaml -{{#include ../../../.github/workflows/example.yml:example_build_coreboot}} -~~~ - -`tests/example_config__coreboot.json`: -~~~json -{{#include ../../../tests/example_config__coreboot.json}} -~~~ -``` - -```admonish example collapsible=true title="Linux Kernel" -`.github/workflows/example.yml`: -~~~yaml -{{#include ../../../.github/workflows/example.yml:example_build_linux_kernel}} -~~~ - -`tests/example_config__linux.json`: -~~~json -{{#include ../../../tests/example_config__linux.json}} -~~~ -``` - -```admonish example collapsible=true title="Edk2" -`.github/workflows/example.yml`: -~~~yaml -{{#include ../../../.github/workflows/example.yml:example_build_edk2}} -~~~ - -`tests/example_config__edk2.json`: -~~~json -{{#include ../../../tests/example_config__edk2.json}} -~~~ -``` - -```admonish example collapsible=true title="Firmware Stitching" -`.github/workflows/example.yml`: -~~~yaml -{{#include ../../../.github/workflows/example.yml:example_build_stitch}} -~~~ - -`tests/example_config__firmware_stitching.json`: -~~~json -{{#include ../../../tests/example_config__firmware_stitching.json}} -~~~ -``` -