-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pyproject.toml and upgrade to Python 3.10. Only support Python 3.10. Use SINTEF/ci-cd throughout where possible. More info: https://SINTEF.github.io/ci-cd Still use dependabot to update dependencies though. Update code base according to ruff and pyupgrade. Use ruff instead of pylint.
- Loading branch information
Showing
32 changed files
with
491 additions
and
1,185 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ coverage: | |
|
||
status: | ||
project: | ||
default: off | ||
default: false | ||
turtle-canon: | ||
threshold: 1% | ||
flags: | ||
|
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,117 +5,35 @@ on: | |
types: | ||
- published | ||
|
||
env: | ||
PUBLISH_UPDATE_BRANCH: main | ||
GIT_USER_NAME: CasperWA | ||
GIT_USER_EMAIL: "[email protected]" | ||
|
||
jobs: | ||
|
||
update-and-publish: | ||
name: Update CHANGELOG and documentation | ||
runs-on: ubuntu-latest | ||
publish-docs: | ||
name: External | ||
uses: SINTEF/ci-cd/.github/workflows/[email protected] | ||
if: github.repository == 'CasperWA/turtle-canon' && startsWith(github.ref, 'refs/tags/v') | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install -U pip | ||
pip install -U setuptools wheel | ||
pip install -U -e .[dev] | ||
- name: Update changelog | ||
uses: CharMixer/auto-changelog-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }} | ||
|
||
- name: Update documentation and version - Commit changes and update tag | ||
run: .github/utils/update_docs.sh | ||
|
||
- name: Push updates to '${{ env.PUBLISH_UPDATE_BRANCH }}' | ||
uses: CasperWA/push-protected@v2 | ||
with: | ||
token: ${{ secrets.RELEASE_PAT }} | ||
branch: ${{ env.PUBLISH_UPDATE_BRANCH }} | ||
force: true | ||
tags: true | ||
|
||
- name: Get tagged versions | ||
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV | ||
|
||
- name: Create release-specific changelog | ||
uses: CharMixer/auto-changelog-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }} | ||
since_tag: "${{ env.PREVIOUS_VERSION }}" | ||
output: "release_changelog.md" | ||
|
||
- name: Append changelog to release body | ||
run: | | ||
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md | ||
cat release_changelog.md >> release_body.md | ||
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }} | ||
|
||
# - name: Build source distribution | ||
# run: python ./setup.py sdist | ||
|
||
# - name: Publish package to TestPyPI | ||
# uses: pypa/gh-action-pypi-publish@master | ||
# with: | ||
# user: __token__ | ||
# password: ${{ secrets.TEST_PYPI_TOKEN }} | ||
# repository_url: "https://test.pypi.org/legacy" | ||
|
||
# - name: Publish package to PyPI | ||
# uses: pypa/gh-action-pypi-publish@master | ||
# with: | ||
# user: __token__ | ||
# password: ${{ secrets.PYPI_TOKEN }} | ||
|
||
docs: | ||
name: Build and deploy documentation | ||
needs: update-and-publish | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ env.PUBLISH_UPDATE_BRANCH }} | ||
token: ${{ secrets.RELEASE_PAT }} | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install -U pip | ||
pip install -U setuptools wheel | ||
pip install -U -e .[docs] | ||
- name: Set up git user | ||
run: | | ||
git config --global user.name "${{ env.GIT_USER_NAME }}" | ||
git config --global user.email "${{ env.GIT_USER_EMAIL }}" | ||
- name: Deploy documentation | ||
run: | | ||
mike deploy --push --remote origin --branch gh-pages --update-aliases --config-file mkdocs.yml ${GITHUB_REF#refs/tags/v} stable | ||
mike deploy --push --remote origin --branch gh-pages --update-aliases --config-file mkdocs.yml latest ${{ env.PUBLISH_UPDATE_BRANCH }} | ||
with: | ||
# General | ||
git_username: CasperWA | ||
git_email: "[email protected]" | ||
release_branch: main | ||
|
||
# Python package | ||
python_package: true | ||
package_dirs: turtle_canon | ||
install_extras: "[dev]" | ||
python_version_build: "3.10" | ||
version_update_changes: | | ||
"README.md,latest stable version is \*\*.*\*\*\.,latest stable version is **{version}**." | ||
build_libs: build | ||
build_cmd: "python -m build" | ||
changelog_exclude_labels: "skip_changelog,duplicate,question,invalid,wontfix" | ||
publish_on_pypi: false | ||
|
||
# Documentation | ||
update_docs: true | ||
python_version_docs: "3.10" | ||
doc_extras: "[docs]" | ||
docs_framework: "mkdocs" | ||
mkdocs_update_latest: true | ||
|
||
secrets: | ||
PAT: ${{ secrets.RELEASE_PAT }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,51 @@ | ||
name: CI - Activate auto-merging for Dependabot PRs | ||
name: CI - Activate auto-merging for dependencies PRs | ||
|
||
on: | ||
pull_request_target: | ||
branches: [ci/dependabot-updates] | ||
branches: [ci/dependency-updates] | ||
|
||
jobs: | ||
update-dependabot-branch: | ||
name: Update permanent dependabot branch | ||
update-dependencies-branch: | ||
name: External | ||
uses: SINTEF/ci-cd/.github/workflows/[email protected] | ||
if: github.repository_owner == 'CasperWA' && startsWith(github.event.pull_request.head.ref, 'dependabot/') && github.actor == 'dependabot[bot]' | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DEPENDABOT_BRANCH: ci/dependabot-updates | ||
GIT_USER_NAME: CasperWA | ||
GIT_USER_EMAIL: "[email protected]" | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
persist-credentials: false | ||
|
||
- name: Setup Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Set up git user info | ||
run: | | ||
git config --global user.name "${{ env.GIT_USER_NAME }}" | ||
git config --global user.email "${{ env.GIT_USER_EMAIL }}" | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
with: | ||
perform_changes: true | ||
git_username: CasperWA | ||
git_email: "[email protected]" | ||
changes: | | ||
pip install --upgrade pip | ||
pip install -U setuptools wheel | ||
while IFS="" read -r line || [ -n "${line}" ]; do | ||
if [[ "${line}" =~ ^invoke.*$ ]]; then | ||
invoke="${line}" | ||
pip install -U . | ||
RDFLIB_VERSION="$(python -c 'import rdflib; print(rdflib.__version__)')" | ||
CANONIZED_FILENAME="turtle_canon_tests_canonized_${RDFLIB_VERSION}.ttl" | ||
CANONIZED_FILEPATH="${{ github.workspace }}/tests/static/rdflib_canonized/${CANONIZED_FILENAME}" | ||
CORE_TEST_ONTOLOGY_FILE="${{ github.workspace }}/tests/static/rdflib_canon_tests.ttl" | ||
if [ -f "${CANONIZED_FILEPATH}" ]; then | ||
echo "Canonized test file for RDFlib version ${RDFLIB_VERSION} already exists, checking contents..." | ||
# Copy core test ontology file into a temporary file and canonize it | ||
TEMP_FILEPATH="/tmp/${CANONIZED_FILENAME}.ttl" | ||
cp "${CORE_TEST_ONTOLOGY_FILE}" "${TEMP_FILEPATH}" | ||
turtle-canon "${TEMP_FILEPATH}" | ||
if [ "$(diff "${TEMP_FILEPATH}" "${CANONIZED_FILEPATH}")" ]; then | ||
echo "The existing canonized test file for RDFlib version ${RDFLIB_VERSION} differs from the currently generated one using the same version !" | ||
rm -f "${TEMP_FILEPATH}" | ||
exit 1 | ||
else | ||
echo "Canonized test file for RDFlib version ${RDFLIB_VERSION} is up-to-date, nothing to do." | ||
rm -f "${TEMP_FILEPATH}" | ||
exit 0 | ||
fi | ||
done < requirements_docs.txt | ||
pip install ${invoke} | ||
pip install -r requirements.txt | ||
pip install . | ||
- name: Run tasks (and commit) | ||
run: | | ||
invoke update-pytest-reqs | ||
invoke create-canonized-test-file | ||
git add pyproject.toml tests/static/rdflib_canonized | ||
if [ -n "$(git status --porcelain pyproject.toml tests/static/rdflib_canonized)" ]; then | ||
# Only commit if there's something to commit (git will return non-zero otherwise) | ||
echo "Committing update to pytest dependency config and/or RDFlib version-specific canonized test file !" | ||
git commit -m "Update version-specific parts\n\nUpdate pytest dependency config and/or\nRDFlib version-specific canonized test file" | ||
echo "PUSH_BACK_TO_BRANCH=true" >> $GITHUB_ENV | ||
else | ||
echo "No changes to pytest dependency config and/or RDFlib version-specific canonized test file." | ||
echo "PUSH_BACK_TO_BRANCH=false" >> $GITHUB_ENV | ||
fi | ||
- name: Update Dependabot branch | ||
if: env.PUSH_BACK_TO_BRANCH == 'true' | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.RELEASE_PAT }} | ||
branch: ${{ github.event.pull_request.head.ref }} | ||
echo "No canonized test file for RDFlib version ${RDFLIB_VERSION} found, creating it..." | ||
- name: Activate auto-merge | ||
run: | | ||
PR_ID="$(gh api graphql -F owner='{owner}' -F name='{repo}' -f query='query($owner: String!, $name: String!) {repository(owner: $owner, name: $name) {pullRequest(number: ${{ github.event.pull_request.number }}) {id}}}' --jq '.data.repository.pullRequest.id')" | ||
gh api graphql -f pr_id="$PR_ID" -f query='mutation($pr_id: ID!) {enablePullRequestAutoMerge(input:{mergeMethod:SQUASH,pullRequestId:$pr_id }) {pullRequest {number}}}' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }} | ||
cp "${CORE_TEST_ONTOLOGY_FILE}" "${CANONIZED_FILEPATH}" | ||
turtle-canon "${CANONIZED_FILEPATH}" | ||
exit 0 | ||
fi | ||
secrets: | ||
PAT: ${{ secrets.RELEASE_PAT }} |
Oops, something went wrong.