Skip to content
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
69 changes: 69 additions & 0 deletions .github/workflows/qa-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: QA Checks

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
go:
name: Go checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Verify go.mod is tidy
run: |
go mod tidy
if ! git diff --quiet go.mod go.sum; then
echo "::error::go.mod or go.sum is not tidy. Run 'go mod tidy' and commit the result."
git diff go.mod go.sum
exit 1
fi

- name: go vet
run: go vet ./...

- name: go test
run: go test -race ./...

- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.2.2

docs:
name: Docs lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 11

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: docs/pnpm-lock.yaml

- run: pnpm install --frozen-lockfile

- name: Generate Nuxt types
run: pnpm exec nuxt prepare

- name: ESLint
run: pnpm lint
4 changes: 2 additions & 2 deletions cmd/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var cleanCmd = &cobra.Command{
Long: cleanLongUsage,
Example: "terox clean\nterox gc\nterox cleanup",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
template.Clean()
RunE: func(cmd *cobra.Command, args []string) error {
return template.Clean()
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var listCmd = &cobra.Command{
Example: listExample,
Long: listCmdLongHelp,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
template.List()
RunE: func(cmd *cobra.Command, args []string) error {
return template.List()
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/template/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Clean() error {
// Read the contents of the template directory to check for templates
if templates, err := os.ReadDir(templateDir); err != nil {
return fmt.Errorf(
"Failed to find any templates at %s: %w",
"failed to find any templates at %s: %w",
templateDir,
err,
)
Expand All @@ -30,7 +30,7 @@ func Clean() error {
fmt.Printf("%s\n", template.Name())
if err := os.RemoveAll(path); err != nil {
return fmt.Errorf(
"Failed to remove %s: %w",
"failed to remove %s: %w",
template.Name(),
err,
)
Expand Down
2 changes: 1 addition & 1 deletion internal/template/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func List() error {
// Check if any template exists locally, if yes, list them to STDOUT
if templates, err := os.ReadDir(templateDir); err != nil {
return fmt.Errorf(
"Failed to read the contents of %s directory: %w",
"failed to read the contents of %s directory: %w",
templateDir,
err,
)
Expand Down
4 changes: 2 additions & 2 deletions internal/template/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func downloadTemplate(repo string) (string, error) {
if err != nil {
return "", fmt.Errorf("download %s: %w", url, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("bad server response: %d", resp.StatusCode)
Expand All @@ -100,7 +100,7 @@ func extractTemplate(zipfile, dest string) (string, error) {
if err != nil {
return "", fmt.Errorf("open zip: %w", err)
}
defer r.Close()
defer func() { _ = r.Close() }()

var topLevelFolder string
for _, f := range r.File {
Expand Down
Loading