diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 79d374a..5e52070 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: build +name: Build on: [push, pull_request] jobs: @@ -18,7 +18,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Download Go modules run: go mod download @@ -30,6 +29,3 @@ jobs: run: | go get -u github.com/upyun/upx upx -v - - name: Test - run: | - go test -v . diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index f5f715e..963dc31 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -1,27 +1,27 @@ -name: goreleaser - -on: - push: - tags: - - '*' - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} +name: Release + +on: + push: + tags: + - '*' + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v2 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bc78aa4..dbc8443 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,22 +1,22 @@ -name: lint -on: - push: - pull_request: - -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.31 - # Optional: golangci-lint command line arguments. - args: --issues-exit-code=0 - # Optional: working directory, useful for monorepos - # working-directory: somedir - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true +name: Lint +on: + push: + pull_request: + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.31 + # Optional: golangci-lint command line arguments. + args: --issues-exit-code=0 + # Optional: working directory, useful for monorepos + # working-directory: somedir + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..dddcaea --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + go-version: [^1] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + env: + GO111MODULE: "on" + UPYUN_BUCKET1: ${{ secrets.UPYUN_BUCKET1 }} + UPYUN_BUCKET2: ${{ secrets.UPYUN_BUCKET2 }} + UPYUN_PASSWORD: ${{ secrets.UPYUN_PASSWORD }} + UPYUN_USERNAME: ${{ secrets.UPYUN_USERNAME }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + - uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download Go modules + run: go mod download + - name: Test + run: | + go build . + go test -v . diff --git a/.gitignore b/.gitignore index 430ec88..7534857 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ upx upx-* release dist +FILE +list diff --git a/putgetrm_test.go b/putgetrm_test.go index cc9f5a0..cd3cb22 100644 --- a/putgetrm_test.go +++ b/putgetrm_test.go @@ -151,6 +151,7 @@ func TestPutAndGet(t *testing.T) { // upx get /path/to/file /path/to/dir/ localPath = filepath.Join(localBase, "getfile") + string(filepath.Separator) + os.MkdirAll(localPath, 0755) getFile(t, "FILE", localPath, filepath.Join(localPath, "FILE")) // upx get ../path/to/dir diff --git a/upx_test.go b/upx_test.go index 1daacc1..a2a7f84 100644 --- a/upx_test.go +++ b/upx_test.go @@ -16,10 +16,10 @@ import ( var ( ROOT = fmt.Sprintf("/upx-test/%s", time.Now()) - BUCKET_1 = "bigfile" - BUCKET_2 = "prog-test" - USERNAME = "myworker" - PASSWORD = "TYGHBNtyghbn" + BUCKET_1 = os.Getenv("UPYUN_BUCKET1") + BUCKET_2 = os.Getenv("UPYUN_BUCKET2") + USERNAME = os.Getenv("UPYUN_USERNAME") + PASSWORD = os.Getenv("UPYUN_PASSWORD") ) func SetUp() {