Skip to content

Commit cf054b8

Browse files
committed
ci: add lint workflow
1 parent 2a999c0 commit cf054b8

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

.github/workflows/lint.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# GitHub Actions workflow to lint the locale files.
2+
name: "Lint"
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
merge_group:
9+
10+
concurrency:
11+
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}"
12+
cancel-in-progress: "${{ github.event.action != 'merge_group' }}"
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
lint:
19+
name: "Lint"
20+
runs-on: "ubuntu-latest"
21+
steps:
22+
- name: "Checkout repository"
23+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
24+
with:
25+
fetch-depth: 0
26+
submodules: true
27+
28+
- name: "Setup Go stable"
29+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5
30+
with:
31+
go-version: "stable"
32+
cache: true
33+
check-latest: true
34+
35+
- name: "Download dependencies"
36+
run: go mod download
37+
38+
- name: "Verify dependencies"
39+
run: go mod verify
40+
41+
- name: "Build"
42+
run: go build -v ./...
43+
44+
- name: "Test"
45+
run: go test -race -v ./...
46+
47+
- name: "Lint"
48+
run: |
49+
go build -trimpath ./cmd/lang-lint
50+
./lang-lint

cmd/lang-lint/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"hypera.dev/axolotl-lang/v2"
8+
)
9+
10+
func main() {
11+
if err := lang.LoadLocales(); err != nil {
12+
_, _ = fmt.Fprintln(os.Stderr, err)
13+
os.Exit(1)
14+
}
15+
16+
fmt.Println("Locales loaded successfully", lang.Bundle().LanguageTags())
17+
}

lang.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ func LoadLocales() error {
4141
return nil
4242
}
4343

44+
func Bundle() *i18n.Bundle {
45+
return bundle
46+
}
47+
4448
func GetLocalizer(locale discordgo.Locale) (*Localizer, bool) {
4549
if l, ok := locales[locale]; ok {
4650
return l, true

0 commit comments

Comments
 (0)