Skip to content

Feat: devcontainer pytest integration #442

Feat: devcontainer pytest integration

Feat: devcontainer pytest integration #442

Workflow file for this run

# Github Actions Workflow for CI
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
actions: read
checks: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Install requirements
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run ruff linter
# files under venv will be automatically excluded from ruff check by default https://docs.astral.sh/ruff/settings/#exclude
run: |
source venv/bin/activate
ruff check --output-format github
- name: Setup .env file
run: cp .env.example .env
- name: Build and run pytest (cpu-project)
uses: devcontainers/ci@v0.3
with:
configFile: src/sample_cpu_project/.devcontainer/devcontainer.json
push: never
runCmd: |
WORKSPACE_ROOT=$(pwd)
cd src/sample_cpu_project
COVERAGE_FILE=/tmp/.coverage pytest tests/ \
--junitxml=/tmp/test-results-cpu.xml \
-o junit_suite_name=cpu-project \
--doctest-modules \
--cov=. \
--cov-config=${WORKSPACE_ROOT}/pyproject.toml \
--cov-report=xml:/tmp/coverage-cpu.xml
sed -i 's|<package name=\".\"|<package name=\"cpu-project\"|g' /tmp/coverage-cpu.xml
sudo cp /tmp/test-results-cpu.xml ${WORKSPACE_ROOT}/test-results-cpu.xml
sudo cp /tmp/coverage-cpu.xml ${WORKSPACE_ROOT}/coverage-cpu.xml
- name: Build and run pytest (gpu-project)
uses: devcontainers/ci@v0.3
with:
configFile: src/sample_pytorch_gpu_project/.devcontainer/devcontainer.json
push: never
runCmd: |
WORKSPACE_ROOT=$(pwd)
cd src/sample_pytorch_gpu_project
COVERAGE_FILE=/tmp/.coverage pytest tests/ \
--junitxml=/tmp/test-results-gpu.xml \
-o junit_suite_name=gpu-project \
--doctest-modules \
--cov=. \
--cov-config=${WORKSPACE_ROOT}/pyproject.toml \
--cov-report=xml:/tmp/coverage-gpu.xml
sed -i 's|<package name=\".\"|<package name=\"gpu-project\"|g' /tmp/coverage-gpu.xml
sudo cp /tmp/test-results-gpu.xml ${WORKSPACE_ROOT}/test-results-gpu.xml
sudo cp /tmp/coverage-gpu.xml ${WORKSPACE_ROOT}/coverage-gpu.xml
- name: Build and smoke test notebooks devcontainer
uses: devcontainers/ci@v0.3
with:
configFile: notebooks/.devcontainer/devcontainer.json
push: never
runCmd: |
python --version
pytest --version
- name: Publish Test Results
uses: dorny/test-reporter@v2
if: always()
with:
name: pytest
path: 'test-results-*.xml'
reporter: java-junit
- name: Publish Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
badge: true
output: both
format: markdown
filename: 'coverage-*.xml'
- name: Add code coverage summary markdown to github step summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Archive test and code coverage results
uses: actions/upload-artifact@v7
with:
name: test-and-coverage-results
path: |
test-results-*.xml
coverage-*.xml