Skip to content

Commit a04aafd

Browse files
committed
docs: add notes about change detection
Signed-off-by: AtomicFS <vojtech.vesely@9elements.com>
1 parent 4d835c2 commit a04aafd

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

cmd/firmware-action/recipes/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func (opts CommonOpts) GetOutputDir() string {
166166
return opts.OutputDir
167167
}
168168

169+
// ANCHOR: CommonOptsGetSources
170+
169171
// GetSources returns slice of paths to all sources which are used for build
170172
func (opts CommonOpts) GetSources() []string {
171173
sources := []string{}
@@ -180,6 +182,8 @@ func (opts CommonOpts) GetSources() []string {
180182
return sources
181183
}
182184

185+
// ANCHOR_END: CommonOptsGetSources
186+
183187
// Config is for storing parsed configuration file
184188
type Config struct {
185189
// defined in coreboot.go

cmd/firmware-action/recipes/coreboot.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ func (opts CorebootOpts) GetArtifacts() *[]container.Artifacts {
7171
return opts.CommonOpts.GetArtifacts()
7272
}
7373

74+
// ANCHOR: CorebootOptsGetSources
75+
7476
// GetSources returns slice of paths to all sources which are used for build
7577
func (opts CorebootOpts) GetSources() []string {
7678
sources := opts.CommonOpts.GetSources()
@@ -109,6 +111,8 @@ func (opts CorebootOpts) GetSources() []string {
109111
return sources
110112
}
111113

114+
// ANCHOR_END: CorebootOptsGetSources
115+
112116
// ProcessBlobs is used to figure out blobs from provided data
113117
func (opts CorebootOpts) ProcessBlobs() ([]BlobDef, error) {
114118
blobs := []BlobDef{}

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- [Build Docker container on the fly](firmware-action/build_dockerfile_on_the_fly.md)
2424
- [Interactive debugging](firmware-action/interactive.md)
2525
- [Offline usage](firmware-action/offline_usage.md)
26+
- [Change detection](firmware-action/change_detection.md)
2627
- [Migration instructions]()
2728
- [Migration from v0.13.x to v0.14.0](firmware-action/migration/v0.13.x--v0.14.0/migrate.md)
2829

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Change detection
2+
3+
firmware-action has basic detection of changes.
4+
5+
Related temporary files to aid in change detection are stored in `.firmware-action/` directory, which is always created in current working directory.
6+
7+
```admonish note
8+
It is save to delete the `.firmware-action/` directory, but keep in mind that change detection depends on its existence.
9+
10+
If `.firmware-action/` directory is deleted, it will be re-created on next firmware-action execution.
11+
12+
It might be advantageous to also include this directory in caches / artifacts when in CI. Preserving these files might reduce run time in the CI.
13+
```
14+
15+
16+
## Sources modification time
17+
18+
When building a module, firmware-action checks recursively all sources for a given module. For all module types, list of sources include repository and all input files.
19+
20+
```admonish example collapsible=true title="Code snippet: Common sources"
21+
~~~golang
22+
{{#include ../../../cmd/firmware-action/recipes/config.go:CommonOptsGetSources}}
23+
~~~
24+
```
25+
26+
Each module type has then additional source files. For example `coreboot`, where list of sources also includes `defconfig` and all the blobs.
27+
```admonish example collapsible=true title="Code snippet: Additional coreboot sources"
28+
~~~golang
29+
{{#include ../../../cmd/firmware-action/recipes/coreboot.go:CorebootOptsGetSources}}
30+
~~~
31+
```
32+
33+
When a module is successfully built, a file containing time stamp is saved to `.firmware-action/timestamps/` directory.
34+
35+
On next run, this file (if exists) is loaded with time stamp of last successful run. Then all sources are recursively checked for any file that was modified since the last successful run. If no file was modified since the loaded time stamp, module is considered up-to-date and build is skipped. If any of the files has newer modified time, module is re-built.
36+
37+
38+
## Configuration file changes
39+
40+
Firmware-action can also detect changes in the configuration file. For each module, on each successful build, it stores a copy of the configuration in `.firmware-action/configs/` directory. On next run, current configuration is compared to configuration of last successful build, and if they differ, module is re-built.

docs/src/firmware-action/features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
- [Interactive mode](./interactive.md)
66
- [Offline usage](./offline_usage.md)
77
- [Recursive builds](./config.md#modules)
8+
- [Change detection](./change_detection.md)
89

0 commit comments

Comments
 (0)