Publish to PyPI upon release #31
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: CI - Update RDFLib canonized test files | |
on: | |
pull_request: | |
branches: [main] | |
types: [opened, reopened, synchronize] | |
workflow_dispatch: | |
jobs: | |
check-rdflib-test-files: | |
name: Update RDFLib canonized test files | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref || github.ref }} | |
token: ${{ secrets.RELEASE_PAT }} | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U setuptools wheel | |
pip install -U . | |
- name: Configuration | |
id: config | |
run: | | |
RDFLIB_VERSION="$(python -c 'import rdflib; print(rdflib.__version__)')" | |
CANONIZED_FILENAME="turtle_canon_tests_canonized_${RDFLIB_VERSION}.ttl" | |
RELATIVE_CANONIZED_FILEPATH="tests/static/rdflib_canonized/${CANONIZED_FILENAME}" | |
echo "rdflib_version=${RDFLIB_VERSION}" >> $GITHUB_OUTPUT | |
echo "canonized_filepath=${{ github.workspace }}/${RELATIVE_CANONIZED_FILEPATH}" >> $GITHUB_OUTPUT | |
echo "core_test_ontology_file=${{ github.workspace }}/tests/static/turtle_canon_tests.ttl" >> $GITHUB_OUTPUT | |
echo "relative_canonized_filepath=${RELATIVE_CANONIZED_FILEPATH}" >> $GITHUB_OUTPUT | |
echo "temp_filepath=/tmp/${CANONIZED_FILENAME}" >> $GITHUB_OUTPUT | |
- name: Check if canonized file exists | |
id: file_exists | |
run: | | |
if [ -f "${{ steps.config.outputs.canonized_filepath }}" ]; then | |
CANONIZED_FILE_EXISTS=true | |
else | |
CANONIZED_FILE_EXISTS=false | |
fi | |
echo "Canonized file exists: ${CANONIZED_FILE_EXISTS}" | |
echo "canonized_file_exists=${CANONIZED_FILE_EXISTS}" >> $GITHUB_OUTPUT | |
- name: Check content of canonized file | |
if: steps.file_exists.outputs.canonized_file_exists == 'true' | |
run: | | |
cp ${{ steps.config.outputs.core_test_ontology_file }} ${{ steps.config.outputs.temp_filepath }} | |
turtle-canon "${{ steps.config.outputs.temp_filepath }}" | |
DIFF=$(diff ${{ steps.config.outputs.temp_filepath }} ${{ steps.config.outputs.canonized_filepath }}) | |
if [ "$DIFF" != "" ]; then | |
echo "The existing canonized test file for RDFlib version ${{ steps.config.outputs.rdflib_version }} differs from the currently generated one using the same version !" | |
echo -e "Diff:\n${DIFF}" | |
rm -f "${{ steps.config.outputs.temp_filepath }}" | |
exit 1 | |
else | |
echo "Canonized test file for RDFlib version ${{ steps.config.outputs.rdflib_version }} is up-to-date, nothing to do." | |
rm -f "${{ steps.config.outputs.temp_filepath }}" | |
fi | |
- name: Generate new canonized file | |
if: steps.file_exists.outputs.canonized_file_exists == 'false' | |
run: | | |
cp ${{ steps.config.outputs.core_test_ontology_file }} ${{ steps.config.outputs.canonized_filepath }} | |
turtle-canon "${{ steps.config.outputs.canonized_filepath }}" | |
- name: Commit and push files | |
if: steps.file_exists.outputs.canonized_file_exists == 'false' && github.event_name == 'pull_request' | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add ${{ steps.config.outputs.relative_canonized_filepath }} | |
git commit -m "Update canonized test file for RDFlib version ${{ steps.config.outputs.rdflib_version }}" | |
git push | |
- name: Create PR (if manual trigger) | |
if: steps.file_exists.outputs.canonized_file_exists == 'false' && github.event_name == 'workflow_dispatch' | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.RELEASE_PAT }} | |
commit-message: "Update canonized test file for RDFlib version ${{ steps.config.outputs.rdflib_version }}" | |
title: "[AUTO] Update test file - RDFlib v${{ steps.config.outputs.rdflib_version }}" | |
body: "## Update canonized test file\n\nThis PR updates the canonized test file for RDFlib version ${{ steps.config.outputs.rdflib_version }}." | |
branch: "ci/update-rdflib-canonized-test-file-${{ steps.config.outputs.rdflib_version }}" | |
labels: CI/CD,dependencies | |
reviewers: "CasperWA" | |
delete-branch: true | |
sign-commits: true | |
add-paths: ${{ steps.config.outputs.relative_canonized_filepath }} |