ci: run tests in docker build stage
This commit is contained in:
parent
ab1c9e431a
commit
c0cdcc7e64
@ -1,4 +1,4 @@
|
|||||||
FROM registry.bstein.dev/bstein/python:3.12-slim
|
FROM registry.bstein.dev/bstein/python:3.12-slim AS base
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1
|
PYTHONUNBUFFERED=1
|
||||||
@ -9,5 +9,11 @@ RUN pip install --no-cache-dir -r /app/requirements.txt
|
|||||||
|
|
||||||
COPY atlasbot /app/atlasbot
|
COPY atlasbot /app/atlasbot
|
||||||
|
|
||||||
|
FROM base AS test
|
||||||
|
COPY requirements-dev.txt /app/requirements-dev.txt
|
||||||
|
RUN pip install --no-cache-dir -r /app/requirements-dev.txt
|
||||||
|
COPY tests /app/tests
|
||||||
|
|
||||||
|
FROM base AS runtime
|
||||||
EXPOSE 8090
|
EXPOSE 8090
|
||||||
CMD ["python", "-m", "atlasbot.main"]
|
CMD ["python", "-m", "atlasbot.main"]
|
||||||
|
|||||||
51
Jenkinsfile
vendored
51
Jenkinsfile
vendored
@ -77,29 +77,6 @@ spec:
|
|||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Unit tests') {
|
|
||||||
steps {
|
|
||||||
container('tester') {
|
|
||||||
sh '''
|
|
||||||
set -euo pipefail
|
|
||||||
python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
|
|
||||||
python -m ruff check atlasbot --select C90,PLR
|
|
||||||
mkdir -p build
|
|
||||||
python -m slipcover --json --out build/coverage.json --source atlasbot --fail-under 90 -m pytest -q --junitxml build/junit.xml
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Publish test metrics') {
|
|
||||||
steps {
|
|
||||||
container('tester') {
|
|
||||||
sh '''
|
|
||||||
set -euo pipefail
|
|
||||||
python scripts/publish_test_metrics.py
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Prep toolchain') {
|
stage('Prep toolchain') {
|
||||||
steps {
|
steps {
|
||||||
container('builder') {
|
container('builder') {
|
||||||
@ -142,6 +119,33 @@ spec:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Unit tests') {
|
||||||
|
steps {
|
||||||
|
container('builder') {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p build
|
||||||
|
docker buildx build --platform linux/arm64 --target test --load -t atlasbot-test .
|
||||||
|
docker run --rm -v "$PWD/build:/out" atlasbot-test \
|
||||||
|
python -m ruff check atlasbot --select C90,PLR
|
||||||
|
docker run --rm -v "$PWD/build:/out" atlasbot-test \
|
||||||
|
python -m slipcover --json --out /out/coverage.json --source atlasbot --fail-under 90 \
|
||||||
|
-m pytest -q --junitxml /out/junit.xml
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Publish test metrics') {
|
||||||
|
steps {
|
||||||
|
container('builder') {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
docker run --rm -v "$PWD/build:/out" atlasbot-test \
|
||||||
|
python scripts/publish_test_metrics.py
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Build & push image') {
|
stage('Build & push image') {
|
||||||
steps {
|
steps {
|
||||||
container('builder') {
|
container('builder') {
|
||||||
@ -149,6 +153,7 @@ spec:
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
VERSION_TAG=$(cut -d= -f2 build.env)
|
VERSION_TAG=$(cut -d= -f2 build.env)
|
||||||
docker buildx build --platform linux/arm64 \
|
docker buildx build --platform linux/arm64 \
|
||||||
|
--target runtime \
|
||||||
--tag registry.bstein.dev/bstein/atlasbot:${VERSION_TAG} \
|
--tag registry.bstein.dev/bstein/atlasbot:${VERSION_TAG} \
|
||||||
--tag registry.bstein.dev/bstein/atlasbot:latest \
|
--tag registry.bstein.dev/bstein/atlasbot:latest \
|
||||||
--push .
|
--push .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user