Skip to content

Commit

Permalink
chore(actions): remove manual source code versioning (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
vascoalramos authored and aquemy committed Nov 22, 2022
1 parent ab0d8f5 commit 7b19239
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 78 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
49 changes: 32 additions & 17 deletions .github/workflows/merge-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,46 @@ jobs:

- name: Calculate changelog path
id: path
run: echo "$(echo "::set-output name=value::docsrc/source/pages/reference/changelog/${{ needs.prepare.outputs.release }}" | sed "s/\./_/g").rst"
run: echo "value=$(echo "${{ needs.prepare.outputs.release }}" | sed "s/\./_/g").md" >> $GITHUB_OUTPUT

- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "Azory"
git config --local core.autocrlf false
- name: Convert changelog from md to rst
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git config core.autocrlf false
- name: Write changelog to file
uses: DamianReeves/write-file-action@master
with:
path: docsrc/source/pages/reference/changelog/${{ steps.path.outputs.value }}
contents: ${{ needs.prepare.outputs.release_notes }}
write-mode: overwrite

- name: Add changelog to docs
run: |
sudo apt-get install -y pandoc
echo "${{ needs.prepare.outputs.release_notes }}" \
| sed 's/# \[.*/# Changelog ${{ needs.prepare.outputs.release }}/g' \
| sed 's/## Bug Fixes/## 🐛 Bug fixes/g' \
| sed 's/## Features/## 🎉 Features/g' \
| sed 's/## BREAKING CHANGES/## 🚨 Breaking changes/g' \
| sed 's/## Documentation/## 📖 Documentation/g' \
| pandoc --from markdown --to rst --standalone > ${{ steps.path.outputs.value }}
cd docsrc/source/pages/reference
sed -i -e 's/# \[.*/# Changelog ${{ needs.prepare.outputs.release }}/g' \
-e 's/## Bug Fixes/## 🐛 Bug fixes/g' \
-e 's/## Features/## 🎉 Features/g' \
-e 's/## BREAKING CHANGES/## 🚨 Breaking changes/g' \
-e 's/## Documentation/## 📖 Documentation/g' \
changelog/${{ steps.path.outputs.value }}
grep -q ".. include:: changelog/${{ steps.path.outputs.value }}" changelog.rst || sed -i "4 a\\
.. include:: changelog\/${{ steps.path.outputs.value }}\\
:parser: myst_parser.sphinx_\\
" changelog.rst
- name: Commit changelog
id: commit
run: |
if [[ `git status --porcelain` ]]; then
echo ::set-output name=CHANGES::true
git add ${{ steps.path.outputs.value }}
echo "CHANGES=true" >> $GITHUB_OUTPUT
git add docsrc/source/pages/reference/changelog/${{ steps.path.outputs.value }}
git commit -m "[skip ci] Update changelogs" -a
else
echo ::set-output name=CHANGES::false
echo "CHANGES=false" >> $GITHUB_OUTPUT
fi
- name: Push changes
Expand All @@ -89,6 +101,8 @@ jobs:
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.ACCESS_TOKEN }}
force: true


prerelease-tag:
if: needs.prepare.outputs.new_release == 'true'
Expand Down Expand Up @@ -132,3 +146,4 @@ jobs:
release_name: ${{ needs.prepare.outputs.release }}
body: ${{ needs.prepare.outputs.release_notes }}
draft: true
commitish: master
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:

- name: Configurating Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --local core.autocrlf false
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git config core.autocrlf false
- name: Set up Python 3.8
uses: actions/setup-python@v4
Expand Down Expand Up @@ -62,16 +62,16 @@ jobs:
id: commit
run: |
if [[ `git status --porcelain --untracked-files=no` ]]; then
echo ::set-output name=CHANGES::true
echo "CHANGES=true" >> $GITHUB_OUTPUT
git add -u
git commit -m "[skip ci] Code formatting" -a
else
echo ::set-output name=CHANGES::false
echo "CHANGES=false" >> $GITHUB_OUTPUT
fi
- name: Push changes
uses: ad-m/[email protected]
if: ${{ steps.commit.outputs.CHANGES == 'true' }}
if: always() && steps.commit.outputs.CHANGES == 'true'
with:
branch: ${{ github.head_ref }}
github_token: ${{ secrets.ACCESS_TOKEN }}
46 changes: 20 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Version
id: version
run: echo "value=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -42,9 +46,7 @@ jobs:
run: make lint

