Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cmd/tar-diff/tar-diff
cmd/tar-patch/tar-patch
.secrets
44 changes: 17 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
.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
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:
Expand All @@ -52,26 +52,16 @@ integration-test: tar-diff tar-patch
tests/test.sh

unit-test:
go test $(BUILDFLAGS) -cover ./...
go test $(GOFLAGS) -cover ./...

test: unit-test integration-test

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