Skip to content

Commit 6b93c04

Browse files
committed
run tests in container
1 parent 400d282 commit 6b93c04

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN apk add make git
55
RUN make build
66

77
FROM alpine:3.21
8+
WORKDIR /sonic
9+
COPY --from=builder /work/bin/sonic-configdb-utils /usr/bin
810

9-
COPY --from=builder /work/bin/sonic-configdb-utils /
10-
11-
ENTRYPOINT ["/sonic-configdb-utils"]
11+
ENTRYPOINT ["/usr/bin/sonic-configdb-utils"]

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ test:
3030
go test ./... -count 1
3131

3232
.PHONY: test-generate
33-
test-generate:
33+
test-generate: docker-build
3434
./tests/test.sh
3535

3636
.PHONY: lint
3737
lint:
3838
golangci-lint run --build-tags client -p bugs -p unused
39+
40+
.PHONY: docker-build
41+
docker-build:
42+
docker build -t sonic-configdb-utils:local .

tests/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function test() {
44
test_dir=$1
55

6-
go run main.go generate -i $test_dir/sonic-config.yaml -o $test_dir/config_db.json -p $test_dir/platform.json
6+
docker run --rm -v $test_dir:/usr/share/sonic/platform:ro -v $test_dir:/etc/sonic -v $test_dir:/sonic sonic-configdb-utils:local generate
77

88
if [[ $(diff $test_dir/expected.json $test_dir/config_db.json) ]]; then
99
echo TEST in $test_dir FAILED
@@ -12,7 +12,7 @@ function test() {
1212
exit 1
1313
fi
1414

15-
rm $test_dir/config_db.json
15+
rm -f $test_dir/config_db.json
1616
}
1717

1818
test $(pwd)/tests/1

0 commit comments

Comments
 (0)