Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: cleanup and add universal #614

Merged
merged 4 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cmd/firmware-action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}},
}
Expand Down
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
111 changes: 111 additions & 0 deletions docs/src/firmware-action/usage_examples.md
Original file line number Diff line number Diff line change
@@ -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}}
~~~
```

54 changes: 0 additions & 54 deletions docs/src/firmware-action/usage_github.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
~~~
```

19 changes: 19 additions & 0 deletions tests/example_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions tests/example_config__universal.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
Loading