diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 05560cb8..1ba9e7db 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 @@ -522,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: @@ -538,8 +560,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Restore cached u-root repo uses: actions/cache/restore@v4 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": {}}, } 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}} -~~~ -``` - 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" + ] + } + } +}