Skip to content

Commit bf3c090

Browse files
Initial commit
0 parents  commit bf3c090

16 files changed

Lines changed: 245 additions & 0 deletions

File tree

.devcontainer/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Devcontainer Configuration
2+
3+
This folder contains configuration files required for Codespaces/devcontainers.
4+
Please do not modify its contents unless you know what you are doing and there
5+
is a specific change to the devcontainer configuration you need to make.
6+
7+
If you believe you have a broken configuration or are unsure if you have the
8+
latest version of the configuration, please follow the
9+
[instructions to add codespaces to your project](https://docs.opensafely.org/getting-started/how-to/add-github-codespaces-to-your-project/).

.devcontainer/devcontainer.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "OpenSAFELY",
5+
"image": "ghcr.io/opensafely-core/research-template:v0",
6+
// Features to add to the dev container. More info: https://containers.dev/features.
7+
"features": {
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9+
},
10+
"postCreateCommand": "/bin/bash /opt/devcontainer/postCreate.sh ${containerWorkspaceFolder}",
11+
"postAttachCommand": "/bin/bash /opt/devcontainer/postAttach.sh",
12+
"forwardPorts": [
13+
8787
14+
],
15+
"portsAttributes": {
16+
"8787": {
17+
"label": "RStudio IDE"
18+
}
19+
},
20+
// Configure tool-specific properties.
21+
"customizations": {
22+
"codespaces": {
23+
"repositories": {
24+
"opensafely/server-instructions": {
25+
"permissions": {
26+
"contents": "read"
27+
}
28+
}
29+
}
30+
},
31+
"vscode": {
32+
"extensions": [
33+
"ms-python.python",
34+
"ms-toolsai.jupyter",
35+
"ms-toolsai.jupyter-renderers",
36+
"bennettoxford.opensafely"
37+
],
38+
"settings": {
39+
"extensions.ignoreRecommendations": true,
40+
"files.autoSave": "afterDelay",
41+
"files.autoSaveDelay": 1000,
42+
"git.autofetch": true,
43+
"python.analysis.extraPaths": [".devcontainer/ehrql-main/"],
44+
"python.defaultInterpreterPath": "/opt/venv/bin/python",
45+
"python.terminal.activateEnvInCurrentTerminal": true,
46+
"python.terminal.activateEnvironment": true,
47+
"window.autoDetectColorScheme": true
48+
}
49+
}
50+
},
51+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
52+
// "remoteUser": "root"
53+
"remoteEnv": {
54+
"MAX_WORKERS": "2"
55+
}
56+
}

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# ensure unix line endings on windows for files that need them.
5+
*.sh eol=lf
6+
codelists/* eol=lf

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"

.github/workflows/setup.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Setup repository
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [main]
6+
permissions:
7+
contents: write
8+
jobs:
9+
setup:
10+
name: Initialise OpenSAFELY project.
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
- name: Update README.md and remove action
15+
shell: bash
16+
run: |
17+
export GITHUB_REPOSITORY_OWNER="$(echo $GITHUB_REPOSITORY | awk -F/ '{print $1}')"
18+
export GITHUB_REPOSITORY_NAME="$(echo $GITHUB_REPOSITORY | awk -F/ '{print $2}')"
19+
envsubst < README.md > tmp && mv tmp README.md
20+
rm .github/workflows/setup.yaml
21+
- name: Do not run on template repository
22+
id: is_template
23+
# The only way to trigger this to run when used as a template is on
24+
# push to main. But that means it would also trigger when we push to
25+
# the template repo itself, which we do not want. So, check if we are
26+
# in a template repo
27+
run: |
28+
is_template=false
29+
curl --silent -X GET \
30+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
31+
-H "Accept: application/vnd.github.baptiste-preview+json" \
32+
https://api.github.com/repos/$GITHUB_REPOSITORY \
33+
| jq --exit-status '.is_template == false' || is_template=true
34+
# output true/false so later actions can be skipped
35+
echo "::set-output name=is_template::$is_template"
36+
- name: Commit changes
37+
# only actually commit the changes if this is not a template repo
38+
if: steps.is_template.outputs.is_template == 'false'
39+
run: |
40+
# use the same author as the initial commit
41+
git config user.email "$(git log -1 --pretty=format:'%ae')"
42+
git config user.name "$(git log -1 --pretty=format:'%an')"
43+
git add .
44+
git commit --amend --no-edit
45+
git push origin $GITHUB_REF --force

.github/workflows/test_runner.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Test that the project is runnable
2+
3+
on: [push, workflow_dispatch]
4+
env:
5+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6+
DOCKER_RO_TOKEN: ${{ secrets.DOCKER_RO_TOKEN }}
7+
STATA_LICENSE: ${{ secrets.STATA_LICENSE }}
8+
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
name: Test the project can run, using dummy data
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v6
16+
- name: Test that the project is runnable
17+
uses: opensafely-core/research-action@v2

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*~
2+
model.log
3+
*/input.csv
4+
__pycache__
5+
.python-version
6+
/output/*
7+
metadata/*
8+
venv/
9+
.DS_Store
10+
.Rhistory
11+
.Rproj.user/
12+
.devcontainer/ehrql-main/

.vscode/tasks.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "OpenSAFELY run project",
8+
"type": "shell",
9+
"command": "opensafely run run_all -f",
10+
"problemMatcher": [],
11+
"group": {
12+
"kind": "build",
13+
"isDefault": true
14+
},
15+
"presentation": {
16+
"echo": true,
17+
"reveal": "always",
18+
"focus": true,
19+
"panel": "new",
20+
"showReuseMessage": false,
21+
"clear": true,
22+
}
23+
}
24+
]
25+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) {{current_year}} {{organisation}}
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ${GITHUB_REPOSITORY_NAME}
2+
3+
[View on OpenSAFELY](https://jobs.opensafely.org/repo/https%253A%252F%252Fgithub.com%252Fopensafely%252F${GITHUB_REPOSITORY_NAME})
4+
5+
Details of the purpose and any published outputs from this project can be found at the link above.
6+
7+
The contents of this repository MUST NOT be considered an accurate or valid representation of the study or its purpose.
8+
This repository may reflect an incomplete or incorrect analysis with no further ongoing work.
9+
The content has ONLY been made public to support the OpenSAFELY [open science and transparency principles](https://www.opensafely.org/about/#contributing-to-best-practice-around-open-science) and to support the sharing of re-usable code for other subsequent users.
10+
No clinical, policy or safety conclusions must be drawn from the contents of this repository.
11+
12+
# About the OpenSAFELY framework
13+
14+
The OpenSAFELY framework is a Trusted Research Environment (TRE) for electronic
15+
health records research in the NHS, with a focus on public accountability and
16+
research quality.
17+
18+
Read more at [OpenSAFELY.org](https://opensafely.org).
19+
20+
# Licences
21+
As standard, research projects have a MIT license.

0 commit comments

Comments
 (0)