Skip to content

Commit

Permalink
Update references to setup.py (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiSG authored Apr 26, 2024
2 parents 78815c0 + 2c70fce commit 664ac0d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/has-functional-changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

last_tagged_commit=$(git describe --tags --abbrev=0 --first-parent) # --first-parent ensures we don't follow tags not published in main through an unlikely intermediary merge commit
last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in main 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
Expand Down
12 changes: 9 additions & 3 deletions .github/is-version-number-acceptable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ then
exit 0
fi

current_version=$(python setup.py --version)
current_version=$(grep '^version =' pyproject.toml | cut -d '"' -f 2) # parsing with tomllib is complicated, see https://github.com/python-poetry/poetry/issues/273

if [[ ! $current_version ]]
then
echo "Error getting current version"
exit 1
fi

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 main."
echo "Update the version number in pyproject.toml before merging this branch into main."
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
exit 1
exit 2
fi

if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELOG.md
Expand Down
6 changes: 3 additions & 3 deletions .github/lint-changed-python-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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

if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py")
if ! changed_files=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py")
then
echo "Linting the following Python files:"
echo $changes
flake8 $changes
echo $changed_files
flake8 $changed_files
else echo "No changed Python files to lint"
fi
6 changes: 3 additions & 3 deletions .github/lint-changed-yaml-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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

if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "tests/*.yaml")
if ! changed_files=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "tests/*.yaml")
then
echo "Linting the following changed YAML tests:"
echo $changes
yamllint $changes
echo $changed_files
yamllint $changed_files
else echo "No changed YAML tests to lint"
fi
3 changes: 2 additions & 1 deletion .github/publish-git-tag.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env bash

git tag $(python setup.py --version)
current_version=$(grep '^version =' pyproject.toml | cut -d '"' -f 2) # parsing with tomllib is complicated, see https://github.com/python-poetry/poetry/issues/273
git tag $current_version
git push --tags # update the repository version
16 changes: 8 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }} # Cache the entire build Python environment
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} # Cache the entire build Python environment
restore-keys: |
build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
build-${{ env.pythonLocation }}-
- name: Build package
run: make build
Expand All @@ -33,7 +33,7 @@ jobs:
uses: actions/cache@v2
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}

lint-files:
runs-on: ubuntu-20.04
Expand All @@ -51,7 +51,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- run: make check-syntax-errors
- run: make check-style
- name: Lint Python files
Expand All @@ -73,7 +73,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- run: openfisca test --country-package openfisca_country_template openfisca_country_template/tests

test-api:
Expand All @@ -90,7 +90,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- name: Test the Web API
run: "${GITHUB_WORKSPACE}/.github/test-api.sh"

Expand Down Expand Up @@ -148,13 +148,13 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- name: Cache release
id: restore-release
uses: actions/cache@v2
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
- name: Upload a Python package to PyPi
run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD
- name: Publish a git tag
Expand Down
7 changes: 5 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ sed -i.template -e "1,${last_changelog_number}d" CHANGELOG.md # remove country-

echo -e "${PURPLE}* ${PURPLE}Prepare \033[0m${BLUE}pyproject.toml\033[0m"
sed -i.template "s|https://github.com/openfisca/country-template|$REPOSITORY_URL|g" pyproject.toml
sed -i.template "s|:: 5 - Production/Stable|:: 1 - Planning|g" pyproject.toml
sed -i.template 's|:: 5 - Production/Stable|:: 1 - Planning|g' pyproject.toml
sed -i.template 's|^version = "[0-9.]*"|version = "0.0.1"|g' pyproject.toml
sed -i.template "s|repository_folder|$REPOSITORY_FOLDER|g" README.md
find . -name "*.template" -type f -delete

Expand All @@ -104,7 +105,9 @@ git rm bootstrap.sh > /dev/null 2>&1
git add .
git commit --no-gpg-sign --message "$second_commit_message" --author='OpenFisca Bot <[email protected]>' --quiet

echo -e "${PURPLE}* ${PURPLE}Second git commit made to 'main' branch: '\033[0m${BLUE}$second_commit_message\033[0m${PURPLE}'\033[0m"
git tag "0.0.1"

echo -e "${PURPLE}* ${PURPLE}Second commit and first tag made on 'main' branch: '\033[0m${BLUE}$second_commit_message\033[0m${PURPLE}'\033[0m"
echo

echo -e "${YELLOW}* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \033[0m"
Expand Down

0 comments on commit 664ac0d

Please sign in to comment.