Skip to content

Commit

Permalink
chore: cleanup after moving golang code
Browse files Browse the repository at this point in the history
- change references in docs
- update gitignore
- update workflows
- update Taskfile
- hopefully I did not forget anything

Signed-off-by: AtomicFS <vojtech.vesely@9elements.com>
  • Loading branch information
AtomicFS authored and AtomicFS committed Nov 28, 2024
1 parent fa13365 commit 0e9cd52
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ updates:
- 'patch'

- package-ecosystem: gomod
directory: '/action'
directory: '/cmd/firmware-action'
schedule:
interval: 'daily'
time: '00:00'
Expand Down
24 changes: 12 additions & 12 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ dependencies:
- changed-files:
- any-glob-to-any-file:
- '.dagger-ci/daggerci/requirements.txt'
- 'action/go.mod'
- 'action/go.sum'
- 'cmd/firmware-action/go.mod'
- 'cmd/firmware-action/go.sum'
docker:
- any:
- changed-files:
Expand Down Expand Up @@ -37,38 +37,38 @@ go:
- changed-files:
- any-glob-to-any-file:
- '*.go'
- 'action/.golangci.yml'
- 'action/.goreleaser.yaml'
- 'action/go.mod'
- 'action/go.sum'
- 'cmd/firmware-action/.golangci.yml'
- 'cmd/firmware-action/.goreleaser.yaml'
- 'cmd/firmware-action/go.mod'
- 'cmd/firmware-action/go.sum'
module/coreboot:
- any:
- changed-files:
- any-glob-to-any-file:
- 'action/recipes/coreboot*'
- 'cmd/firmware-action/recipes/coreboot*'
- 'docker/coreboot/**'
module/edk2:
- any:
- changed-files:
- any-glob-to-any-file:
- 'action/recipes/edk2*'
- 'cmd/firmware-action/recipes/edk2*'
- 'docker/edk2/**'
module/linux:
- any:
- changed-files:
- any-glob-to-any-file:
- 'action/recipes/linux*'
- 'cmd/firmware-action/recipes/linux*'
- 'docker/linux/**'
module/stitching:
- any:
- changed-files:
- any-glob-to-any-file:
- 'action/recipes/stitching*'
- 'cmd/firmware-action/recipes/stitching*'
module/u-root:
- any:
- changed-files:
- any-glob-to-any-file:
- 'action/recipes/uroot*'
- 'cmd/firmware-action/recipes/uroot*'
- 'docker/uroot/**'
python:
- any:
Expand All @@ -89,7 +89,7 @@ testing:
- '.markdownlint.json'
- '.mega-linter.yml'
- '.trivy.yaml'
- 'action/**/*_test.go'
- 'cmd/firmware-action/**/*_test.go'
- 'tests/**'
- head-branch:
- '^test'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- 'docker/**'
- 'tests/**'
- 'action.yml'
- 'action/**'
- 'cmd/firmware-action/**'
# Change detection in action golang code
changes:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
with:
filters: |
action:
- 'action/**'
- 'cmd/firmware-action/**'
- name: Compile
id: compile
# Require compilation if changes in action golang code or if any breaking changes since last release
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ jobs:
filters: |
changes:
- '.github/workflows/go-test.yml'
- 'action/**'
- 'cmd/firmware-action/**'
go-test-resource-hogs:
# Run tests that take up a lot of system resources separately
runs-on: ubuntu-latest
needs: skip-check
strategy:
fail-fast: false
matrix:
testregex: ['TestLinux', 'TestEdk2', 'TestCoreboot', 'TestStitching', 'TestURoot']
if: ${{ ! (github.event_name == 'pull_request_review' && github.actor != 'github-actions[bot]') && needs.skip-check.outputs.changes == 'true' }}
Expand All @@ -69,11 +70,11 @@ jobs:
go-version: stable
- name: Install go dependencies
run: |
cd action
cd cmd/firmware-action
go get -d ./...
- name: Run go test
run: |
cd action
cd cmd/firmware-action
go test -race -v -timeout 60m -shuffle=on -covermode=atomic -coverprofile coverage.out -run ${{ matrix.testregex }} ./...
go-test:
Expand All @@ -91,9 +92,9 @@ jobs:
go-version: stable
- name: Install go dependencies
run: |
cd action
cd cmd/firmware-action
go get -d ./...
- name: Run go test
run: |
cd action
cd cmd/firmware-action
go test -race -v -timeout 60m -shuffle=on -covermode=atomic -coverprofile coverage.out -skip '(TestLinux|TestEdk2|TestCoreboot|TestStitching)' ./...
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: action
working-directory: cmd/firmware-action
2 changes: 1 addition & 1 deletion .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# Bump version
- name: Update main.go
run: |
sed -i -E 's/const firmwareActionVersion = .*/const firmwareActionVersion = "${{ steps.semver.outputs.next }}"/g' action/main.go
sed -i -E 's/const firmwareActionVersion = .*/const firmwareActionVersion = "${{ steps.semver.outputs.next }}"/g' cmd/firmware-action/main.go
- name: Update Taskfile.yml
run: |
sed -i -E "s/^ SEMVER: .*/ SEMVER: '${{ steps.semver.outputs.next }}'/g" Taskfile.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: |
git branch --show-current
git pull
echo "version=$(grep 'const firmwareActionVersion' < action/main.go | sed -E 's/.*= "//g' | sed 's/"//g')" >> "${GITHUB_OUTPUT}"
echo "version=$(grep 'const firmwareActionVersion' < cmd/firmware-action/main.go | sed -E 's/.*= "//g' | sed 's/"//g')" >> "${GITHUB_OUTPUT}"
# Can't really use cocogitto here
- name: Create tag
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.coverage
.task
.example_runs
action/coverage.html
action/coverage.out
cmd/firmware-action/coverage.html
cmd/firmware-action/coverage.out
bin/
megalinter-reports
node_modules
action/recipes/__tmp_files__/
cmd/firmware-action/recipes/__tmp_files__/
output-*/
docker/coreboot/coreboot-*
15 changes: 8 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
version: '3'
vars:
SEMVER: 'v0.8.1'
GOLANG_CODE_PATH: 'cmd/firmware-action'

