Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Bring repository up to date
Browse files Browse the repository at this point in the history
fix some tests and licensing checks
format everything
add ci

Signed-off-by: Appu Goundan <[email protected]>
  • Loading branch information
loosebazooka committed Feb 15, 2024
1 parent 5d44978 commit 56c19b6
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 36 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Build and test"

on:
push:
branches: [main]
pull_request: {}

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: go.mod
- name: Run tests
run: make test
- name: Run integration tests
run: make integration
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test: $(BUILD_DIR)/$(PROJECT)

.PHONY: integration
integration: $(BUILD_DIR)/$(PROJECT)
go test -v -tags integration $(REPOPATH)/tests -timeout 20m
go test -v -tags integration $(REPOPATH)/tests -timeout 20m -run TestDiffAndAnalysis/file_differ

.PHONY: release
release: cross
Expand Down
2 changes: 1 addition & 1 deletion differs/apt_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/sirupsen/logrus"
)

//APT package database location
// APT package database location
const dpkgStatusFile string = "var/lib/dpkg/status"

type AptAnalyzer struct {
Expand Down
2 changes: 1 addition & 1 deletion differs/emerge_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/sirupsen/logrus"
)

//Emerge package database location
// Emerge package database location
const emergePkgFile string = "/var/db/pkg"

type EmergeAnalyzer struct{}
Expand Down
4 changes: 2 additions & 2 deletions differs/rpm_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ import (
"github.com/sirupsen/logrus"
)

//RPM macros file location
// RPM macros file location
const rpmMacros string = "/usr/lib/rpm/macros"

//RPM command to extract packages from the rpm database
// RPM command to extract packages from the rpm database
var rpmCmd = []string{
"rpm", "--nodigest", "--nosignature",
"-qa", "--qf", "%{NAME}\t%{VERSION}-%{RELEASE}\t%{SIZE}\n",
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/fs_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func GetSize(path string) int64 {
return stat.Size()
}

//GetFileContents returns the contents of a file at the specified path
// GetFileContents returns the contents of a file at the specified path
func GetFileContents(path string) (*string, error) {
if _, err := os.Lstat(path); os.IsNotExist(err) {
return nil, err
Expand Down
24 changes: 2 additions & 22 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,5 @@ if [[ $files ]]; then
exit 1
fi

# Check for python on host, and use it if possible, otherwise fall back on python dockerized
if [[ -f $(which python 2>&1) ]]; then
PYTHON="python"
else
PYTHON="docker run --rm -it -v $(pwd):/container-diff -w /container-diff python python"
fi


# Ignore these paths in the following tests.
ignore="vendor\|out\|actions\|setup-tests"

# Check boilerplate
echo "Checking boilerplate..."
BOILERPLATEDIR=./boilerplate
# Grep returns a non-zero exit code if we don't match anything, which is good in this case.
set +e
files=$(${PYTHON} ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR} | grep -v $ignore)
set -e
if [[ ! -z ${files} ]]; then
echo "Boilerplate missing in: ${files}."
exit 1
fi
echo "Checking go-addlicense..."
addlicense -check -l apache -ignore \{actions,differs,vendor,setup-tests,out\}/**/* -ignore cloudbuild\*yaml *
16 changes: 8 additions & 8 deletions tests/file_diff_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6731,12 +6731,12 @@
"Size2": 10125
},
{
"Name": "/var/lib/rpm/Conflictname",
"Name": "/var/lib/rpm/Obsoletename",
"Size1": 8192,
"Size2": 8192
},
{
"Name": "/var/lib/rpm/Name",
"Name": "/var/lib/rpm/Group",
"Size1": 8192,
"Size2": 8192
},
Expand All @@ -6746,22 +6746,22 @@
"Size2": 8192
},
{
"Name": "/var/lib/rpm/Installtid",
"Name": "/var/lib/rpm/Sha1header",
"Size1": 8192,
"Size2": 8192
},
{
"Name": "/var/lib/rpm/Group",
"Name": "/var/lib/rpm/Conflictname",
"Size1": 8192,
"Size2": 8192
},
{
"Name": "/var/lib/rpm/Obsoletename",
"Name": "/var/lib/rpm/Name",
"Size1": 8192,
"Size2": 8192
},
{
"Name": "/var/lib/rpm/Sha1header",
"Name": "/var/lib/rpm/Installtid",
"Size1": 8192,
"Size2": 8192
},
Expand Down Expand Up @@ -6791,12 +6791,12 @@
"Size2": 546
},
{
"Name": "/var/lib/yum/rpmdb-indexes/version",
"Name": "/var/cache/yum/x86_64/7/timedhosts",
"Size1": 44,
"Size2": 44
},
{
"Name": "/var/cache/yum/x86_64/7/timedhosts",
"Name": "/var/lib/yum/rpmdb-indexes/version",
"Size1": 44,
"Size2": 44
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

/*
Expand Down

0 comments on commit 56c19b6

Please sign in to comment.