Skip to content

Commit

Permalink
Swap to the clang-formatting directory for now. Update the files to b…
Browse files Browse the repository at this point in the history
…e smaller for the tests
  • Loading branch information
Skptak committed Aug 31, 2023
1 parent a0f3be8 commit 7582e0c
Show file tree
Hide file tree
Showing 35 changed files with 1,131 additions and 38,025 deletions.
484 changes: 30 additions & 454 deletions .github/workflows/formattingTests.yml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
test-format-check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: FreeRTOS/coreMQTT
ref: main
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
exe-path: executable-monitor/test.out
success-line: "SLEEPING FOR 6 SECONDS"
timeout-seconds: 20

- name: Functional Test | Success Case | No Retries, No Success Line, Exit Code
id: test-executable-monitor-action-no-retry-attempts-exit-code
uses: ./executable-monitor
Expand All @@ -125,7 +125,7 @@ jobs:
exe-path: executable-monitor/test.out
success-line: "SLEEPING FOR 6 SECONDS"
retry-attempts: 2

- name: API Test | Success Case | Retries, No Success Line, Exit Code, Use Default Timeout
id: test-executable-monitor-action-no-success-line-no-timeout
uses: ./executable-monitor
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
repository: FreeRTOS/FreeRTOS
ref: '202107.00'
path: FreeRTOS
submodules: recursive
submodules: recursive
- name: Test manifest verifier
uses: ./manifest-verifier
with:
Expand Down
File renamed without changes.
170 changes: 170 additions & 0 deletions clang-formatting/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: 'formatting'
description: 'CI formatting check'
inputs:
path:
description: 'Path to repository folder to run formatting check for. '
required: false
default: ./
exclude-files:
description: 'List of comma-separated files to exclude from the formatting check. Eg file1, file2'
required: false
default: ''
exclude-dirs:
description: 'List of comma-separated directories to exclude from the formatting check. Eg docs, build'
required: false
default: ''
include-extensions:
description: 'List of comma-separated extensions to add to the formatting check. Eg md, dox'
required: false
default: ''

