update-checks-list #37
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: update-checks-list | |
# Run manually or when dispatched by a new threedi-modelchecker release. | |
on: | |
workflow_dispatch: | |
inputs: | |
reviewer_name: | |
description: "Who to ask for a review (github username)" | |
default: "elisalle" | |
required: true | |
jobs: | |
update_checks_list: | |
runs-on: ubuntu-22.04 | |
outputs: | |
checks_changed: ${{ steps.check_files.outputs.checks_changed }} | |
checker_version: ${{ steps.fetch_version.outputs.checker_version }} | |
steps: | |
# Checkout the code. | |
- uses: actions/checkout@v4 | |
- name: set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: install threedi-modelchecker | |
run: python -m pip install threedi-modelchecker | |
- name: generate and overwrite schematisation checks list | |
run: threedi_modelchecker export-checks --format rst --file source/i_current_schematisation_checks_table.rst | |
- name: fetch threedi-modelchecker version name | |
id: fetch_version | |
run: echo "checker_version=$(python -c 'import threedi_modelchecker; print(threedi_modelchecker.__version__)')" >> "$GITHUB_OUTPUT" | |
- name: check modified files | |
id: check_files | |
run: | | |
echo "=============== list modified files ===============" | |
git diff --name-only HEAD | |
echo "========== check paths of modified files ==========" | |
files_changed=$(git diff --name-only HEAD | tr -d '\n') | |
if [[ $files_changed == source/i_current_schematisation_checks_table.rst ]]; then | |
echo "Schematisation checks table has changed" | |
echo "checks_changed=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "Schematisation checks table has not changed" | |
echo "checks_changed=false" >> "$GITHUB_OUTPUT" | |
fi | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: source/i_current_schematisation_checks_table.rst | |
create_pr: | |
runs-on: ubuntu-22.04 | |
needs: update_checks_list | |
if: needs.update_checks_list.outputs.checks_changed == 'true' # don't run if the checks table hasn't changed | |
steps: | |
# Checkout the code. | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
- name: move downloaded artifact file to correct place | |
run: | | |
mv artifact/i_current_schematisation_checks_table.rst source | |
rm -rf artifact | |
- name: set environment variables | |
run: | | |
echo "PR_TITLE=Update schematisation checks for threedi-modelchecker ${{ needs.update_checks_list.outputs.checker_version }}" >> "$GITHUB_ENV" | |
echo "PR_BODY=This PR was auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request).\ | |
It is usually triggered by a new threedi-modelchecker release, but can also be run by hand. This PR updates the documented\ | |
list of checks run by the modelchecker to reflect the latest threedi-modelchecker version,\ | |
${{ needs.update_checks_list.outputs.checker_version }}. **Please note:** The `build_and_deploy`\ | |
workflow cannot be triggered by this bot, so to run the required checks, please close and reopen\ | |
this pull request." >> $GITHUB_ENV | |
- name: create pull request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
title: ${{ env.PR_TITLE }} | |
commit-message: ${{ env.PR_TITLE }} | |
committer: GitHub <[email protected]> | |
author: github-actions <[email protected]> | |
body: ${{ env.PR_BODY }} | |
branch: update-schematisation-checks-${{ needs.update_checks_list.outputs.checker_version }} | |
add-paths: | | |
source/i_current_schematisation_checks_table.rst | |
assignees: ${{ github.event.inputs.reviewer_name }} | |
reviewers: ${{ github.event.inputs.reviewer_name }} |