1# Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved. 2# 3# Licensed under the Apache License 2.0 (the "License"). You may not use 4# this file except in compliance with the License. You can obtain a copy 5# in the file LICENSE in the source distribution or at 6# https://www.openssl.org/source/license.html 7 8name: Coding style validation 9 10on: [pull_request] 11 12env: 13 PR_NUMBER: ${{ github.event.number }} 14 GH_TOKEN: ${{ github.token }} 15 16permissions: 17 contents: read 18 19jobs: 20 check-style: 21 runs-on: ubuntu-latest 22 steps: 23 - uses: actions/checkout@v4 24 with: 25 fetch-depth: 0 26 path: openssl 27 - name: check style for each commit 28 working-directory: openssl 29 shell: bash 30 run: | 31 ERRORS_FOUND=0 32 git fetch origin $GITHUB_BASE_REF:$GITHUB_BASE_REF 33 REFSTART=$(git rev-parse $GITHUB_BASE_REF) 34 REFEND=$(git rev-parse HEAD) 35 echo "Checking from $REFSTART to $REFEND" 36 echo "::group::Style report for commits $REFSTART..$REFEND" 37 set +e 38 ./util/check-format-commit.sh $REFSTART..$REFEND 39 if [ $? -ne 0 ] 40 then 41 ERRORS_FOUND=1 42 fi 43 set -e 44 echo "::endgroup::" 45 SKIP_TEST=$(gh pr view $PR_NUMBER --json labels --jq '.labels[] | select(.name == "style: waived") | .name') 46 if [ -z "$SKIP_TEST" ] 47 then 48 exit $ERRORS_FOUND 49 else 50 echo "PR $PR_NUMBER is marked with style: waived, waiving style check errors" 51 exit 0 52 fi 53