From 0e9cd52492da8ae45a50fba96d5b2130bfe6b35d Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Thu, 28 Nov 2024 15:54:25 +0100 Subject: [PATCH] chore: cleanup after moving golang code - change references in docs - update gitignore - update workflows - update Taskfile - hopefully I did not forget anything Signed-off-by: AtomicFS --- .github/dependabot.yml | 2 +- .github/labeler.yml | 24 ++++++++++---------- .github/workflows/example.yml | 4 ++-- .github/workflows/go-test.yml | 11 +++++---- .github/workflows/lint.yml | 2 +- .github/workflows/release-prepare.yml | 2 +- .github/workflows/release.yml | 2 +- .gitignore | 6 ++--- Taskfile.yml | 15 ++++++------ action.yml | 8 +++---- cmd/firmware-action/recipes/coreboot_test.go | 2 +- cmd/firmware-action/recipes/linux_test.go | 2 +- docs/src/firmware-action-example | 2 +- docs/src/firmware-action/config.md | 20 ++++++++-------- docs/src/firmware-action/interactive.md | 2 +- 15 files changed, 53 insertions(+), 51 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 579180c7..4ecc21e9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,7 +24,7 @@ updates: - 'patch' - package-ecosystem: gomod - directory: '/action' + directory: '/cmd/firmware-action' schedule: interval: 'daily' time: '00:00' diff --git a/.github/labeler.yml b/.github/labeler.yml index 61767a4f..13a0d0e5 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -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: @@ -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: @@ -89,7 +89,7 @@ testing: - '.markdownlint.json' - '.mega-linter.yml' - '.trivy.yaml' - - 'action/**/*_test.go' + - 'cmd/firmware-action/**/*_test.go' - 'tests/**' - head-branch: - '^test' diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 2f66f87c..d5e3e012 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -64,7 +64,7 @@ jobs: - 'docker/**' - 'tests/**' - 'action.yml' - - 'action/**' + - 'cmd/firmware-action/**' # Change detection in action golang code changes: @@ -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 diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 0d724e36..5842d8c6 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -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' }} @@ -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: @@ -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)' ./... diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b2e6e613..fe920fe5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -66,4 +66,4 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: latest - working-directory: action + working-directory: cmd/firmware-action diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml index deed353e..416ed7bf 100644 --- a/.github/workflows/release-prepare.yml +++ b/.github/workflows/release-prepare.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 715789e7..04d43a37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.gitignore b/.gitignore index 8b7eb290..be7bbe4e 100644 --- a/.gitignore +++ b/.gitignore @@ -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-* diff --git a/Taskfile.yml b/Taskfile.yml index 76023147..b1ea726a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -2,6 +2,7 @@ version: '3' vars: SEMVER: 'v0.8.1' + GOLANG_CODE_PATH: 'cmd/firmware-action' includes: containers: @@ -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 ./... @@ -39,11 +40,11 @@ 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 @@ -51,7 +52,7 @@ tasks: godocs: desc: Start godocs http server - dir: action + dir: '{{.GOLANG_CODE_PATH}}' cmds: - godoc -http=:6060 diff --git a/action.yml b/action.yml index 7afc55f6..024f6823 100644 --- a/action.yml +++ b/action.yml @@ -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' }} @@ -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' }} diff --git a/cmd/firmware-action/recipes/coreboot_test.go b/cmd/firmware-action/recipes/coreboot_test.go index bf902c9a..8041d092 100644 --- a/cmd/firmware-action/recipes/coreboot_test.go +++ b/cmd/firmware-action/recipes/coreboot_test.go @@ -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) diff --git a/cmd/firmware-action/recipes/linux_test.go b/cmd/firmware-action/recipes/linux_test.go index e0b8480e..29d49486 100644 --- a/cmd/firmware-action/recipes/linux_test.go +++ b/cmd/firmware-action/recipes/linux_test.go @@ -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) diff --git a/docs/src/firmware-action-example b/docs/src/firmware-action-example index faa16e14..75417b32 160000 --- a/docs/src/firmware-action-example +++ b/docs/src/firmware-action-example @@ -1 +1 @@ -Subproject commit faa16e140f96c2ab76e103a4a86ea66530ba9cc0 +Subproject commit 75417b329e4a632528147d15b575f983766913b0 diff --git a/docs/src/firmware-action/config.md b/docs/src/firmware-action/config.md index 7b7fa794..23a9d637 100644 --- a/docs/src/firmware-action/config.md +++ b/docs/src/firmware-action/config.md @@ -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. @@ -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}} ``` diff --git a/docs/src/firmware-action/interactive.md b/docs/src/firmware-action/interactive.md index a162af80..0ec89bde 100644 --- a/docs/src/firmware-action/interactive.md +++ b/docs/src/firmware-action/interactive.md @@ -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}} ~~~ ```