includes:
containers:
Expand All @@ -17,19 +18,19 @@ includes:
tasks:
build-go-binary:
desc: Template task to build a go binary
dir: action
dir: '{{.GOLANG_CODE_PATH}}'
cmds:
- go build -ldflags="-s -w" -o ../bin/firmware-action-{{OS}}-{{ARCH}}-{{.SEMVER}}
- go build -ldflags="-s -w" -o ../../bin/firmware-action-{{OS}}-{{ARCH}}-{{.SEMVER}}
env:
CGO_ENABLED: 0
sources:
- ./**/*.go
generates:
- ../bin/firmware-action-{{OS}}-{{ARCH}}-{{.SEMVER}}
- ../../bin/firmware-action-{{OS}}-{{ARCH}}-{{.SEMVER}}

lint:
desc: Run the linters
dir: action
dir: '{{.GOLANG_CODE_PATH}}'
cmds:
- revive ./...
- go vet ./...
Expand All @@ -39,19 +40,19 @@ tasks:
format:
desc: Run gofumt (fork of gofmt, stricter)
cmds:
- gofumpt -w action
- gofumpt -w '{{.GOLANG_CODE_PATH}}'

test:
desc: Run tests
dir: action
dir: '{{.GOLANG_CODE_PATH}}'
cmds:
- go test {{.CLI_ARGS}} -race -timeout 60m -shuffle=on -covermode=atomic -coverprofile coverage.out ./...
- go tool cover -func=coverage.out
- go tool cover -html=coverage.out -o coverage.html

