mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
skip specified tests when build snapshot image
This commit is contained in:
@@ -50,5 +50,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
platforms: ${{ vars.BUILD_SNAPSHOT_PLATFORMS }}
|
platforms: ${{ vars.BUILD_SNAPSHOT_PLATFORMS }}
|
||||||
push: true
|
push: true
|
||||||
|
build-args: |
|
||||||
|
SKIP_TESTS=${{ vars.SKIP_TESTS }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|||||||
@@ -45,5 +45,7 @@ jobs:
|
|||||||
linux/arm/v7
|
linux/arm/v7
|
||||||
linux/arm/v6
|
linux/arm/v6
|
||||||
push: true
|
push: true
|
||||||
|
build-args: |
|
||||||
|
SKIP_TESTS=${{ vars.SKIP_TESTS }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
@@ -26,3 +26,5 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
push: false
|
push: false
|
||||||
|
build-args: |
|
||||||
|
SKIP_TESTS=${{ vars.SKIP_TESTS }}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
# Build backend binary file
|
# Build backend binary file
|
||||||
FROM golang:1.22.8-alpine3.20 AS be-builder
|
FROM golang:1.22.8-alpine3.20 AS be-builder
|
||||||
ARG RELEASE_BUILD
|
ARG RELEASE_BUILD
|
||||||
|
ARG SKIP_TESTS
|
||||||
ENV RELEASE_BUILD=$RELEASE_BUILD
|
ENV RELEASE_BUILD=$RELEASE_BUILD
|
||||||
|
ENV SKIP_TESTS=$SKIP_TESTS
|
||||||
WORKDIR /go/src/github.com/mayswind/ezbookkeeping
|
WORKDIR /go/src/github.com/mayswind/ezbookkeeping
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN docker/backend-build-pre-setup.sh
|
RUN docker/backend-build-pre-setup.sh
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
set "TYPE="
|
set "TYPE="
|
||||||
set "NO_LINT=0"
|
set "NO_LINT=0"
|
||||||
set "NO_TEST=0"
|
set "NO_TEST=0"
|
||||||
|
set "SKIP_TESTS=%SKIP_TESTS%"
|
||||||
set "RELEASE=%RELEASE_BUILD%"
|
set "RELEASE=%RELEASE_BUILD%"
|
||||||
set "RELEASE_TYPE=unknown"
|
set "RELEASE_TYPE=unknown"
|
||||||
set "VERSION="
|
set "VERSION="
|
||||||
@@ -56,7 +57,7 @@ goto :pre_parse_args
|
|||||||
echo /r, --release Build release (The script will use environment variable "RELEASE_BUILD" to detect whether this is release building by default)
|
echo /r, --release Build release (The script will use environment variable "RELEASE_BUILD" to detect whether this is release building by default)
|
||||||
echo /o, --output ^<filename^> Package file name (For "package" type only)
|
echo /o, --output ^<filename^> Package file name (For "package" type only)
|
||||||
echo --no-lint Do not execute lint check before building
|
echo --no-lint Do not execute lint check before building
|
||||||
echo --no-test Do not execute unit testing before building
|
echo --no-test Do not execute unit testing before building (You can use environment variable "SKIP_TESTS" to skip specified tests)
|
||||||
echo /h, --help Show help
|
echo /h, --help Show help
|
||||||
goto :eof
|
goto :eof
|
||||||
|
|
||||||
@@ -139,7 +140,13 @@ goto :pre_parse_args
|
|||||||
if "%NO_TEST%"=="0" (
|
if "%NO_TEST%"=="0" (
|
||||||
echo Executing backend unit testing...
|
echo Executing backend unit testing...
|
||||||
call go clean -cache
|
call go clean -cache
|
||||||
call go test .\... -v
|
|
||||||
|
if "%SKIP_TESTS%"=="" (
|
||||||
|
call go test .\... -v
|
||||||
|
) else (
|
||||||
|
echo (Skip unit test "%SKIP_TESTS%")
|
||||||
|
call go test .\... -v -skip "%SKIP_TESTS%"
|
||||||
|
)
|
||||||
|
|
||||||
if !errorlevel! neq 0 (
|
if !errorlevel! neq 0 (
|
||||||
call :echo_red "Error: Failed to pass unit testing"
|
call :echo_red "Error: Failed to pass unit testing"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
TYPE=""
|
TYPE=""
|
||||||
NO_LINT="0"
|
NO_LINT="0"
|
||||||
NO_TEST="0"
|
NO_TEST="0"
|
||||||
|
SKIP_TESTS="${SKIP_TESTS}"
|
||||||
RELEASE=${RELEASE_BUILD:-"0"}
|
RELEASE=${RELEASE_BUILD:-"0"}
|
||||||
RELEASE_TYPE="unknown"
|
RELEASE_TYPE="unknown"
|
||||||
VERSION=""
|
VERSION=""
|
||||||
@@ -43,7 +44,7 @@ Options:
|
|||||||
-o, --output <filename> Package file name (For "package" type only)
|
-o, --output <filename> Package file name (For "package" type only)
|
||||||
-t, --tag Docker tag (For "docker" type only)
|
-t, --tag Docker tag (For "docker" type only)
|
||||||
--no-lint Do not execute lint check before building
|
--no-lint Do not execute lint check before building
|
||||||
--no-test Do not execute unit testing before building
|
--no-test Do not execute unit testing before building (You can use environment variable "SKIP_TESTS" to skip specified tests)
|
||||||
-h, --help Show help
|
-h, --help Show help
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@@ -137,7 +138,13 @@ build_backend() {
|
|||||||
if [ "$NO_TEST" = "0" ]; then
|
if [ "$NO_TEST" = "0" ]; then
|
||||||
echo "Executing backend unit testing..."
|
echo "Executing backend unit testing..."
|
||||||
go clean -cache
|
go clean -cache
|
||||||
go test ./... -v
|
|
||||||
|
if [ -z "$SKIP_TESTS" ]; then
|
||||||
|
go test ./... -v
|
||||||
|
else
|
||||||
|
echo "(Skip unit test \"$SKIP_TESTS\")"
|
||||||
|
go test ./... -v -skip "$SKIP_TESTS"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
echo_red "Error: Failed to pass unit testing"
|
echo_red "Error: Failed to pass unit testing"
|
||||||
|
|||||||
Reference in New Issue
Block a user