Skip to content

Commit

Permalink
Test the github action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Murray committed Jul 11, 2024
1 parent 2af7d81 commit 0471a23
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"build": {
"dockerfile": "../Dockerfile"
},
"name": "Python 3.12",
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker"
]
}
},
"postCreateCommand": "./install-dependencies.sh"
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
//"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: CI
on:
push:
branches: [main]

jobs:
lint-and-unit:
runs-on: ubuntu-latest
container: mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
steps:
- name: "Install dependencies"
run: ./install-dependencies.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,6 @@ cython_debug/

# Secrets
*.env

# taskfile.dev cache
.task/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
13 changes: 13 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pytest = "*"
flake8 = "*"

[dev-packages]

[requires]
python_version = "3.12"
87 changes: 87 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# python-vscode-devcontainer
A template for developing Python with VS Code in a Devcontainer

A template for developing Python with VS Code in a Devcontainer. Since [Hacken](https://hacken.ca) mostly uses Bitbucket Pipelines, that is supported as well as GitHub Actions.

Provides a development environment with:
- Python 3.12
- pipenv
- pytest
- flake8
- [Task](https://taskfile.dev)


Usage:
- `task flake8`
- `task test`
- `task watch`
17 changes: 17 additions & 0 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
image: python:3.12
options:
max-time: 1
pipelines:
default:
- step:
name: "Build and Test"
caches:
- pip
script:
- wget https://github.com/go-task/task/releases/download/v3.37.2/task_linux_amd64.deb
- dpkg -i task_linux_amd64.deb
- task --version
- pip install pipenv
- pipenv install --ignore-pipfile
- pipenv run task

15 changes: 15 additions & 0 deletions install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Is task already installed?
which task
rc=$?

set -e
if [ 0 -ne $rc ]; then
deb='task_linux_amd64.deb'
wget https://github.com/go-task/task/releases/download/v3.37.2/${deb}
sudo dpkg -i ${deb}
rm -f ${deb}
fi

pipenv install --ignore-pipfile
44 changes: 44 additions & 0 deletions taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# https://taskfile.dev

version: '3.37'

interval: '100ms'

vars:

tasks:
default:
desc: "Lint check and unit test"
deps: [flake8, test]

watch:
desc: "Watch flake8 and unit tests"
deps: [flake8, test]
watch: true
sources:
- '**/*.py'
- '*.yml'

flake8:
aliases: [lint]
desc: "Lint check"
watch: true
cmds:
- flake8

test:
desc: "Unit tests"
watch: true
cmds:
- pytest

kick:
desc: Kick the CICD pipeline.
vars:
KICK: "$(pwd)/.kick-pipeline"
cmds:
- |
date > {{.KICK}}
git add {{.KICK}}
git ci -m "kick"
git push
2 changes: 2 additions & 0 deletions tests/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_will_pass():
assert True

0 comments on commit 0471a23

Please sign in to comment.