Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Updating the code

Please make sure that introduced changes are consistent with the testing api and add additional tests if relevant.

## Updating the versioning

Please add to `changelog.yaml` and then run `make changelog` before committing the results ONCE in this PR.
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}}
2 changes: 2 additions & 0 deletions .github/get_changelog_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
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 docs/* .gitignore LICENSE* .github/* data/*"

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'` # Check if any file that has not be listed in IGNORE_DIFF_ON has changed since the last tag was published.
then
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 .github/fetch_version.py`

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 .github/fetch_version.py` # create a new tag
git push --tags || true # update the repository version
29 changes: 29 additions & 0 deletions .github/workflows/changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Versioning

on:
pull_request:
branches: [ main ]

jobs:
check-changelog-entry:
name: Changelog entry check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Check for changelog entry
run: |
if [ ! -f "changelog_entry.yaml" ]; then
echo "Error: changelog_entry.yaml file is missing."
echo "Please add a changelog_entry.yaml file at the root of the repository."
exit 1
fi

# Check if the file is empty
if [ ! -s "changelog_entry.yaml" ]; then
echo "Error: changelog_entry.yaml file is empty."
echo "Please add content to the changelog_entry.yaml file."
exit 1
fi

echo "Changelog entry found and is not empty."
38 changes: 38 additions & 0 deletions .github/workflows/versioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Workflow that runs on versioning metadata updates.

name: Versioning updates
on:
push:
branches:
- main

paths:
- changelog_entry.yaml
- "!pyproject.toml"

jobs:
Versioning:
runs-on: ubuntu-latest
if: |
(!(github.event.head_commit.message == 'Update package version'))
steps:
- name: Checkout repo
uses: actions/checkout@v4
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@v5
with:
python-version: 3.11
- 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: "."
message: Update package version

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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).

## [0.1.0] - 2025-06-17 00:00:00

### Added

- Initialized project




9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ build:

clean:
rm -rf dist/ build/ *.egg-info/
rm -rf docs/_build/
rm -rf docs/_build/

changelog:
build-changelog changelog.yaml --output changelog.yaml --update-last-date --start-from 0.1.0 --append-file changelog_entry.yaml
build-changelog changelog.yaml --org PolicyEngine --repo microcalibrate --output CHANGELOG.md --template .github/changelog_template.md
bump-version changelog.yaml pyproject.toml
rm changelog_entry.yaml || true
touch changelog_entry.yaml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# MicroCalibrate
5 changes: 5 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- changes:
added:
- Initialized project
date: 2025-06-17
version: 0.1.0
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
changed:
- Initialized changelog.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dev = [
"mypy>=1.0.0,<2.0.0",
"build>=1.0.0,<2.0.0",
"linecheck>=0.1.0,<0.2.0",
"yaml-changelog>=0.1.7",
]

docs = [
Expand Down