From 649f074d257c451d7759590605304cc9a75d29d7 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Wed, 6 Dec 2023 14:42:18 +0000 Subject: [PATCH 1/2] Update Project Changes: - ci: Add a workflow for Forgejo Actions - docs: Update README.asciidoc - tests: add a mage target for running tests --- .forgejo/workflows/workflow.yaml | 37 ++++++++++++++++++++++++++++++++ README.asciidoc | 22 +++++++++++-------- magefiles/mage.go | 19 ++++++++++++++++ magefiles/main.go | 13 +++++++++++ 4 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 .forgejo/workflows/workflow.yaml create mode 100644 magefiles/main.go diff --git a/.forgejo/workflows/workflow.yaml b/.forgejo/workflows/workflow.yaml new file mode 100644 index 0000000..dbe6a92 --- /dev/null +++ b/.forgejo/workflows/workflow.yaml @@ -0,0 +1,37 @@ +--- +on: + pull_request: + types: + - opened + - reopened + - synchronize + +jobs: + test: + runs-on: docker + env: + GO_TEST_VERBOSE: "1" + GO_TEST_COVER: "1" + steps: + - name: Checkout Repository + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Setup Go + uses: https://code.forgejo.org/actions/setup-go@v4 + with: + go-version: '1.21' + - name: Test + run: go run magefiles/main.go -v test + + lint: + runs-on: docker + steps: + - name: Checkout Repository + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Setup Go + uses: https://code.forgejo.org/actions/setup-go@v4 + with: + go-version: '1.21' + - name: Lint + uses: https://github.com/golangci/golangci-lint-action@v3 + with: + version: v1.54 diff --git a/README.asciidoc b/README.asciidoc index 229e1cf..85c7454 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -110,20 +110,24 @@ Run `spruce` to verify your installation. You should see the usage printed onto [source,console] ---- $ spruce -A tool for building CVs +SUMMARY: + spruce - A command-line tool for building CVs -Usage: +VERSION: + v0.3.0 + +USAGE: spruce [flags] spruce [command] -Available Commands: - create create a new CV JSON file - generate generate a PDF file from an existing CV JSON file - version print the application's build information +COMMANDS: + create creates a new CV JSON file + generate generates a PDF file from an existing CV JSON file + version print the application's version and build information -Flags: - -h, --help - print the help message for spruce +FLAGS: + -help, --help + print the help message Use "spruce [command] --help" for more information about a command. ---- diff --git a/magefiles/mage.go b/magefiles/mage.go index f876690..e1d0f39 100644 --- a/magefiles/mage.go +++ b/magefiles/mage.go @@ -19,6 +19,25 @@ var ( defaultInstallPrefix = "/usr/local" ) +// Test run the go tests. +// To enable verbose mode set SPRUCE_TEST_VERBOSE=1. +// To enable coverage mode set SPRUCE_TEST_COVER=1. +func Test() error { + goTest := sh.RunCmd("go", "test") + + args := []string{"./..."} + + if os.Getenv("SPRUCE_TEST_VERBOSE") == "1" { + args = append(args, "-v") + } + + if os.Getenv("SPRUCE_TEST_COVER") == "1" { + args = append(args, "-cover") + } + + return goTest(args...) +} + // Lint runs golangci-lint against the code. func Lint() error { return sh.RunV("golangci-lint", "run", "--color", "always") diff --git a/magefiles/main.go b/magefiles/main.go new file mode 100644 index 0000000..8883df9 --- /dev/null +++ b/magefiles/main.go @@ -0,0 +1,13 @@ +//go:build ignore + +package main + +import ( + "os" + + "github.com/magefile/mage/mage" +) + +func main() { + os.Exit(mage.Main()) +} -- 2.45.2 From b2ce85b1460aa97a8cad66056b9c19f6d300f62e Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Wed, 6 Dec 2023 14:48:20 +0000 Subject: [PATCH 2/2] ci(fix): update environment variables --- .forgejo/workflows/workflow.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/workflow.yaml b/.forgejo/workflows/workflow.yaml index dbe6a92..8dead88 100644 --- a/.forgejo/workflows/workflow.yaml +++ b/.forgejo/workflows/workflow.yaml @@ -10,8 +10,8 @@ jobs: test: runs-on: docker env: - GO_TEST_VERBOSE: "1" - GO_TEST_COVER: "1" + SPRUCE_TEST_VERBOSE: "1" + SPRUCE_TEST_COVER: "1" steps: - name: Checkout Repository uses: https://code.forgejo.org/actions/checkout@v3 -- 2.45.2