mirror of
https://github.com/esimov/caire.git
synced 2025-10-11 19:40:06 +08:00
ci: intial workflow setup
This commit is contained in:
45
.github/workflows/build.yml
vendored
Normal file
45
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go-version: [~1.16]
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Cache-Go
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: |
|
||||
~/go/pkg/mod # Module download cache
|
||||
~/.cache/go-build # Build cache (Linux)
|
||||
~/Library/Caches/go-build # Build cache (Mac)
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Download Go modules
|
||||
run: go mod download
|
||||
|
||||
- name: Build project
|
||||
id: makefile
|
||||
run: make
|
@@ -47,24 +47,24 @@ func DecorateText(s string, msgType MessageType) string {
|
||||
// FormatTime formats time.Duration output to a human readable value.
|
||||
func FormatTime(d time.Duration) string {
|
||||
if d.Seconds() < 60.0 {
|
||||
return fmt.Sprintf("%ds", int64(d.Seconds()))
|
||||
return fmt.Sprintf("%.2fs", d.Seconds())
|
||||
}
|
||||
if d.Minutes() < 60.0 {
|
||||
remainingSeconds := math.Mod(d.Seconds(), 60)
|
||||
return fmt.Sprintf("%dm:%ds", int64(d.Minutes()), int64(remainingSeconds))
|
||||
return fmt.Sprintf("%dm %.2fs", int64(d.Minutes()), remainingSeconds)
|
||||
}
|
||||
if d.Hours() < 24.0 {
|
||||
remainingMinutes := math.Mod(d.Minutes(), 60)
|
||||
remainingSeconds := math.Mod(d.Seconds(), 60)
|
||||
return fmt.Sprintf("%dh:%dm:%ds",
|
||||
int64(d.Hours()), int64(remainingMinutes), int64(remainingSeconds))
|
||||
return fmt.Sprintf("%dh %dm %.2fs",
|
||||
int64(d.Hours()), int64(remainingMinutes), remainingSeconds)
|
||||
}
|
||||
remainingHours := math.Mod(d.Hours(), 24)
|
||||
remainingMinutes := math.Mod(d.Minutes(), 60)
|
||||
remainingSeconds := math.Mod(d.Seconds(), 60)
|
||||
return fmt.Sprintf("%dd:%dh:%dm:%ds",
|
||||
return fmt.Sprintf("%dd %dh %dm %.2fs",
|
||||
int64(d.Hours()/24), int64(remainingHours),
|
||||
int64(remainingMinutes), int64(remainingSeconds))
|
||||
int64(remainingMinutes), remainingSeconds)
|
||||
}
|
||||
|
||||
// DetectFileContentType detects the file type by reading MIME type information of the file content.
|
||||
|
Reference in New Issue
Block a user