feat: use a non-root user the Dev Container (#287) #786
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test-copier: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.10", "3.11", "3.12", "3.13"] | |
project-type: ["app", "package"] | |
typing: ["optional", "strict"] | |
name: "Copier: Python ${{ matrix.python-version }} ${{ matrix.project-type }} with ${{ matrix.typing }} typing" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: substrate | |
- name: Set up uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "**/uv.lock" | |
- name: Scaffold Python project | |
run: | | |
uvx copier copy --vcs-ref=HEAD substrate my-project \ | |
--defaults \ | |
--data project_type="${{ matrix.project-type }}" \ | |
--data project_name="My Project" \ | |
--data project_description="A Python ${{ matrix.project-type }} that reticulates splines." \ | |
--data project_url="https://github.com/user/repo" \ | |
--data author_name="John Smith" \ | |
--data author_email="[email protected]" \ | |
--data python_version="3.10" \ | |
--data typing="${{ matrix.typing }}" \ | |
--data with_fastapi_api=true \ | |
--data with_typer_cli=true | |
cd my-project | |
git config --global init.defaultBranch main | |
git init | |
git checkout -b test | |
git add . | |
- name: Lint and test project | |
uses: devcontainers/[email protected] | |
with: | |
subFolder: ./my-project/ | |
runCmd: | | |
uv lock | |
poe lint | |
poe test | |
- name: Build app Docker image | |
if: ${{ matrix.project-type == 'app' }} | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./my-project/ | |
target: app | |
test-cookiecutter: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.10", "3.13"] | |
project-type: ["app", "package"] | |
name: "Cookiecutter: Python ${{ matrix.python-version }} ${{ matrix.project-type }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: poetry-cookiecutter | |
- name: Set up uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "**/uv.lock" | |
- name: Scaffold Python project | |
run: | | |
uvx cruft create --no-input --extra-context '{"project_type": "${{ matrix.project-type }}", "project_name": "My Project", "python_version": "3.10", "__docker_image":"superlinear/python-gpu:$PYTHON_VERSION-cuda11.8", "with_fastapi_api": "1", "with_typer_cli": "1"}' ./poetry-cookiecutter/ | |
cd my-project | |
git config --global init.defaultBranch main | |
git init | |
git checkout -b test | |
git add . | |
- name: Lint and test project | |
uses: devcontainers/[email protected] | |
with: | |
subFolder: ./my-project/ | |
runCmd: | | |
poe lint | |
poe test | |
- name: Build app Docker image | |
if: ${{ matrix.project-type == 'app' }} | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./my-project/ | |
target: app |