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 \
|
||||
PYTHONUNBUFFERED=1
|
||||
@ -9,5 +9,11 @@ RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
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
|
||||
CMD ["python", "-m", "atlasbot.main"]
|
||||
|
||||
51
Jenkinsfile
vendored
51
Jenkinsfile
vendored
@ -77,29 +77,6 @@ spec:
|
||||
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') {
|
||||
steps {
|
||||
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') {
|
||||
steps {
|
||||
container('builder') {
|
||||
@ -149,6 +153,7 @@ spec:
|
||||
set -euo pipefail
|
||||
VERSION_TAG=$(cut -d= -f2 build.env)
|
||||
docker buildx build --platform linux/arm64 \
|
||||
--target runtime \
|
||||
--tag registry.bstein.dev/bstein/atlasbot:${VERSION_TAG} \
|
||||
--tag registry.bstein.dev/bstein/atlasbot:latest \
|
||||
--push .
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user