Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: auto check #3

Merged
merged 1 commit into from
Dec 10, 2024
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
64 changes: 0 additions & 64 deletions .github/workflows/auto-check-workflow.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Astrolib Continuous Integration
name: Balloons Continuous Integration

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Astrolib Release
name: Balloons Release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ before:
# - go mod generate

builds:
- id: "astrolib"
- id: "balloons"
env:
- CGO_ENABLED=0
goos:
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"structcheck",
"stylecheck",
"thelper",
"toplevel",
"tparallel",
"typecheck",
"unconvert",
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 🌟 astrolib: ___Go template for library modules___
# 🌟 balloons: ___Go template for library modules___

[![A B](https://img.shields.io/badge/branching-commonflow-informational?style=flat)](https://commonflow.org)
[![A B](https://img.shields.io/badge/merge-rebase-informational?style=flat)](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
[![A B](https://img.shields.io/badge/branch%20history-linear-blue?style=flat)](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule)
[![Go Reference](https://pkg.go.dev/badge/github.com/snivilised/astrolib.svg)](https://pkg.go.dev/github.com/snivilised/astrolib)
[![Go report](https://goreportcard.com/badge/github.com/snivilised/astrolib)](https://goreportcard.com/report/github.com/snivilised/astrolib)
[![Coverage Status](https://coveralls.io/repos/github/snivilised/astrolib/badge.svg?branch=main)](https://coveralls.io/github/snivilised/astrolib?branch=main&kill_cache=1)
[![Astrolib Continuous Integration](https://github.com/snivilised/astrolib/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/snivilised/astrolib/actions/workflows/ci-workflow.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/snivilised/balloons.svg)](https://pkg.go.dev/github.com/snivilised/balloons)
[![Go report](https://goreportcard.com/badge/github.com/snivilised/balloons)](https://goreportcard.com/report/github.com/snivilised/balloons)
[![Coverage Status](https://coveralls.io/repos/github/snivilised/balloons/badge.svg?branch=main)](https://coveralls.io/github/snivilised/balloons?branch=main&kill_cache=1)
[![Balloons Continuous Integration](https://github.com/snivilised/balloons/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/snivilised/balloons/actions/workflows/ci-workflow.yml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![A B](https://img.shields.io/badge/commit-conventional-commits?style=flat)](https://www.conventionalcommits.org/)

Expand Down Expand Up @@ -53,7 +53,7 @@ By using this template, there is no need to use the cobra-cli to scaffold your a

### 📝 Checklist of required changes

The following is list of actions that must be performed before using this template. Most of the changes concern changing the name `astrolib` to the name of the new application. As the template is instantiated from github, the new name will automatically replace the top level directory name, that being ___astrolib___.
The following is list of actions that must be performed before using this template. Most of the changes concern changing the name `balloons` to the name of the new application. As the template is instantiated from github, the new name will automatically replace the top level directory name, that being ___astrolib___.

➕ The following descriptions use owner name ___pandora___ and repo name ___maestro___ as an example. That is to say the client has instantiated ___astrolib___ template into github at url _github.com/pandora/maestro_

Expand All @@ -63,13 +63,13 @@ Automated via `automate-checklist.sh` script. When the user instantiates the rep

##### ✅ Rename import statements

+ `rename import paths`: global search and replace ___snivilised/astrolib___ to ___pandora/maestro___
+ `rename import paths`: global search and replace ___snivilised/balloons___ to ___pandora/maestro___

##### ✅ Identifiers

+ `change astrolibTemplData`: perform a refactor rename (_Rename Symbol_) to ___maestroTemplData___

##### ✅ Global search replace astrolib to maestro
##### ✅ Global search replace balloons to maestro

Will take care of the following required changes:

Expand All @@ -84,7 +84,7 @@ Will take care of the following required changes:

##### ✅ Miscellaneous automated changes

+ `reset version files`: this is optional because the release process automatically updates the version number according to the tag specified by the user, but will initially contain the version number which reflects the current value of astrolib at the time the client project is instantiated.
+ `reset version files`: this is optional because the release process automatically updates the version number according to the tag specified by the user, but will initially contain the version number which reflects the current value of balloons at the time the client project is instantiated.
+ `change SOURCE_ID`: to "github.com/pandora/maestro"

#### 🖐 Manual changes
Expand Down Expand Up @@ -125,7 +125,7 @@ Of course, its up to the user what settings they use in their repo, these are ju

### 🌐 l10n Translations

This template has been setup to support localisation. The default language is `en-GB` with support for `en-US`. There is a translation file for `en-US` defined as __src/i18n/deploy/astrolib.active.en-US.json__. This is the initial translation for `en-US` that should be deployed with the app.
This template has been setup to support localisation. The default language is `en-GB` with support for `en-US`. There is a translation file for `en-US` defined as __src/i18n/deploy/balloons.active.en-US.json__. This is the initial translation for `en-US` that should be deployed with the app.

Make sure that the go-i18n package has been installed so that it can be invoked as cli, see [go-i18n](https://github.com/nicksnyder/go-i18n) for installation instructions.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.4
v0.1.0
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/snivilised/astrolib
module github.com/snivilised/balloons

go 1.23.0

Expand Down
56 changes: 15 additions & 41 deletions internal/lab/test-utilities.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package lab

import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)

Expand All @@ -13,48 +11,24 @@ func Path(parent, relative string) string {
return filepath.Join(append([]string{parent}, segments...)...)
}

func Normalise(p string) string {
return strings.ReplaceAll(p, "/", string(filepath.Separator))
}

func Reason(name string) string {
return fmt.Sprintf("❌ for item named: '%v'", name)
}

func JoinCwd(segments ...string) string {
if current, err := os.Getwd(); err == nil {
parent, _ := filepath.Split(current)
grand := filepath.Dir(parent)
great := filepath.Dir(grand)
all := append([]string{great}, segments...)

return filepath.Join(all...)
}

panic("could not get root path")
}
// Repo gets the path of the repo with relative joined on
func Repo(relative string) string {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
output, _ := cmd.Output()

func Root() string {
if current, err := os.Getwd(); err == nil {
return current
}
repo := strings.TrimSpace(string(output))

panic("could not get root path")
return combine(repo, relative)
}

func Repo(relative string) string {
_, filename, _, _ := runtime.Caller(0) //nolint:dogsled // ignore
return Path(filepath.Dir(filename), relative)
}

func Log() string {
if current, err := os.Getwd(); err == nil {
parent, _ := filepath.Split(current)
grand := filepath.Dir(parent)
great := filepath.Dir(grand)

return filepath.Join(great, "Test", "test.log")
// combine creates a path from the parent combined with the relative path. The relative
// path is a file system path so should only contain forward slashes, not the standard
// file path separator as denoted by filepath.Separator, typically used when interacting
// with the local file system. Do not use trailing "/".
func combine(parent, relative string) string {
if relative == "" {
return parent
}

panic("could not get root path")
return parent + "/" + relative
}
6 changes: 3 additions & 3 deletions locale/messages-errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import (
// that this message has been removed from the translation files, so
// it is not useable at run time.
type FooBarTemplData struct {
astrolibTemplData
balloonsTemplData
Path string
Reason error
}

// the ID should use spp/library specific code, so replace astrolib with the
// the ID should use spp/library specific code, so replace balloons with the
// name of the library implementing this template project.
func (td FooBarTemplData) Message() *i18n.Message {
return &i18n.Message{
ID: "foo-bar.astrolib.nav",
ID: "foo-bar.balloons.nav",
Description: "Foo Bar description",
Other: "foo bar failure '{{.Path}}' (reason: {{.Reason}})",
}
Expand Down
2 changes: 1 addition & 1 deletion locale/messages-general.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

type UsingConfigFileTemplData struct {
astrolibTemplData
balloonsTemplData
ConfigFileName string
}

Expand Down
8 changes: 4 additions & 4 deletions locale/translate-defs.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package locale

// CLIENT-TODO: Should be updated to use url of the implementing project,
// so should not be left as astrolib. (this should be set by auto-check)
const AstrolibSourceID = "github.com/snivilised/astrolib"
// so should not be left as balloons. (this should be set by auto-check)
const AstrolibSourceID = "github.com/snivilised/balloons"

type astrolibTemplData struct{}
type balloonsTemplData struct{}

func (td astrolibTemplData) SourceID() string {
func (td balloonsTemplData) SourceID() string {
return AstrolibSourceID
}
14 changes: 7 additions & 7 deletions resources/doc/i18n-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ The local directory structure is as follows:

- ___default___: contains the translation file created by the __newt__ (new translation task). Actually, this task creates an __active__ file (`active.en-GB.json`) in the `i18n/out` folder, the result of which needs to be manually copied into the __active__ file in the `default` folder.

- ___deploy___: contains all the translations files that are intended to be deployed with the application. There will be one per supported language and by default this template project includes a translation file for __en-US__ (`astrolib.active.en-US.json`)
- ___deploy___: contains all the translations files that are intended to be deployed with the application. There will be one per supported language and by default this template project includes a translation file for __en-US__ (`balloons.active.en-US.json`)

## ⚙️ Translation Workflow

### ✨ New Translations

__goi18n__ instructs the user to manually create an empty translation message file that they want to add (eg `translate.en-US.json`). This is taken care of by the __newt__ task. Then the requirement is to run the goi18n merge \<active\> command (goi18n merge `astrolib.active.en-US.json` `astrolib.translate.en-US.json`). This has been wrapped up into the __merge__ task and the result is that the translation file `astrolib.translation.en-US.json` is populated with the messages to be translated. So the sequence goes:
__goi18n__ instructs the user to manually create an empty translation message file that they want to add (eg `translate.en-US.json`). This is taken care of by the __newt__ task. Then the requirement is to run the goi18n merge \<active\> command (goi18n merge `balloons.active.en-US.json` `balloons.translate.en-US.json`). This has been wrapped up into the __merge__ task and the result is that the translation file `balloons.translation.en-US.json` is populated with the messages to be translated. So the sequence goes:

- run __newt__ task: (generates default language file `./src/i18n/out/active.en-GB.json` and empty `./src/i18n/out/us-US/astrolib.translation.en-US.json` file). This task can be run from the root folder, __goi18n__ will recursively search the directory tree for files with translate-able content, ie files with template definitions (___i18n.Message___)
- run __merge__ task: derives a translation file for the requested language __en-US__ using 2 files as inputs: source active file (`./src/i18n/out/active.en-GB.json`) and the empty __en-US__ translate file (`./src/i18n/out/us-US/astrolib.translation.en-US.json`), both of which were generated in the previous step.
- run __newt__ task: (generates default language file `./src/i18n/out/active.en-GB.json` and empty `./src/i18n/out/us-US/balloons.translation.en-US.json` file). This task can be run from the root folder, __goi18n__ will recursively search the directory tree for files with translate-able content, ie files with template definitions (___i18n.Message___)
- run __merge__ task: derives a translation file for the requested language __en-US__ using 2 files as inputs: source active file (`./src/i18n/out/active.en-GB.json`) and the empty __en-US__ translate file (`./src/i18n/out/us-US/balloons.translation.en-US.json`), both of which were generated in the previous step.
- hand the translate file to your translator for them to translate
- rename the translate file to the active equivalent (`astrolib.translation.en-US.json`). Save this into the __deploy__ folder. This file will be deployed with the application.
- rename the translate file to the active equivalent (`balloons.translation.en-US.json`). Save this into the __deploy__ folder. This file will be deployed with the application.

### 🧩 Update Existing Translations (⚠️ not finalised)

Expand All @@ -36,7 +36,7 @@ However, in this template, the user can execute the following steps:

- run task __update__: this will re-extract messages into `active.en-GB.json` and then runs merge to create an updated translate file.
- hand the translate file to your translator for them to translate
- as before, this translated file should be used to update the active file `astrolib.active.en-US.json` inside the __deploy__ folder.
- as before, this translated file should be used to update the active file `balloons.active.en-US.json` inside the __deploy__ folder.

## 🎓 Task Reference

Expand Down Expand Up @@ -64,7 +64,7 @@ Outputs:
Inputs:

- ./src/i18n/out/active.en-GB.json
- ./src/i18n/out/en-US/astrolib.translate-en-US.json
- ./src/i18n/out/en-US/balloons.translate-en-US.json

Outputs:

Expand Down
Loading
Loading