Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ghickman committed Oct 31, 2023
0 parents commit 176bd18
Show file tree
Hide file tree
Showing 17 changed files with 773 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git/

**/*~
**/.#*
**/*#
**/htmlcov
**/__pycache__
**/*.pyc
**/.python-version
**/.env
**/.venv
**/venv
**/.coverage
**/*.egg-info/
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 20

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
9 changes: 9 additions & 0 deletions .github/workflows/auto-merge-dependabot-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Auto merge Dependabot PRs

on: pull_request

jobs:
auto-merge-dependabot-prs:
uses: opensafely-core/.github/.github/workflows/auto-merge-dependabot-prs.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: CI

on:
push:

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: "opensafely-core/setup-action@v1"
with:
python-version: "3.11"
install-just: true
- name: Check formatting, linting and import sorting
run: just check

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: "opensafely-core/setup-action@v1"
with:
python-version: "3.11"
install-just: true
- name: Run tests
# env: # Add environment variables required for tests
run: |
just test
lint-dockerfile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
with:
failure-threshold: error
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Created by https://www.toptal.com/developers/gitignore/api/osx,macos,linux,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=osx,macos,linux,windows

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### OSX ###
# General

# Icon must end with two \r

# Thumbnails

# Files that might appear in the root of a volume

# Directories potentially created on remote AFP share

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/osx,macos,linux,windows

# Python
__pycache__
.python-version
*.pyc

# Coverage
.coverage
htmlcov

# IDEs
.idea/


# Virtual environments
.venv/
venv/

.pytest-cache/
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
default_language_version:
python: python3.11

repos:
- repo: local
hooks:
- id: black
name: black
entry: just black
language: system
types: [python]
require_serial: true
- id: ruff
name: ruff
entry: just ruff
language: system
types: [python]
require_serial: true

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
- id: detect-private-key

- repo: https://github.com/stratasan/hadolint-pre-commit
rev: cdefcb0
hooks:
- id: hadolint
34 changes: 34 additions & 0 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Notes for developers

## System requirements

### just

```sh
# macOS
brew install just

# Linux
# Install from https://github.com/casey/just/releases

# Add completion for your shell. E.g. for bash:
source <(just --completions bash)

# Show all available commands
just # shortcut for just --list
```


## Local development environment


Set up a local development environment with:
```
just dev_setup
```

## Tests
Run the tests with:
```
just test <args>
```
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# All Dockerfiles should start from this base image
# Provide the TAG environment variable, or replace with the image version required
FROM ghcr.io/opensafely-core/base-docker:$TAG
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
${GITHUB_REPOSITORY_NAME}
Copyright (C) University of Oxford

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# metrics

This is a template for an OpenSAFELY Core repository.

Put your project description here.

New repo checklist:
- [ ] Does the repo require a Dockerfile?
If not, delete:
- Dockerfile -
- .dockerignore
- hadolint pre-commit hook from `.pre-commit-config.yaml`
- `lint-dockerfile` action from `.github/workflows/main.yml`
- [ ] Is this a Django project?
If so, you probably need to add the following per-file ignores to `.flake8`
```
per-file-ignores =
manage.py:INP001
gunicorn.conf.py:INP001
```
- [ ] Will this project be installed with pip?
If so, delete `requirements.prod.in` and switch references in the `justfile` to `pyproject.toml`
- [ ] Update DEVELOPERS.md with any project-specific requirements and commands
- [ ] Update commands in `justfile`


## Developer docs

Please see the [additional information](DEVELOPERS.md).
Loading

0 comments on commit 176bd18

Please sign in to comment.