runs:
using: "composite"
steps:
- env:
# At time of writing, you can't add a global environment
# to an action file so stuck with this. If this gets changed
# Please move this
bashPass: \033[32;1mPASSED -
bashInfo: \033[33;1mINFO -
bashFail: \033[31;1mFAILED -
bashEnd: \033[0m
stepName: Install Clang Format
name: ${{ env.stepName }}
shell: bash
run: |
# ${{ env.stepName }}
echo -e "::group::${{ env.stepName }}"
sudo apt-get install clang-format fd-find dos2unix
echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
export PATH="$PATH:$GITHUB_ACTION_PATH"
fdfind --version
fdInstalled=$?
clang-format --version
clangFormatInstalled=$?
echo -e "::endgroup::"
if [ $clangFormatInstalled -eq 1 ] || [ $fdInstalled -eq 1 ]; then
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
exit 1
else
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
exit 0
fi
- env:
bashPass: \033[32;1mPASSED -
bashInfo: \033[33;1mINFO -
bashFail: \033[31;1mFAILED -
bashEnd: \033[0m
stepName: Check Format of Files
name: ${{ env.stepName }}
id: action-formatting-check
if: ${{ steps.validate-inputs.outcome}} = "success"
working-directory: ${{ inputs.path }}
shell: bash
run: |
# ${{ env.stepName }}
echo -e "${{ env.bashInfo }} Using clang-format version "$(clang-format --version)" ${{ env.bashEnd }}"
echo -e "::group::Clang Format Code Files"
exitCode=0
export PATH="$PATH:$GITHUB_ACTION_PATH"
# TODO: These checks should really only run against modified files on PRS
# Where when the commit to the actual repo happens, then we should trigger the job
# Against all of the files in the repo. Nice inbetween to keep checks fast for PRs,
# But maintain that we don't have a change in the Repo that suddenly causes an issue
# Parse the optional inputs
args=""
# fd-find uses -E to exclude a file or directory
if [ -n "${{ inputs.exclude-dirs }}" ]; then
dirs=" -E "
dirs+="${{ inputs.exclude-dirs }}"
dirs="${dirs//,/ -E }"
args+=" ${dirs}"
fi
# fd-find uses -E to exclude a file or directory
if [ -n "${{ inputs.exclude-files }}" ]; then
files=" -E "
files+="${{ inputs.exclude-files }}"
files="${files//,/ -E }"
args+=" ${files}"
fi
# fd-find uses -e to include a file extension
if [ -n "${{ inputs.include-file-types }}" ]; then
file_types=" -e "
file_types+="${{ inputs.include-file-types }}"
file_types="${file_types//,/ -e }"
args+=" ${file_types}"
fi
# Get all .c and .h files, as well as any other requested file types.
# Then run clang-format with the common config file.
echo -e "${{ env.bashInfo }} Running: fdfind -e c -e h ${args} --exec clang-format -i ${{ env.bashEnd }}"
echo -e "::group::${{ env.bashInfo }} Check Formatting with Clang-Format ${{ env.bashEnd }}"
fdfind -e c -e h ${args} --exec fdfind -e c -e h ${args} --exec clang-format -i
echo -e "::endgroup::"
echo -e "::group::Check for Trailing Whitespace"
# These checks will be captured in the git diff
# Replace all trailing whitespace, exclude photo files
fdfind --type=file -E '*.png' -E '*.jpg' -E '*.svg' ${args} . --exec sed -Ei 's/[[:blank:]]+$//'
echo -e "::endgroup::"
echo -e "::group::Check for CRLF Line Endings"
# Replace all line endings with LF ones instead of CRLF
fdfind --type=file ${args} . --exec dos2unix
echo -e "::endgroup::"
# Run a git diff to print the differences if any exist, return an error code if there are any
# Wrap in a set+e and set -e so we can keep running after the error
echo -e "::group::${{ env.bashInfo }} Format Difference ${{ env.bashEnd }}"
set +e
git diff --exit-code --color=always
exitCode=$?
set -e
echo -e "::endgroup::"
if [ $exitCode -eq 0 ]; then
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
else
# I am intentionally doing this a second time here.
# Using tee will mask the exit code of the diff
# And we don't want the colour to be added to the patch
# Put it in what the 'default' path will be for the upload step
git diff > formattingChanges.patch
echo -e "${{ env.bashFail }} List of files with formatting errors: ${{ env.bashEnd }}"
echo -e "${{ env.bashFail }} "$(git diff --name-only)" ${{ env.bashEnd }} "
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
fi
exit $exitCode
- name: Upload Formatting Git Patch
if: failure() && ( steps.action-formatting-check.outcome == 'failure' )
id: upload-formatting-patch
uses: actions/upload-artifact@v3
with:
name: formattingChanges
path: ${{ inputs.path }}/formattingChanges.patch
retention-days: 7

- env:
stepName: Formatting Git Patch Info
bashPass: \033[32;1m
bashInfo: \033[33;1m
bashFail: \033[31;1m
bashEnd: \033[0
if: failure() && ( steps.upload-formatting-patch.outcome == 'success' )
shell: bash
run: |
# ${{ env.stepName }}
echo -e "${{ env.bashInfo }} A git patch of the formatting issues has been attached to this workflow ${{ env.bashEnd }}"
echo -e "${{ env.bashInfo }} This can be accessed by returning to the bottom of the summary page of the workflow run ${{ env.bashEnd }}"
echo -e "${{ env.bashInfo }} At the bottom of the page will be a formattingChanges.patch file that you can download ${{ env.bashEnd }}"
echo -e "${{ env.bashInfo }} Copy this patch to your repository and apply it using 'git apply formattingChanges.patch' ${{ env.bashEnd }}"
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
#ifndef CGC_ERROR_H_
#define CGC_ERROR_H_

/* Error checking macros for the clock selction and clock enable defines */

#if ( (CLK_SOURCE != CLK_SOURCE_LOCO) && \
(CLK_SOURCE != CLK_SOURCE_HOCO) && \
(CLK_SOURCE != CLK_SOURCE_MAIN) && \
(CLK_SOURCE != CLK_SOURCE_SUB) && \
(CLK_SOURCE != CLK_SOURCE_PLL) )
#error "No CLK_SOURCE specified. Please specify a valid CLK_SOURCE";
#endif


#if (CLK_SOURCE == CLK_SOURCE_HOCO) && (ENABLE_HOCO == 0)
#error "HOCO has been specified as the CLK_SOURCE but ENABLE_HOCO is (0). Please set to (1) in file cgc.h"
#endif

#if (CLK_SOURCE == CLK_SOURCE_MAIN) && (ENABLE_MAIN == 0)
#error "HOCO has been specified as the CLK_SOURCE but ENABLE_HOCO is (0). Please set to (1) in file cgc.h"
#endif

#if (CLK_SOURCE == CLK_SOURCE_SUB) && (ENABLE_SUB == 0)
#error "HOCO has been specified as the CLK_SOURCE but ENABLE_HOCO is (0). Please set to (1) in file cgc.h"
#endif

#if (CLK_SOURCE == CLK_SOURCE_PLL) && (ENABLE_PLL == 0)
#error "PLL has been specified as the CLK_SOURCE but ENABLE_PLL is (0). Please set to (1) in file cgc.h"
#endif

#if ( FCLK_FREQUENCY > 50000000L )
#error "FCLK_FREQUENCY Error: Please enter a valid divider value"
#endif

#if ( ICLK_FREQUENCY > 100000000L )
#error "ICLK_FREQUENCY Error: Please enter a valid divider value"
#endif

#if ( BCLK_FREQUENCY > 100000000L )
#error "BCLK_FREQUENCY Error: Please enter a valid divider value"
#endif

#if ( PCLKB_FREQUENCY > 50000000L )
#error "PCLKB_FREQUENCY Error: Please enter a valid divider value"
#endif

#ifndef CGC_ERROR_H_
#define CGC_ERROR_H_

/* Error checking macros for the clock selction and clock enable defines */

#if ( (CLK_SOURCE != CLK_SOURCE_LOCO) && \
(CLK_SOURCE != CLK_SOURCE_HOCO) && \
(CLK_SOURCE != CLK_SOURCE_MAIN) && \
(CLK_SOURCE != CLK_SOURCE_SUB) && \
(CLK_SOURCE != CLK_SOURCE_PLL) )
#error "No CLK_SOURCE specified. Please specify a valid CLK_SOURCE";
#endif


#if (CLK_SOURCE == CLK_SOURCE_HOCO) && (ENABLE_HOCO == 0)
#error "HOCO has been specified as the CLK_SOURCE but ENABLE_HOCO is (0). Please set to (1) in file cgc.h"
#endif

#if (CLK_SOURCE == CLK_SOURCE_MAIN) && (ENABLE_MAIN == 0)
#error "HOCO has been specified as the CLK_SOURCE but ENABLE_HOCO is (0). Please set to (1) in file cgc.h"
#endif

#if (CLK_SOURCE == CLK_SOURCE_SUB) && (ENABLE_SUB == 0)
#error "HOCO has been specified as the CLK_SOURCE but ENABLE_HOCO is (0). Please set to (1) in file cgc.h"
#endif

#if (CLK_SOURCE == CLK_SOURCE_PLL) && (ENABLE_PLL == 0)
#error "PLL has been specified as the CLK_SOURCE but ENABLE_PLL is (0). Please set to (1) in file cgc.h"
#endif

#if ( FCLK_FREQUENCY > 50000000L )
#error "FCLK_FREQUENCY Error: Please enter a valid divider value"
#endif

#if ( ICLK_FREQUENCY > 100000000L )
#error "ICLK_FREQUENCY Error: Please enter a valid divider value"
#endif

#if ( BCLK_FREQUENCY > 100000000L )
#error "BCLK_FREQUENCY Error: Please enter a valid divider value"
#endif

#if ( PCLKB_FREQUENCY > 50000000L )
#error "PCLKB_FREQUENCY Error: Please enter a valid divider value"
#endif

#endif
81 changes: 81 additions & 0 deletions clang-formatting/filesWithCRLFEndings/crlf-file.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/

static void prvQueueSendTask( void *pvParameters )
{
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;

/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );

/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();

for( ;; )
{
/* Place this task in the blocked state until it is time to run again.
The block time is specified in ticks, the constant used converts ticks
to ms. While in the Blocked state this task will not consume any CPU
time. */
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );

/* Send to the queue - causing the queue receive task to unblock and
toggle the LED. 0 is used as the block time so the sending operation
will not block - it shouldn't need to block as the queue should always
be empty at this point in the code. */
xQueueSend( xQueue, &ulValueToSend, 0U );
}
}
/*-----------------------------------------------------------*/

static void prvQueueReceiveTask( void *pvParameters )
{
unsigned long ulReceivedValue;

/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );

for( ;; )
{
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );

/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == 100UL )
{
/* Toggle the LED. */
port_pin_toggle_output_level( LED_0_PIN );
ulReceivedValue = 0U;
}
}
}
/*-----------------------------------------------------------*/

Loading

0 comments on commit 7582e0c

Please sign in to comment.