[#81] makefile to check for unused test data
This change adds logic to the docker-image-unit-tests to ensure that code is checked within the container for coverage, valid test data, and reduces the number of containers created in the gate - reducing the runtime of each gate. Relates-To: #81 Change-Id: Iab3d9bd74266d32404e6eb06ecebc234df04fd5c Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
parent
d852d2db1a
commit
abb28716c8
@ -11,7 +11,7 @@ RUN go mod download
|
||||
|
||||
COPY . /usr/src/airshipctl/
|
||||
ARG MAKE_TARGET=build
|
||||
RUN make ${MAKE_TARGET}
|
||||
RUN for target in $MAKE_TARGET; do make $target; done
|
||||
|
||||
FROM ${RELEASE_IMAGE} as release
|
||||
COPY --from=builder /usr/src/airshipctl/bin/airshipctl /usr/local/bin/airshipctl
|
||||
|
10
Makefile
10
Makefile
@ -127,6 +127,11 @@ endif
|
||||
print-docker-image-tag:
|
||||
@echo "$(DOCKER_IMAGE)"
|
||||
|
||||
.PHONY: docker-image-test-suite
|
||||
docker-image-test-suite: DOCKER_MAKE_TARGET = "lint cover update-golden check-git-diff"
|
||||
docker-image-test-suite: DOCKER_TARGET_STAGE = builder
|
||||
docker-image-test-suite: docker-image
|
||||
|
||||
.PHONY: docker-image-unit-tests
|
||||
docker-image-unit-tests: DOCKER_MAKE_TARGET = cover
|
||||
docker-image-unit-tests: DOCKER_TARGET_STAGE = builder
|
||||
@ -176,3 +181,8 @@ update-golden: unit-tests
|
||||
.PHONY: delete-golden
|
||||
delete-golden:
|
||||
@find . -type f -name "*.golden" -delete
|
||||
|
||||
# Used by gates after unit-tests and update-golden targets to ensure no files are deleted.
|
||||
.PHONY: check-git-diff
|
||||
check-git-diff:
|
||||
@./tools/git_diff_check
|
@ -12,16 +12,9 @@
|
||||
|
||||
- hosts: primary
|
||||
tasks:
|
||||
- name: Run Linter
|
||||
- name: Run Linter, Unit Tests, Verify Golden Testdata
|
||||
block:
|
||||
- name: "make docker-image-lint"
|
||||
- name: "make docker-image-test-suite"
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
target: docker-image-lint
|
||||
|
||||
- name: Run Unit Tests
|
||||
block:
|
||||
- name: "make docker-image-unit-tests"
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
target: docker-image-unit-tests
|
||||
target: docker-image-test-suite
|
||||
|
34
tools/git_diff_check
Executable file
34
tools/git_diff_check
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# Update git index
|
||||
git update-index -q --ignore-submodules --refresh
|
||||
|
||||
# Evaluate git files for difference, if found print message and fail.
|
||||
git diff-files --quiet --ignore-submodules
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "git diff found modified test cases, please run make update-golden"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Evaluate git index for differences, if found print message and fail.
|
||||
git diff-index --cached --quiet --ignore-submodules HEAD --
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "git diff found modified test cases, please run make update-golden"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "no git diff detected, make target completed successfully"
|
Loading…
Reference in New Issue
Block a user