Test Changelog Entries #343
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: CI | |
on: | |
push: | |
branches: | |
- main | |
- 'dev/**' | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
pull_request: | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
check_doc_modified: ${{steps.check_doc_modified.outcome}} | |
check_changelog_modified: ${{steps.check_changelog_modified.outcome}} | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
fetch-depth: 1000 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1000 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install pkgmt | |
run: | | |
python -m pip install --upgrade pip | |
pip install git+https://github.com/neelasha23/pkgmt.git@issue76 | |
pip install "mistune>=3rc" | |
- name: Lint | |
run: | | |
pkgmt lint | |
- name: Check project | |
run: | | |
pkgmt check | |
- name: Check doc/ Modified | |
id: check_doc_modified | |
run: | | |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] | |
then | |
echo "Pull request event, checking if tests need to run..." | |
python -m pkgmt.fail_if_modified -b origin/main -e doc -e CHANGELOG.md | |
else | |
echo "This is not a pull request event" | |
echo "Running all tests" | |
exit 1 | |
fi | |
continue-on-error: true | |
- name: Check CHANGELOG.md Modified | |
env: | |
labels_JSON: ${{ toJSON(github.event.pull_request.labels.*.name) }} | |
id: check_changelog_modified | |
run: | | |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] | |
then | |
# Check if the array contains "no-changelog" | |
if echo "$labels_JSON" | jq '. | contains(["no-changelog"])' | grep -q true; then | |
echo "PR contains no-changelog label" | |
else | |
echo "PR does not contain no-changelog label"; | |
echo "Checking if changelog is modified"; | |
echo "If this test fails add the no-changelog label to the PR or modify the changelog" | |
python -m pkgmt.fail_if_invalid_changelog -b origin/main -i CHANGELOG.md | |
fi | |
else | |
exit 0 | |
fi | |
test: | |
needs: [check] | |
if: needs.check.outputs.check_doc_modified == 'failure' | |
strategy: | |
matrix: | |
python-version: ['3.11'] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Lint | |
run: | | |
python -m pip install --upgrade pip pkgmt | |
pkgmt lint | |
- name: Install dependencies | |
run: | | |
echo installing... | |
- name: Test with pytest | |
run: | | |
echo testing... |