Myrthe2 #216
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: Lint | |
on: | |
pull_request_target: | |
env: | |
TZ: Europe/Berlin | |
defaults: | |
run: | |
shell: bash -Eeuxo pipefail {0} | |
jobs: | |
# Cancel other workflows that are dependent on this workflow by adding jobs that have the same concurrency group. | |
cancel_linux: | |
name: Cancel running Workflows | |
concurrency: | |
group: linux-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Cancel Linux" | |
run: echo "Cancelling Linux" | |
cancel_macos: | |
name: Cancel running Workflows | |
concurrency: | |
group: macos-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Cancel macOS" | |
run: echo "Cancelling macOS" | |
cancel_misc: | |
name: Cancel running Workflows | |
concurrency: | |
group: misc-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Cancel Misc" | |
run: echo "Cancelling Misc" | |
lint: | |
name: Lint | |
concurrency: | |
group: lint-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
needs: [cancel_linux, cancel_macos, cancel_misc] | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
steps: | |
- name: Add label | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }} | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
run: gh pr edit $PR_URL --add-label "lint" | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: "refs/pull/${{ github.event.number }}/merge" | |
submodules: false | |
token: ${{ secrets.SEQAN_ACTIONS_PAT }} | |
- name: Get changed files | |
id: changed_files | |
run: | | |
CPP_LIST=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} | \ | |
{ grep -v -E "(lib/)" || test $? = 1; } | \ | |
{ grep -E "(\.cpp|\.hpp)$" || test $? = 1; } | xargs) | |
echo "cpp_list=$CPP_LIST" >> $GITHUB_OUTPUT | |
CMAKE_LIST=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} | \ | |
{ grep -v -E "(lib/)" || test $? = 1; } | \ | |
{ grep -E "(\.cmake|CMakeLists.txt)$" || test $? = 1; } | xargs) | |
echo "cmake_list=$CMAKE_LIST" >> $GITHUB_OUTPUT | |
- name: Switch to fork | |
run: | | |
git remote add fork ${{ github.event.pull_request.head.repo.html_url }} | |
git fetch fork ${{ github.event.pull_request.head.ref }} | |
git checkout --force --track fork/${{ github.event.pull_request.head.ref }} | |
- name: Run clang-format | |
if: ${{ steps.changed_files.outputs.cpp_list }} | |
uses: DoozyX/[email protected] | |
with: | |
source: ${{ steps.changed_files.outputs.cpp_list }} | |
clangFormatVersion: 15 | |
inplace: True | |
- name: Run cmake-format | |
if: ${{ steps.changed_files.outputs.cmake_list }} | |
uses: PuneetMatharu/[email protected] | |
with: | |
args: --config-files .cmake-format.yaml --in-place | |
- name: Check git status | |
id: git_status | |
run: | | |
if [[ -z $(git status -uno --porcelain) ]]; then | |
echo "commit_required=" >> $GITHUB_OUTPUT | |
else | |
echo "commit_required=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Import GPG key | |
if: ${{ steps.git_status.outputs.commit_required }} | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
gpg_private_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }} | |
passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Commit changes | |
if: ${{ steps.git_status.outputs.commit_required }} | |
run: | | |
git config user.name "seqan-actions[bot]" | |
git config user.email "[email protected]" | |
git add . | |
git commit -m '[MISC] automatic linting' | |
git push fork ${{ github.event.pull_request.head.ref }} | |
- name: Remove label | |
if: ${{ !steps.git_status.outputs.commit_required }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }} | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
run: gh pr edit $PR_URL --remove-label "lint" |