Skip to content

Commit

Permalink
CI - clang-format-15 (#9085)
Browse files Browse the repository at this point in the history
Stop CI from pulling LLVM repos and using GNUPG keyservers,
ubuntu-latest already has clang-format-{13,14,15}

Fixes long-standing issue with -style=file:...
  • Loading branch information
mcspr authored Feb 9, 2024
1 parent 16e1918 commit e6df345
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 45 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/style-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,8 @@ jobs:
with:
python-version: '3.x'
- name: Style check
env:
LLVM_SNAPSHOT_KEY: "6084F3CF814B57C1CF12EFD515CF4D18AF4F7421"
run: |
export GNUPGHOME=$(mktemp -d)
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$LLVM_SNAPSHOT_KEY"
gpg --batch --armor --export "$LLVM_SNAPSHOT_KEY" | \
sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.gpg.asc
gpgconf --kill all
rm -r $GNUPGHOME
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main" | \
sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt update
sudo apt install clang-format-13
pip3 install pyyaml
bash ./tests/ci/style_check.sh
# Validate orthography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
bin/PostServer/PostServer
then put your PC's IP address in SERVER_IP below, port 9080 (instead of default 80):
*/
//#define SERVER_IP "10.0.1.7:9080" // PC address with emulation on host
// #define SERVER_IP "10.0.1.7:9080" // PC address with emulation on host
#define SERVER_IP "192.168.1.42"

#ifndef STASSID
Expand Down
6 changes: 3 additions & 3 deletions libraries/ESP8266WebServer/examples/FSBrowser/FSBrowser.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

// Select the FileSystem by uncommenting one of the lines below

//#define USE_SPIFFS
// #define USE_SPIFFS
#define USE_LITTLEFS
//#define USE_SDFS
// #define USE_SDFS

// Uncomment the following line to embed a version of the web page in the code
// (program code will be larger, but no file will have to be written to the filesystem).
// Note: the source file "extras/index_htm.h" must have been generated by "extras/reduce_index.sh"

//#define INCLUDE_FALLBACK_INDEX_HTM
// #define INCLUDE_FALLBACK_INDEX_HTM

////////////////////////////////

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WebServer/examples/Graph/Graph.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

// Select the FileSystem by uncommenting one of the lines below

//#define USE_SPIFFS
// #define USE_SPIFFS
#define USE_LITTLEFS
//#define USE_SDFS
// #define USE_SDFS

////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const char *pass = STAPSK;
// The HTTPS server
BearSSL::WiFiServerSecure server(443);

//#define USE_EC // Enable Elliptic Curve signed cert
// #define USE_EC // Enable Elliptic Curve signed cert

#define USING_INSECURE_CERTS_AND_KEYS_AND_CAS 1
#include <ssl-tls-ca-key-cert-example.h>
Expand All @@ -58,7 +58,7 @@ BearSSL::WiFiServerSecure server(443);
// Caching SSL sessions shortens the length of the SSL handshake.
// You can see the performance improvement by looking at the
// Network tab of the developer tools of your browser.
//#define DYNAMIC_CACHE // Whether to dynamically allocate the cache.
// #define DYNAMIC_CACHE // Whether to dynamically allocate the cache.

#if defined(USE_CACHE) && defined(DYNAMIC_CACHE)
// Dynamically allocated cache.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const char *ap_default_psk = APPSK; ///< Default PSK.
/// @}

/// Uncomment the next line for verbose output over UART.
//#define SERIAL_VERBOSE
// #define SERIAL_VERBOSE

/**
@brief Read WiFi connection information from file system.
Expand Down
4 changes: 2 additions & 2 deletions libraries/LittleFS/examples/SpeedTest/SpeedTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// WARNING: The filesystem will be formatted at the start of the test!

#define TESTFS LittleFS
//#define TESTFS SPIFFS
//#define TESTFS SDFS
// #define TESTFS SPIFFS
// #define TESTFS SDFS

// How large of a file to test
#define TESTSIZEKB 512
Expand Down
2 changes: 1 addition & 1 deletion libraries/Netdump/examples/Netdump/Netdump.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
//#include <FS.h>
// #include <FS.h>
#include <LittleFS.h>
#include <map>

Expand Down
8 changes: 4 additions & 4 deletions libraries/esp8266/examples/LowPowerDemo/LowPowerDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <PolledTimeout.h>
#include <include/WiFiState.h> // WiFiState structure details

//#define DEBUG // prints WiFi connection info to serial, uncomment if you want WiFi messages
// #define DEBUG // prints WiFi connection info to serial, uncomment if you want WiFi messages
#ifdef DEBUG
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINT(x) Serial.print(x)
Expand All @@ -56,8 +56,8 @@

// uncomment one of the two lines below for your LED connection (optional)
#define LED 5 // D1/GPIO5 external LED for modules with built-in LEDs so it doesn't add amperage
//#define LED 2 // D4/GPIO2 LED for ESP-01,07 modules; D4 is LED_BUILTIN on most other modules
// you can use LED_BUILTIN, but it adds to the measured amperage by 0.3mA to 6mA.
// #define LED 2 // D4/GPIO2 LED for ESP-01,07 modules; D4 is LED_BUILTIN on most other modules
// you can use LED_BUILTIN, but it adds to the measured amperage by 0.3mA to 6mA.

ADC_MODE(ADC_VCC); // allows you to monitor the internal VCC level; it varies with WiFi load
// don't connect anything to the analog input pin(s)!
Expand All @@ -72,7 +72,7 @@ IPAddress dns1(0, 0, 0, 0);
IPAddress dns2(0, 0, 0, 0);
uint32_t timeout = 30E3; // 30 second timeout on the WiFi connection

//#define TESTPOINT // used to track the timing of several test cycles (optional)
// #define TESTPOINT // used to track the timing of several test cycles (optional)
#ifdef TESTPOINT
#define testPointPin 4 // D2/GPIO4, you can use any pin that supports interrupts
#define testPoint_HIGH digitalWrite(testPointPin, HIGH)
Expand Down
4 changes: 2 additions & 2 deletions libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
// check for your nearest city in TZ.h

// espressif headquarter TZ
//#define MYTZ TZ_Asia_Shanghai
// #define MYTZ TZ_Asia_Shanghai

// example for "Not Only Whole Hours" timezones:
// Kolkata/Calcutta is shifted by 30mn
//#define MYTZ TZ_Asia_Kolkata
// #define MYTZ TZ_Asia_Kolkata

// example of a timezone with a variable Daylight-Saving-Time:
// demo: watch automatic time adjustment on Summer/Winter change (DST)
Expand Down
4 changes: 3 additions & 1 deletion libraries/lwIP_enc28j60/src/utility/enc28j60.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ bool ENC28J60::reset(void)

/* Wait for OST */
PRINTF("waiting for ESTAT_CLKRDY\n");
while ((readreg(ESTAT) & ESTAT_CLKRDY) == 0) { };
while ((readreg(ESTAT) & ESTAT_CLKRDY) == 0)
{
};
PRINTF("ESTAT_CLKRDY\n");

setregbank(ERXTX_BANK);
Expand Down
1 change: 0 additions & 1 deletion tests/clang-format-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ KeepEmptyLinesAtTheStartOfBlocks: false
SpaceAfterTemplateKeyword: false
SpaceBeforeInheritanceColon: false
SpacesBeforeTrailingComments: 2
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
Expand Down
21 changes: 8 additions & 13 deletions tests/restyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ root=$(git rev-parse --show-toplevel)
test -d ${root}/cores/esp8266
test -d ${root}/libraries

# allow `env CLANG_FORMAT=clang-format-13`, or some other version
# default to v13, latest stable version from https://apt.llvm.org
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-13}

