Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ obj-x86_64-linux-gnu/
obj-aarch64-linux-gnu/
obj-arm-linux-gnueabihf/
obj-i686-linux-gnu/
unit.out
unit-test.cov
system-test.cov
aptly.test
build/
dpkgs/
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
sudo mkdir -p /srv ; sudo chown runner /srv
COVERAGE_DIR=${{ runner.temp }} make system-test
make system-test

- name: "Merge Code Coverage"
run: |
go install github.com/wadey/[email protected]
~/go/bin/gocovmerge unit.out ${{ runner.temp }}/*.out > coverage.txt
~/go/bin/gocovmerge unit-test.cov system-test.cov > coverage.txt

- name: "Upload Code Coverage"
uses: codecov/codecov-action@v2
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
*.o
*.a
*.so
unit.out
unit-test.cov
system-test.cov

# Folders
_obj
Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ VERSION=$(shell make -s version)
PYTHON?=python3
BINPATH?=$(GOPATH)/bin
GOLANGCI_LINT_VERSION=v2.0.2 # version supporting go 1.24
COVERAGE_DIR?=$(shell mktemp -d)
GOOS=$(shell go env GOHOSTOS)
GOARCH=$(shell go env GOHOSTARCH)

Expand All @@ -15,12 +14,16 @@ export TZ=UTC
# Unit Tests and some sysmte tests rely on expired certificates, turn back the time
export TEST_FAKETIME := 2025-01-02 03:04:05

ifeq ($(origin COVERAGE_DIR), undefined)
COVERAGE_DIR := $(shell mktemp -d)
endif

# run with 'COVERAGE_SKIP=1' to skip coverage checks during system tests
ifeq ($(COVERAGE_SKIP),1)
COVERAGE_ARG_BUILD :=
COVERAGE_ARG_TEST := --coverage-skip
else
COVERAGE_ARG_BUILD := -coverpkg="./..."
COVERAGE_ARG_BUILD := -coverpkg=github.com/aptly-dev/aptly/...
COVERAGE_ARG_TEST := --coverage-dir $(COVERAGE_DIR)
endif

Expand Down Expand Up @@ -107,13 +110,16 @@ test: prepare swagger etcd-install ## Run unit tests (add TEST=regex to specify
@echo "\e[33m\e[1mStarting etcd ...\e[0m"
@mkdir -p /tmp/aptly-etcd-data; system/t13_etcd/start-etcd.sh > /tmp/aptly-etcd-data/etcd.log 2>&1 &
@echo "\e[33m\e[1mRunning go test ...\e[0m"
faketime "$(TEST_FAKETIME)" go test -v ./... -gocheck.v=true -check.f "$(TEST)" -coverprofile=unit.out; echo $$? > .unit-test.ret
faketime "$(TEST_FAKETIME)" go test -v ./... -gocheck.v=true -check.f "$(TEST)" -coverprofile=unit-test.cov; echo $$? > .unit-test.ret
@echo "\e[33m\e[1mStopping etcd ...\e[0m"
@pid=`cat /tmp/etcd.pid`; kill $$pid
@rm -f /tmp/aptly-etcd-data/etcd.log
@ret=`cat .unit-test.ret`; if [ "$$ret" = "0" ]; then echo "\n\e[32m\e[1mUnit Tests SUCCESSFUL\e[0m"; else echo "\n\e[31m\e[1mUnit Tests FAILED\e[0m"; fi; rm -f .unit-test.ret; exit $$ret
@go tool cover -func=unit-test.cov


system-test: prepare swagger etcd-install ## Run system tests
@test -f $(BINPATH)/gocovmerge || GOOS= GOARCH= go install github.com/wadey/gocovmerge@latest
# build coverage binary
go test -v $(COVERAGE_ARG_BUILD) -c -tags testruncli
# Download fixture-db, fixture-pool, etcd.db
Expand All @@ -122,6 +128,9 @@ system-test: prepare swagger etcd-install ## Run system tests
test -f ~/etcd.db || (curl -o ~/etcd.db.xz http://repo.aptly.info/system-tests/etcd.db.xz && xz -d ~/etcd.db.xz)
# Run system tests
PATH=$(BINPATH)/:$(PATH) FORCE_COLOR=1 $(PYTHON) system/run.py --long $(COVERAGE_ARG_TEST) $(CAPTURE_ARG) $(TEST)
PATH=$(BINPATH)/:$(PATH) gocovmerge $(COVERAGE_DIR)/*.out > system-test.cov
rm -f $(COVERAGE_DIR)/*.out
go tool cover -func=system-test.cov

bench:
@echo "\e[33m\e[1mRunning benchmark ...\e[0m"
Expand Down Expand Up @@ -237,7 +246,7 @@ clean: ## remove local build and module cache
test ! -e .go || find .go/ -type d ! -perm -u=w -exec chmod u+w {} \;
rm -rf .go/
rm -rf build/ obj-*-linux-gnu* tmp/
rm -f unit.out aptly.test VERSION docs/docs.go docs/swagger.json docs/swagger.yaml docs/swagger.conf
rm -f unit-test.cov system-test.cov aptly.test VERSION docs/docs.go docs/swagger.json docs/swagger.yaml docs/swagger.conf
find system/ -type d -name __pycache__ -exec rm -rf {} \; 2>/dev/null || true

.PHONY: help man prepare swagger version binaries build docker-release docker-system-test docker-unit-test docker-lint docker-build docker-image docker-man docker-shell docker-serve clean releasetype dpkg serve flake8
7 changes: 6 additions & 1 deletion api/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"fmt"
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -195,7 +196,11 @@ func apiReposEdit(c *gin.Context) {
collectionFactory := context.NewCollectionFactory()
collection := collectionFactory.LocalRepoCollection()

name := c.Params.ByName("name")
name, err := url.PathUnescape(c.Params.ByName("name"))
if err != nil {
AbortWithJSONError(c, 400, err)
return
}
repo, err := collection.ByName(name)
if err != nil {
AbortWithJSONError(c, 404, err)
Expand Down
2 changes: 1 addition & 1 deletion system/t06_publish/PublishSnapshot43Test_gold
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Signing file 'Release' with gpg, please enter your passphrase when prompted:
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:

Snapshot snap43 has been successfully published.
Please setup your webserver to serve directory '/home/runner/.aptly/public' with autoindexing.
Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing.
Now you can add following line to apt sources:
deb http://your-server/ maverick main
Don't forget to add your GPG key to apt with apt-key.
Expand Down
2 changes: 1 addition & 1 deletion system/testout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class TestOut:
def __init__(self):
self.tmp_file = tempfile.NamedTemporaryFile(delete=False)
self.tmp_file = tempfile.NamedTemporaryFile(delete=True)
self.read_pos = 0

def fileno(self):
Expand Down
Loading