diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1749305 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,93 @@ +name: CI +on: + pull_request: + merge_group: + push: + branches: + - main + +permissions: + contents: read + # Make sure package write permission is always enabled, even + # for Dependabot pull requests. + packages: write + +# Prevent multiple runs on the same branch. This is important for webhooks +# that must be run in order. +concurrency: + group: ${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +jobs: + shellcheck: + runs-on: "ubuntu-22.04" + steps: + - name: Check out source code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Run shellcheck + uses: ludeeus/action-shellcheck@master + with: + version: v0.8.0 + scandir: "./scripts" + severity: info + + go-test: + runs-on: "ubuntu-22.04" + needs: + - setup-environment + steps: + - name: Check out source code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Set up Go + uses: actions/setup-go@v4.1.0 + with: + go-version: "1.21.3" + + - run: make test + + go-lint: + runs-on: "ubuntu-22.04" + needs: + - setup-environment + steps: + - name: Check out source code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Set up Go + uses: actions/setup-go@v4.1.0 + with: + go-version: "1.21.3" + + - run: make lint + + build: + runs-on: "ubuntu-22.04" + needs: + - setup-environment + steps: + - name: Check out source code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Set up Go + uses: actions/setup-go@v4.1.0 + with: + go-version: "1.21.3" + + - name: Test GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: v1.21.2 + args: release --skip=publish --clean --snapshot + distribution: goreleaser + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 38463d1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: go -os: - - linux - - windows - - freebsd -arch: - - amd64 -go: -- '1.16' -before_script: - - go mod download -script: - # All platforms - - go test ./... - - go build - # Linux only - # Run generic_unix.sh test script - # Build for all platforms - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then scripts/test/generic_unix.sh; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then make build; fi diff --git a/Makefile b/Makefile index 7c4ebaa..b4da8aa 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,14 @@ -VERSION := $(shell cat cmd/root.go | grep 'const version' | cut -c 25- | tr -d '"') - $(shell mkdir -p artifacts) build: clean - $(info building disk-usage ${VERSION}) - - @docker build \ - -f docker/Dockerfile \ - --no-cache \ - --build-arg version=${VERSION} \ - -t disk-usage:${VERSION} . - - @docker create -ti --name disk-usageartifacts disk-usage:${VERSION} bash && \ - docker cp disk-usageartifacts:/disk-usage/artifacts/. artifacts/ - - # cleanup - @docker rm -fv disk-usageartifacts &> /dev/null + goreleaser build --snapshot --clean lint: golint ./... +test: + go test ./... + fmt: go fmt ./... diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 53d4bab..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM golang:1.16 - -ARG version - -ADD . /disk-usage/ -WORKDIR /disk-usage - -RUN go get github.com/mitchellh/gox - -# build for Windows, Linux -RUN \ - $GOPATH/bin/gox \ - -arch='amd64' \ - -os='!netbsd !openbsd !darwin' \ - -output "artifacts/disk-usage-{{.OS}}-{{.Arch}}" \ - -ldflags '-w -extldflags "-static"' \ - ./... - -WORKDIR /disk-usage/artifacts -RUN ls | xargs -n1 sha256sum >> SHA256SUMS