# TODO: waiting for llvm-14 to allow --style=file:<path-to-file>
makeClangFormatStyle() {
python3 -c 'import sys,yaml; sys.stdout.write(yaml.dump(yaml.safe_load(open(sys.argv[1], "r")), default_flow_style=True)); sys.stdout.flush();' $1
}
# allow `env CLANG_FORMAT=clang-format-N`, or some other version
# default to v15, latest stable version from ubuntu-latest Github Actions image
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15}

#########################################
# 'all' variable should be "cores/esp8266 libraries"
Expand All @@ -37,14 +32,14 @@ tests

cd $root

style=$(makeClangFormatStyle ${root}/tests/clang-format-core.yaml)
style=${root}/tests/clang-format-core.yaml
for target in $all; do
if [ -d "$target" ]; then
find $target \
'(' -name "*.cpp" -o -name "*.c" -o -name "*.h" ')' \
-exec $CLANG_FORMAT --verbose --style="$style" -i {} \;
-exec $CLANG_FORMAT --verbose --style="file:$style" -i {} \;
else
$CLANG_FORMAT --verbose --style="$style" -i $target
$CLANG_FORMAT --verbose --style="file:$style" -i $target
fi
done

Expand All @@ -55,12 +50,12 @@ done
# exclude=$(git submodule --quiet foreach git rev-parse --show-toplevel | grep libraries)

if [ -z $1 ] ; then
style=$(makeClangFormatStyle ${root}/tests/clang-format-arduino.yaml)
style=${root}/tests/clang-format-arduino.yaml
find libraries \
-path libraries/ESP8266SdFat -prune -o \
-path libraries/Ethernet -prune -o \
-path libraries/SoftwareSerial -prune -o \
-name '*.ino' -exec $CLANG_FORMAT --verbose --style="$style" -i {} \;
-name '*.ino' -exec $CLANG_FORMAT --verbose --style="file:$style" -i {} \;
fi

#########################################

0 comments on commit e6df345

Please sign in to comment.