Add action for towncrier build draft changelog #149
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
# Limited unit testing of the actions | |
on: | |
pull_request: | |
env: | |
FORCE_COLOR: 2 | |
jobs: | |
test-main: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Install | |
run: npm install | |
- name: Style test | |
env: | |
DEBUG: eslint:eslint | |
run: npm run lint | |
- name: Other setup | |
run: echo ".github/test_bin" >> $GITHUB_PATH | |
- name: Test "cmp_py_versions" | |
run: | | |
assert_equal "$( ./bin/cmp_py_versions '8.0.0' '8' )" "" | |
assert_equal "$( ./bin/cmp_py_versions '8.0a3' '8.0.1' )" "8.0a3 not equal to 8.0.1" | |
if [[ $( ./bin/cmp_py_versions "8.O.1" "8.O.1" 2> out.stderr ) ]]; then | |
echo "::error:: Invalid version number 8.O.1 did not throw error" | |
exit 1 | |
fi | |
exact_grep "InvalidVersion" out.stderr | |
- name: Run "configure-git" | |
uses: ./configure-git | |
- name: Test "configure-git" | |
run: | | |
echo "Somehow, Palpatine returned" >> README.md | |
# If configure-git didn't work, commit will fail: | |
git commit -a -m "Test commit" | |
- name: Unit tests | |
run: npm run test | |
test-stage-1: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
project-file: ['setup.py', 'setup.cfg', 'pyproject.toml'] | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Other setup | |
run: echo ".github/test_bin" >> $GITHUB_PATH | |
- name: Run "sanitize-inputs" | |
uses: ./stage-1/sanitize-inputs | |
with: | |
version: ' 9.2.3 ' | |
branch: " master " | |
- name: Test "sanitize-inputs" result | |
run: | | |
assert_equal "$VERSION" '9.2.3' | |
assert_equal "$BASE_REF" 'master' | |
- name: Run "checkout-pr-branch" | |
uses: ./stage-1/checkout-pr-branch | |
- name: Test "checkout-pr-branch" result | |
run: | | |
assert_equal "$HEAD_REF" 'prepare-9.2.3' | |
assert_equal "$( git branch --show-current )" 'prepare-9.2.3' | |
- name: Setup mock project files | |
run: | | |
cp .github/test_files/__init__.py ./__init__.py | |
cp .github/test_files/CHANGES.md ./CHANGES.md | |
cp .github/test_files/${{ matrix.project-file }} ./${{ matrix.project-file }} | |
echo "[command]git add ."; git add . | |
echo "[command]git commit" | |
git commit -m "Setup test files" | |
- name: Run "set-python-package-version" | |
id: set-package-version | |
uses: ./stage-1/set-python-package-version | |
with: | |
# Note this will check the published versions of the old isodatetime package on PyPI. | |
# The choice of package to check is arbitrary for this test, as long as it doesn't have a version 9.2.3 | |
pypi-package-name: 'isodatetime' | |
init-file: '__init__.py' | |
- name: Test "set-python-package-version" result | |
run: | | |
python -c " | |
from __init__ import __version__ | |
assert __version__ == '9.2.3', f'::error:: assert version {__version__} == 9.2.3' | |
" | |
package_version='${{ steps.set-package-version.outputs.package-version }}' | |
assert_equal "$package_version" "1!9.2.3" | |
# Check changes to init file are staged | |
exact_grep "M __init__.py" <(git status -s) | |
- name: Run "update-changelog-release-date" | |
uses: ./stage-1/update-changelog-release-date | |
with: | |
changelog-file: CHANGES.md | |
- name: Test "update-changelog-release-date" result | |
run: | | |
date_now=$( date '+%Y-%m-%d' --utc ) | |
exact_grep "## isodatetime 2.1.0 (<span actions:bind='release-date'>Released $date_now</span>)" CHANGES.md | |
# Check only the topmost entry above had its date updated | |
exact_grep "## isodatetime 2.0.2 (<span actions:bind='release-date'>Released 2020-07-01</span>)" CHANGES.md | |
# Check changes to changelog are staged | |
exact_grep "M CHANGES.md" <(git status -s) | |
test-set-meta-releases: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: checkout repo | |
uses: actions/checkout@v4 | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: run | |
id: test-set-meta-releases | |
uses: ./set-meta-releases | |
- name: check | |
shell: python | |
run: | | |
import json | |
meta_releases_list = json.loads('${{ steps.test-set-meta-releases.outputs.meta-releases }}') | |
assert isinstance(meta_releases_list, list) | |
assert len(meta_releases_list) > 0 | |
meta_releases_dict = json.loads('${{ steps.test-set-meta-releases.outputs.meta-releases-dict }}') | |
assert isinstance(meta_releases_dict, dict) | |
assert len(meta_releases_dict) > 0 |