diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4901bce..93734aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,15 +2,11 @@ name: Continuous Integration on: push: branches: - - main + - main pull_request: jobs: - test-job: - runs-on: ubuntu-latest - steps: - - name: Successful test - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + test-makefile: name: build and test makefile runs-on: ubuntu-latest @@ -19,6 +15,25 @@ jobs: - uses: actions/setup-go@v6 with: go-version: "1.23" + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y make tar diffutils bzip2 gzip curl git - name: run make run: make + test-fedora: + name: build and test on Fedora latest + runs-on: ubuntu-latest + container: + image: quay.io/fedora/fedora:latest + options: --user root + steps: + - name: Install dependencies + run: | + dnf update -y + dnf install -y golang make tar diffutils bzip2 gzip curl git which + - name: Check out repository + uses: actions/checkout@v6 + - name: Build and test + run: make diff --git a/.gitignore b/.gitignore index b7cfcc3..3ac0386 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ cmd/tar-diff/tar-diff cmd/tar-patch/tar-patch +.secrets diff --git a/Makefile b/Makefile index 64aa746..f357a38 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,20 @@ -.PHONY: all build clean fmt install lint test tools unit-test integration-test validate .install.gitvalidation .install.golangci-lint .gitvalidation +.PHONY: all build clean fmt install lint test tools unit-test integration-test validate .install.golangci-lint export GOPROXY=https://proxy.golang.org + GOBIN := $(shell go env GOBIN) ifeq ($(GOBIN),) +GOPATH := $(shell go env GOPATH) GOBIN := $(GOPATH)/bin endif -BUILDFLAGS := +GOFLAGS:= +ifeq ($(GOFLAGS),) +GOFLAGS := -buildvcs=false +endif -PACKAGES := $(shell go list $(BUILDFLAGS) ./...) +PACKAGES := $(shell go list $(GOFLAGS) ./...) SOURCE_DIRS = $(shell echo $(PACKAGES) | awk 'BEGIN{FS="/"; RS=" "}{print $$4}' | uniq) PREFIX ?= ${DESTDIR}/usr @@ -17,32 +22,27 @@ INSTALLDIR=${PREFIX}/bin export PATH := $(PATH):${GOBIN} -all: tools tar-diff tar-patch test validate .gitvalidation +all: tools tar-diff tar-patch test validate build: - go build $(BUILDFLAGS) ./... + go build $(GOFLAGS) ./... tar-diff: - go build $(BUILDFLAGS) ./cmd/tar-diff + go build $(GOFLAGS) ./cmd/tar-diff tar-patch: - go build $(BUILDFLAGS) ./cmd/tar-patch + go build $(GOFLAGS) ./cmd/tar-patch install: tar-diff tar-patch install -d -m 755 ${INSTALLDIR} install -m 755 tar-diff ${INSTALLDIR}/tar-diff install -m 755 tar-patch ${INSTALLDIR}/tar-patch -tools: .install.gitvalidation .install.golangci-lint - -.install.gitvalidation: - if [ ! -x "$(GOBIN)/git-validation" ]; then \ - go install github.com/vbatts/git-validation@latest; \ - fi +tools: .install.golangci-lint .install.golangci-lint: if [ ! -x "$(GOBIN)/golangci-lint" ]; then \ - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOBIN) latest; \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/main/install.sh | sh -s -- -b $(GOBIN) v1.62.2; \ fi clean: @@ -52,7 +52,7 @@ integration-test: tar-diff tar-patch tests/test.sh unit-test: - go test $(BUILDFLAGS) -cover ./... + go test $(GOFLAGS) -cover ./... test: unit-test integration-test @@ -60,18 +60,8 @@ fmt: @gofmt -l -s -w $(SOURCE_DIRS) validate: lint - @go vet ./... + @go vet $(GOFLAGS) ./... @test -z "$$(gofmt -s -l . | tee /dev/stderr)" lint: - $(GOBIN)/golangci-lint run - -.gitvalidation: - @which $(GOBIN)/git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make clean && make tools'" && false) -ifeq ($(GITHUB_ACTIONS),true) - $(GOBIN)/git-validation -q -run DCO,short-subject,dangling-whitespace -else - git fetch -q "https://github.com/containers/tar-diff.git" "refs/heads/master" - upstream="$$(git rev-parse --verify FETCH_HEAD)" ; \ - $(GOBIN)/git-validation -q -run DCO,short-subject,dangling-whitespace -range $$upstream..HEAD -endif + GOFLAGS=$(GOFLAGS) $(GOBIN)/golangci-lint run