Skip to content

Commit

Permalink
Add repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Oct 18, 2022
0 parents commit e8a5e58
Show file tree
Hide file tree
Showing 42 changed files with 33,567 additions and 0 deletions.
Empty file added .github/ISSUE_TEMPLATE.md
Empty file.
27 changes: 27 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Thanks for contributing! Please remove any top-level sections that do not apply to your changes.

- [ ] `make format && make documentation` has been run.

# New variable

- [ ] Label field added
- [ ] Documentation field added
- [ ] Unit field added
- [ ] Default value field added if relevant
- [ ] Variable name follows conventions
- [ ] Unit test(s) added
- [ ] Integration test(s) added if relevant
- [ ] Issues this PR fixes linked

## What's changed

Description of the changes here.

# Bug fix

- [ ] Regression test added
- [ ] Regression test passing

## What this fixes and how it's fixed

Description of how this fix works goes here. Link any issues this PR fixes.
8 changes: 8 additions & 0 deletions .github/changelog_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

{{changelog}}
4 changes: 4 additions & 0 deletions .github/get-changelog-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
git remote add upstream https://github.com/policyengine/policyengine-core
git fetch --tags upstream
last_tagged_commit=`git describe --tags --abbrev=0 --first-parent`
git --no-pager diff $last_tagged_commit -- CHANGELOG.md
12 changes: 12 additions & 0 deletions .github/has-functional-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env bash

IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore LICENSE* .github/* environment.yml"

last_tagged_commit=$(git describe --tags --abbrev=0 --first-parent) # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit

if git diff-index --name-only --exit-code $last_tagged_commit -- . $(echo " $IGNORE_DIFF_ON" | sed 's/ / :(exclude)/g'); then # Check if any file that has not be listed in IGNORE_DIFF_ON has changed since the last tag was published.
echo "No functional changes detected."
exit 1
else
echo "The functional files above were changed."
fi
33 changes: 33 additions & 0 deletions .github/is-version-number-acceptable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /usr/bin/env bash

if [[ ${GITHUB_REF#refs/heads/} == master ]]
then
echo "No need for a version check on master."
exit 0
fi

if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh
then
echo "No need for a version update."
exit 0
fi

current_version=`python setup.py --version`

if git rev-parse --verify --quiet $current_version
then
echo "Version $current_version already exists in commit:"
git --no-pager log -1 $current_version
echo
echo "Update the version number in setup.py before merging this branch into master."
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
exit 1
fi

if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELOG.md
then
echo "CHANGELOG.md has not been modified, while functional changes were made."
echo "Explain what you changed before merging this branch into master."
echo "Look at the CONTRIBUTING.md file to learn how to write the changelog."
exit 2
fi
4 changes: 4 additions & 0 deletions .github/publish-git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

git tag `python setup.py --version`
git push --tags || true # update the repository version
53 changes: 53 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Pull request
on:
pull_request:
branches: [master]
jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check formatting
uses: "lgeiger/black-action@master"
with:
args: ". -l 79 --check"
check-version:
name: Check version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Build changelog
run: pip install yaml-changelog>=0.1.7 && make changelog
- name: Preview changelog update
run: ".github/get-changelog-diff.sh"
- name: Check version number has been properly updated
run: .github/is-version-number-acceptable.sh
Test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install package
run: make install
- name: Run tests
run: make test
- uses: codecov/codecov-action@v3
- name: Build package
run: make build
- name: Test documentation builds
run: make documentation
97 changes: 97 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Push
on:
push:
branches: [master]
jobs:
Lint:
runs-on: ubuntu-latest
if: |
(github.repository == 'PolicyEngine/policyengine-canada')
&& (github.event.head_commit.message == 'Update PolicyEngine Canada')
steps:
- uses: actions/checkout@v3
- name: Check formatting
uses: "lgeiger/black-action@master"
with:
args: ". -l 79 --check"
versioning:
name: Update versioning
if: |
(github.repository == 'PolicyEngine/policyengine-canada')
&& !(github.event.head_commit.message == 'Update PolicyEngine Canada')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.POLICYENGINE_GITHUB }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Build changelog
run: pip install yaml-changelog && make changelog
- name: Preview changelog update
run: ".github/get-changelog-diff.sh"
- name: Update changelog
uses: EndBug/add-and-commit@v9
with:
add: "."
committer_name: Github Actions[bot]
author_name: Github Actions[bot]
message: Update PolicyEngine Canada
Test:
runs-on: ${{ matrix.os }}
if: |
(github.repository == 'PolicyEngine/policyengine-canada')
&& (github.event.head_commit.message == 'Update PolicyEngine Canada')
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install package
run: make install
- name: Run tests
run: make test
- uses: codecov/codecov-action@v3
- name: Generate documentation
run: make documentation
- name: Deploy documentation
if: matrix.os == 'ubuntu-latest'
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/_build/html # The folder the action should deploy.
Publish:
runs-on: ubuntu-latest
if: |
(github.repository == 'PolicyEngine/policyengine-canada')
&& (github.event.head_commit.message == 'Update PolicyEngine Canada')
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Publish a git tag
run: ".github/publish-git-tag.sh || true"
- name: Install package
run: make install
- name: Build package
run: make build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI }}
skip_existing: true
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/__pycache__
**/*.egg-info
coverage.xml
.coverage
build/
dist/
docs/_build/
**/*.ipynb_checkpoints/
**/*.h5
**/iframe_figures/
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
34 changes: 34 additions & 0 deletions .vscode/python.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"PolicyEngine CA Variable": {
"prefix": "var",
"body": [
"class ${1:name}(Variable):",
" value_type = ${2:float}",
" entity = ${3:Person}",
" label = \"${4:Label}\"",
" unit = ${5:CAD}",
" documentation = \"${6:Description}\"",
" definition_period = ${7:YEAR}",
"",
""
],
"description": "Insert a new OpenFisca Variable, without a formula."
},
"PolicyEngine CA Formula": {
"prefix": "form",
"body": [
"def formula(${1:person}, period, parameters):",
" ${2:pass}"
],
"description": "Insert a new OpenFisca Formula."
},
"PolicyEngine CA module": {
"prefix": "file",
"body": [
"from policyengine_canada.model_api import *",
"",
"",
"$0"
]
},
}
30 changes: 30 additions & 0 deletions .vscode/yaml.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Insert PolicyEngine CA basic parameter": {
"prefix": "param",
"body": [
"description: ${1:Description}",
"values:",
" 2022-01-01: ${2:0.00}",
"metadata:",
" unit: currency-CAD",
" name: ${3:name}",
" label: ${4:Label}",
" reference:",
" - title: ${5:Title}",
" href: ${6:https://example.com}",
],
"description": "Insert a basic PolicyEngine CA parameter."
},
"Insert PolicyEngine CA basic test": {
"prefix": "test",
"body": [
"- name: ${1:Name}",
" period: 2022",
" input:",
" ${3:variable values here}",
" output:",
" ${4:expected output here}"
],
"description": "Insert a basic PolicyEngine CA parameter for one person."
}
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Loading

0 comments on commit e8a5e58

Please sign in to comment.