Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
340c90211f | ||
|
|
e737280a3c | ||
|
|
18d1d2730f | ||
|
|
fc1f3fa814 |
@@ -14,9 +14,9 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: '1.25.3'
|
go-version: '1.25.4'
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender_models_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/textsender_models_deploy_key
|
||||||
chmod 600 ~/.ssh/textsender_models_deploy_key
|
chmod 600 ~/.ssh/textsender_models_deploy_key
|
||||||
ssh-keyscan ${{ vars.MY_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ secrets.MY_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/textsender_models_deploy_key
|
ssh-add -v ~/.ssh/textsender_models_deploy_key
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
stages:
|
|
||||||
- build
|
|
||||||
- test
|
|
||||||
|
|
||||||
build:
|
|
||||||
stage: build
|
|
||||||
image: rust:1.85
|
|
||||||
script:
|
|
||||||
- cargo build --release
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- target/release/clean_file
|
|
||||||
expire_in: 1 week
|
|
||||||
cache:
|
|
||||||
key: "cargo-cache"
|
|
||||||
paths:
|
|
||||||
- target/
|
|
||||||
- ~/.cargo/
|
|
||||||
|
|
||||||
test:
|
|
||||||
stage: test
|
|
||||||
image: rust:1.85
|
|
||||||
script:
|
|
||||||
- cargo test
|
|
||||||
cache:
|
|
||||||
key: "cargo-cache"
|
|
||||||
paths:
|
|
||||||
- target/
|
|
||||||
- ~/.cargo/
|
|
||||||
@@ -6,16 +6,17 @@ GO_VERSION ?= $(shell go version | awk '{print $$3}')
|
|||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
go build -ldflags="\
|
go build -ldflags="\
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.Version=$(VERSION)' \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.Version=$(VERSION)' \
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.BuildTime=$(BUILD_TIME)' \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.BuildTime=$(BUILD_TIME)' \
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.Commit=$(COMMIT)' \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.Commit=$(COMMIT)' \
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.GoVersion=$(GO_VERSION)'" \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.GoVersion=$(GO_VERSION)'" \
|
||||||
-o clean_file main.go
|
-o clean_file cmd/clean_file/main.go
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
go install -ldflags="\
|
go install -ldflags="\
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.Version=$(VERSION)' \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.Version=$(VERSION)' \
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.BuildTime=$(BUILD_TIME)' \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.BuildTime=$(BUILD_TIME)' \
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.Commit=$(COMMIT)' \
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.Commit=$(COMMIT)' \
|
||||||
-X 'git.kundeng.us/phoenix/clean_file/version.GoVersion=$(GO_VERSION)'"
|
-X 'git.kundeng.us/phoenix/clean_file/internal/version.GoVersion=$(GO_VERSION)'"
|
||||||
|
-o clean_file cmd/clean_file/main.go
|
||||||
|
|||||||
@@ -3,17 +3,18 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.kundeng.us/phoenix/clean_file/parser"
|
"git.kundeng.us/phoenix/clean_file/internal/parser"
|
||||||
"git.kundeng.us/phoenix/clean_file/version"
|
"git.kundeng.us/phoenix/clean_file/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
args := os.Args
|
args := os.Args
|
||||||
|
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
fmt.Println("Invalid arguments provided")
|
log.Println("Invalid arguments provided")
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,10 +26,10 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("clean_file")
|
log.Println("clean_file")
|
||||||
filepath := args[1]
|
filepath := args[1]
|
||||||
|
|
||||||
fmt.Println("File path:", filepath)
|
log.Println("File path:", filepath)
|
||||||
prsr := parser.NumberParser{FilePath: filepath}
|
prsr := parser.NumberParser{FilePath: filepath}
|
||||||
|
|
||||||
numbers := prsr.FileDump()
|
numbers := prsr.FileDump()
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
module git.kundeng.us/phoenix/clean_file
|
module git.kundeng.us/phoenix/clean_file
|
||||||
|
|
||||||
go 1.25.3
|
go 1.25.4
|
||||||
|
|
||||||
require git.kundeng.us/phoenix/textsender-models v0.0.7-5-9bc1743bd9-556
|
require git.kundeng.us/phoenix/textsender-models v0.0.12
|
||||||
|
|
||||||
require github.com/google/uuid v1.6.0 // indirect
|
require github.com/google/uuid v1.6.0 // indirect
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
git.kundeng.us/phoenix/textsender-models v0.0.7-5-9bc1743bd9-556 h1:/tIswN4wEFioG++uo25iBY1jPNdHjhH07l8Vh4qUDQo=
|
git.kundeng.us/phoenix/textsender-models v0.0.12 h1:ps9H3FS5LyCwQhAiIvg4vYyfLZZ64dex1y9ytb0o9C4=
|
||||||
git.kundeng.us/phoenix/textsender-models v0.0.7-5-9bc1743bd9-556/go.mod h1:lx5MCnOgGgsdpwzrfi9uph5xmkeb6H8AuexUNGss2no=
|
git.kundeng.us/phoenix/textsender-models v0.0.12/go.mod h1:9iPDQJg1Tc6WMNoW5+f8YKmnosMwlWHJ++hmxNLDEe0=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"git.kundeng.us/phoenix/textsender-models/pkg/contact"
|
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
const Letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
@@ -19,7 +19,7 @@ type NumberParser struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (prsr *NumberParser) FileDump() []contact.Contact {
|
func (prsr *NumberParser) FileDump() []contact.Contact {
|
||||||
fmt.Println("Dumping files")
|
log.Println("Dumping files")
|
||||||
objs := []contact.Contact{}
|
objs := []contact.Contact{}
|
||||||
|
|
||||||
for _, line := range prsr.readLines(prsr.FilePath) {
|
for _, line := range prsr.readLines(prsr.FilePath) {
|
||||||
@@ -45,14 +45,14 @@ func (prsr *NumberParser) updateContacts(contacts []contact.Contact) []contact.C
|
|||||||
for _, ct := range contacts {
|
for _, ct := range contacts {
|
||||||
parsed := ct.PhoneNumber
|
parsed := ct.PhoneNumber
|
||||||
if len(parsed) < 2 {
|
if len(parsed) < 2 {
|
||||||
fmt.Println("Invalid number:", parsed)
|
log.Println("Invalid number:", parsed)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
pars := prsr.removeSomeData(parsed)
|
pars := prsr.removeSomeData(parsed)
|
||||||
parsed = pars
|
parsed = pars
|
||||||
|
|
||||||
fmt.Println(parsed)
|
log.Println("Parsed:", parsed)
|
||||||
|
|
||||||
updatedParsed := prsr.addPrefix(parsed)
|
updatedParsed := prsr.addPrefix(parsed)
|
||||||
updated = append(updated, contact.Contact{PhoneNumber: updatedParsed})
|
updated = append(updated, contact.Contact{PhoneNumber: updatedParsed})
|
||||||
@@ -94,13 +94,13 @@ func (prsr NumberParser) SaveFile(vals []contact.Contact) {
|
|||||||
// Create json and save it to the filesystem
|
// Create json and save it to the filesystem
|
||||||
jsonData, err := json.MarshalIndent(&vals, "", " ")
|
jsonData, err := json.MarshalIndent(&vals, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error marshaling JSON:", err)
|
log.Println("Error marshaling JSON:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(filename, jsonData, 0644)
|
err = os.WriteFile(filename, jsonData, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error writing file:", err)
|
log.Println("Error writing file:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ func (prsr NumberParser) removeSomeData(unparsed string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Parsed:", parsed)
|
log.Println("Parsed:", parsed)
|
||||||
|
|
||||||
return parsed
|
return parsed
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,13 @@ package parser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.kundeng.us/phoenix/textsender-models/pkg/contact"
|
"git.kundeng.us/phoenix/textsender-models/tx0/contact"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Test_File_Path = "../tests/numbers.txt"
|
const Test_File_Path = "../../tests/numbers.txt"
|
||||||
|
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
func Test_RemoveDups(t *testing.T) {
|
func Test_RemoveDups(t *testing.T) {
|
||||||
@@ -39,12 +40,14 @@ func Test_RemoveDups(t *testing.T) {
|
|||||||
for _, val := range finalAmount {
|
for _, val := range finalAmount {
|
||||||
fmt.Println("PhoneNumber:", val.PhoneNumber)
|
fmt.Println("PhoneNumber:", val.PhoneNumber)
|
||||||
}
|
}
|
||||||
fmt.Println("Printing test values")
|
fmt.Println("\nPrinting test values")
|
||||||
for _, val := range testValues {
|
for _, val := range testValues {
|
||||||
fmt.Println("PhoneNumber:", val.PhoneNumber)
|
fmt.Println("PhoneNumber:", val.PhoneNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Error("Data has not be updated")
|
t.Error("Data has not been updated")
|
||||||
|
} else {
|
||||||
|
log.Println("The duplicates have been removed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user