godocs:
desc: Start godocs http server
dir: action
dir: '{{.GOLANG_CODE_PATH}}'
cmds:
- godoc -http=:6060

Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ runs:
- name: compile_unix
if: ${{ ( runner.os == 'Linux' || runner.os == 'macOS' ) && inputs.compile == 'true' }}
shell: bash
working-directory: ./action
working-directory: ./cmd/firmware-action
run: |
go build -ldflags="-s -w" -o ../firmware-action
go build -ldflags="-s -w" -o ../../firmware-action
- id: fetch_windows
if: ${{ runner.os == 'Windows' && inputs.compile == 'false' }}
Expand All @@ -106,9 +106,9 @@ runs:
- name: compile_windows
if: ${{ runner.os == 'Windows' && inputs.compile == 'true' }}
shell: pwsh
working-directory: ./action
working-directory: ./cmd/firmware-action
run: |
go build -ldflags="-s -w" -o ../firmware-action.exe
go build -ldflags="-s -w" -o ../../firmware-action.exe
- name: run_unix
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
Expand Down
2 changes: 1 addition & 1 deletion cmd/firmware-action/recipes/coreboot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestCoreboot(t *testing.T) {
assert.NoError(t, err)

// Copy over defconfig file into tmpDir
repoRootPath, err := filepath.Abs(filepath.Join(pwd, "../.."))
repoRootPath, err := filepath.Abs(filepath.Join(pwd, "../../.."))
assert.NoError(t, err)
// repoPath = path to end user repository (in this case somewhere in /tmp)
// repoRootPath = path to our repository with this code (contains configuration files for testing)
Expand Down
2 changes: 1 addition & 1 deletion cmd/firmware-action/recipes/linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestLinux(t *testing.T) {

// Copy over defconfig file into tmpDir/linux
defconfigPath := filepath.Join(myLinuxOpts.RepoPath, myLinuxOpts.DefconfigPath)
repoRootPath, err := filepath.Abs(filepath.Join(pwd, "../.."))
repoRootPath, err := filepath.Abs(filepath.Join(pwd, "../../.."))
assert.NoError(t, err)
// common.RepoPath = path to end user repository (in this case somewhere in /tmp)
// repoRootPath = path to our repository with this code (contains configuration files for testing)
Expand Down
20 changes: 10 additions & 10 deletions docs/src/firmware-action/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Each module has sections:
- `specific`

```go
{{#include ../../../action/recipes/coreboot.go:CorebootOpts}}
{{#include ../../../cmd/firmware-action/recipes/coreboot.go:CorebootOpts}}
```

`common` & `specific` are identical in function. There is no real difference between these two. They are split to simplify the code. They define things like path to source code, version and source of SDK to use, and so on.
Expand Down Expand Up @@ -113,30 +113,30 @@ For more tails see [go-playground/validator](https://github.com/go-playground/va

### Common
```go
{{#include ../../../action/recipes/config.go:CommonOpts}}
{{#include ../../../cmd/firmware-action/recipes/config.go:CommonOpts}}
```

### Specific / coreboot
```go
{{#include ../../../action/recipes/coreboot.go:CorebootOpts}}
{{#include ../../../action/recipes/coreboot.go:CorebootBlobs}}
{{#include ../../../cmd/firmware-action/recipes/coreboot.go:CorebootOpts}}
{{#include ../../../cmd/firmware-action/recipes/coreboot.go:CorebootBlobs}}
```

### Specific / Linux
```go
{{#include ../../../action/recipes/linux.go:LinuxOpts}}
{{#include ../../../action/recipes/linux.go:LinuxSpecific}}
{{#include ../../../cmd/firmware-action/recipes/linux.go:LinuxOpts}}
{{#include ../../../cmd/firmware-action/recipes/linux.go:LinuxSpecific}}
```

### Specific / Edk2
```go
{{#include ../../../action/recipes/edk2.go:Edk2Opts}}
{{#include ../../../action/recipes/edk2.go:Edk2Specific}}
{{#include ../../../cmd/firmware-action/recipes/edk2.go:Edk2Opts}}
{{#include ../../../cmd/firmware-action/recipes/edk2.go:Edk2Specific}}
```

### Specific / Firmware stitching
```go
{{#include ../../../action/recipes/stitching.go:FirmwareStitchingOpts}}
{{#include ../../../action/recipes/stitching.go:IfdtoolEntry}}
{{#include ../../../cmd/firmware-action/recipes/stitching.go:FirmwareStitchingOpts}}
{{#include ../../../cmd/firmware-action/recipes/stitching.go:IfdtoolEntry}}
```

2 changes: 1 addition & 1 deletion docs/src/firmware-action/interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To start a `ssh` service and wait for user to log-in, the container has to be co
As a workaround, when the evaluation of pipeline fails in the container, the container from previous step is converted into a `service` container with everything as it was just before the failing command was executed. In essence, when you connect, you end up in pristine environment.
~~~go
{{#include ../../../action/container/ssh.go:ContainerAsService}}
{{#include ../../../cmd/firmware-action/container/ssh.go:ContainerAsService}}
~~~
```

0 comments on commit 0e9cd52

Please sign in to comment.