-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
361 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# SPDX-FileCopyrightText: 2024 Shun Sakai | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
name: CD | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "develop" | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "stable" | ||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.2 | ||
- name: Install Asciidoctor | ||
run: | | ||
gem install asciidoctor | ||
asciidoctor -V | ||
- name: Check `.goreleaser.yaml` | ||
uses: goreleaser/goreleaser-action@v5.0.0 | ||
with: | ||
distribution: "goreleaser" | ||
version: "latest" | ||
args: check | ||
- name: Check GoReleaser | ||
uses: goreleaser/goreleaser-action@v5.0.0 | ||
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
with: | ||
distribution: "goreleaser" | ||
version: "latest" | ||
args: release --clean --snapshot | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5.0.0 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
distribution: "goreleaser" | ||
version: "latest" | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# SPDX-FileCopyrightText: 2024 Shun Sakai | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
version: 1 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
- asciidoctor -b manpage docs/man/man1/glzip.1.adoc | ||
|
||
builds: | ||
- main: ./cmd/glzip | ||
binary: glzip | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- darwin | ||
- freebsd | ||
- linux | ||
- openbsd | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
|
||
archives: | ||
- format: tar.gz | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- AUTHORS.adoc | ||
- CHANGELOG.adoc | ||
- CONTRIBUTING.adoc | ||
- docs/man/man1/glzip.1 | ||
- LICENSES/* | ||
- README.md | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// SPDX-FileCopyrightText: 2024 Shun Sakai | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
package main | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/google/go-cmdtest" | ||
) | ||
|
||
var testFiles = []string{ | ||
"foo.txt", | ||
"fox.lz", | ||
"fox_bm.lz", | ||
"fox_das46.lz", | ||
"fox_de20.lz", | ||
"fox_s11.lz", | ||
"fox_v2.lz", | ||
} | ||
|
||
func copyFile(srcFile, dstFile string) error { | ||
src, err := os.Open(srcFile) | ||
if err != nil { | ||
return err | ||
} | ||
defer src.Close() | ||
|
||
dst, err := os.Create(dstFile) | ||
if err != nil { | ||
return err | ||
} | ||
defer dst.Close() | ||
|
||
_, err = io.Copy(dst, src) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func TestCLI(t *testing.T) { | ||
t.Parallel() | ||
|
||
if runtime.GOOS == "windows" { | ||
t.SkipNow() | ||
} | ||
|
||
wd, err := os.Getwd() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if err := exec.Command("go", "build").Run(); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
defer os.Remove("glzip") | ||
|
||
ts, err := cmdtest.Read("testdata") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
ts.Setup = func(rootDir string) error { | ||
for _, testFile := range testFiles { | ||
err := copyFile(filepath.Join(wd, "testdata", testFile), filepath.Join(rootDir, testFile)) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
ts.Commands["glzip"] = cmdtest.Program("glzip") | ||
ts.Run(t, false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SPDX-FileCopyrightText: 2024 Shun Sakai | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
$ glzip foo.txt | ||
$ cat foo.txt --> FAIL | ||
$ glzip -decompress foo.txt.lz | ||
$ cat foo.txt | ||
Hello, world! | ||
|
||
$ glzip -keep foo.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: 2024 Shun Sakai | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
$ glzip -dictionary-size 4194304 foo.txt | ||
$ cat foo.txt --> FAIL | ||
$ glzip -decompress foo.txt.lz | ||
$ cat foo.txt | ||
Hello, world! | ||
|
||
$ glzip -dictionary-size 4095 foo.txt --> FAIL | ||
lzip: dictionary size is too small | ||
|
||
$ glzip -dictionary-size 536870913 foo.txt --> FAIL | ||
lzip: dictionary size is too large |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2024 Shun Sakai | ||
|
||
SPDX-License-Identifier: Apache-2.0 OR MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_bcrc.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_bm.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_crc0.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_das46.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_de20.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_mes81.lz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../testdata/fox_s11.lz |
Oops, something went wrong.