- name: Build package
run: |
python setup.py sdist bdist_wheel
twine check dist/*
run: make package version=${{ steps.version.outputs.value }}

- name: Upload Pipeline Artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -96,9 +98,9 @@ jobs:

- name: Configurating Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --local core.autocrlf false
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git config core.autocrlf false
- name: Set up Python 3.8
uses: actions/setup-python@v4
Expand All @@ -117,35 +119,27 @@ jobs:

- name: Update examples
run: make examples
env:
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}

- name: Build the documentation
run: make docs

- name: Create branch name
run: |
export BRANCH_NAME="${GITHUB_REF##*/}/"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Move the changes to the gh-pages branch (release branch)
run: |
mv docs/ ${{ env.BRANCH_NAME }}
mkdir docs/
mv ${{ env.BRANCH_NAME }} docs/${{ env.BRANCH_NAME }}
mv examples/ ${{ env.BRANCH_NAME }}
mkdir examples/
mv ${{ env.BRANCH_NAME }} examples/${{ env.BRANCH_NAME }}
git add -f docs/${{ env.BRANCH_NAME }}
git add -f examples/${{ env.BRANCH_NAME }}
git stash push -- docs/ examples/${{ env.BRANCH_NAME }}
mv docs master
mkdir docs
mv master docs/master
mv examples/ master
mkdir examples
mv master examples/master
git add -f docs/master
git add -f examples/master
git stash push -- docs/master examples/master
git fetch origin gh-pages
git checkout gh-pages
git checkout -f gh-pages
touch .nojekyll
git add .nojekyll
rm -rf docs/${{ env.BRANCH_NAME }}
rm -rf examples/${{ env.BRANCH_NAME }}
rm -rf docs/master
rm -rf examples/master
git add docs/
git add examples/
git stash apply
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ examples/*/*.csv
docs/
docsrc/_build/
docsrc/source/pages/api/_autosummary/

# User created
VERSION
version.py
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
files: |
^src/|
^tests/|
files: ^src/|^tests/
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
Expand Down Expand Up @@ -30,6 +28,7 @@ repos:
rev: "0.47"
hooks:
- id: check-manifest
args: [ "--ignore=src/pandas_profiling/version.py" ]
- repo: https://github.com/PyCQA/flake8
rev: "4.0.1"
hooks:
Expand Down
3 changes: 1 addition & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
"@semantic-release/release-notes-generator"
]
}
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ test_cov:
examples:
find ./examples -maxdepth 2 -type f -name "*.py" -execdir python {} \;

package:
rm -rf build dist
echo "$(version)" > VERSION
python setup.py sdist bdist_wheel
twine check dist/*

install:
pip install -e .[notebook]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Download the source code by cloning the repository or click on [Download ZIP](ht
Install it by navigating to the proper directory and running:

```sh
python setup.py install
pip install -e .
```

The profiling report is written in HTML and CSS, which means a modern browser is required.
Expand Down
3 changes: 2 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
ignores: [(message) => message.includes('Merge branch') || message.includes('[skip ci]')],
rules: {
'body-max-line-length': [2, 'always', 120],
'footer-max-line-length': [2, 'always', 120],
},
};
};
7 changes: 6 additions & 1 deletion docsrc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _GetApiWrapperVersion():
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"recommonmark",
"myst_parser",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
Expand Down Expand Up @@ -84,3 +84,8 @@ def _GetApiWrapperVersion():
autosummary_generate = True

autodoc_pydantic_model_show_json = False

source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}
4 changes: 2 additions & 2 deletions docsrc/source/pages/reference/changelog/v3_3_1.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Changelog v3.3.1
================
----------------

🐛 Bug fixes
-----------
^^^^^^^^^^^

- remove unused imports
(`66864c1 <https://github.com/ydataai/pandas-profiling/commit/66864c15cfa9b80cb426957e17410c579425d450>`__)
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pre-commit>=2.8.2
virtualenv>=20.0.33
twine
wheel
recommonmark>=0.6.0
myst-parser>=0.18.1
sphinx_rtd_theme>=0.4.3
sphinx-autodoc-typehints>=1.10.3
sphinx-multiversion>=0.2.3
autodoc_pydantic
autodoc_pydantic
17 changes: 6 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@
with (source_root / "requirements.txt").open(encoding="utf8") as f:
requirements = f.readlines()

version = "3.4.0"
try:
version = (source_root / "VERSION").read_text().rstrip("\n")
except FileNotFoundError:
version = "dev"

with (source_root / "src" / "pandas_profiling" / "version.py").open(
"w", encoding="utf-8"
) as f:
f.writelines(
[
'"""This file is auto-generated by setup.py, please do not alter."""\n',
f'__version__ = "{version}"\n',
"",
]
)
with open(source_root / "src/pandas_profiling/version.py", "w") as version_file:
version_file.write(f'__version__ = \'{version}\'')

setup(
name="pandas-profiling",
Expand Down
2 changes: 0 additions & 2 deletions src/pandas_profiling/version.py

This file was deleted.

8 changes: 4 additions & 4 deletions tests/unit/test_pandas/test_correlations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest
from pandas_profiling.config import Settings
import pandas as pd
import numpy as np
import pandas as pd
import pytest

from pandas_profiling.config import Settings
from pandas_profiling.model.pandas.correlations_pandas import (
pandas_auto_compute,
pandas_spearman_compute,
pandas_cramers_compute,
pandas_spearman_compute,
)


Expand Down

0 comments on commit 7b19239

Please sign in to comment.