Skip to content

Commit e6df345

Browse files
authored
CI - clang-format-15 (#9085)
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:...
1 parent 16e1918 commit e6df345

File tree

13 files changed

+29
-45
lines changed

13 files changed

+29
-45
lines changed

.github/workflows/style-check.yml

-12
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,8 @@ jobs:
2424
with:
2525
python-version: '3.x'
2626
- name: Style check
27-
env:
28-
LLVM_SNAPSHOT_KEY: "6084F3CF814B57C1CF12EFD515CF4D18AF4F7421"
2927
run: |
30-
export GNUPGHOME=$(mktemp -d)
31-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$LLVM_SNAPSHOT_KEY"
32-
gpg --batch --armor --export "$LLVM_SNAPSHOT_KEY" | \
33-
sudo tee /etc/apt/trusted.gpg.d/llvm-snapshot.gpg.asc
34-
gpgconf --kill all
35-
rm -r $GNUPGHOME
36-
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main" | \
37-
sudo tee /etc/apt/sources.list.d/llvm.list
3828
sudo apt update
39-
sudo apt install clang-format-13
40-
pip3 install pyyaml
4129
bash ./tests/ci/style_check.sh
4230
4331
# Validate orthography

libraries/ESP8266HTTPClient/examples/PostHttpClient/PostHttpClient.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bin/PostServer/PostServer
1616
then put your PC's IP address in SERVER_IP below, port 9080 (instead of default 80):
1717
*/
18-
//#define SERVER_IP "10.0.1.7:9080" // PC address with emulation on host
18+
// #define SERVER_IP "10.0.1.7:9080" // PC address with emulation on host
1919
#define SERVER_IP "192.168.1.42"
2020

2121
#ifndef STASSID

libraries/ESP8266WebServer/examples/FSBrowser/FSBrowser.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525

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

28-
//#define USE_SPIFFS
28+
// #define USE_SPIFFS
2929
#define USE_LITTLEFS
30-
//#define USE_SDFS
30+
// #define USE_SDFS
3131

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

36-
//#define INCLUDE_FALLBACK_INDEX_HTM
36+
// #define INCLUDE_FALLBACK_INDEX_HTM
3737

3838
////////////////////////////////
3939

libraries/ESP8266WebServer/examples/Graph/Graph.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

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

27-
//#define USE_SPIFFS
27+
// #define USE_SPIFFS
2828
#define USE_LITTLEFS
29-
//#define USE_SDFS
29+
// #define USE_SDFS
3030

3131
////////////////////////////////
3232

libraries/ESP8266WiFi/examples/BearSSL_Server/BearSSL_Server.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const char *pass = STAPSK;
4848
// The HTTPS server
4949
BearSSL::WiFiServerSecure server(443);
5050

51-
//#define USE_EC // Enable Elliptic Curve signed cert
51+
// #define USE_EC // Enable Elliptic Curve signed cert
5252

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

6363
#if defined(USE_CACHE) && defined(DYNAMIC_CACHE)
6464
// Dynamically allocated cache.

libraries/ESP8266mDNS/examples/OTA-mDNS-LittleFS/OTA-mDNS-LittleFS.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const char *ap_default_psk = APPSK; ///< Default PSK.
4747
/// @}
4848

4949
/// Uncomment the next line for verbose output over UART.
50-
//#define SERIAL_VERBOSE
50+
// #define SERIAL_VERBOSE
5151

5252
/**
5353
@brief Read WiFi connection information from file system.

libraries/LittleFS/examples/SpeedTest/SpeedTest.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// WARNING: The filesystem will be formatted at the start of the test!
99

1010
#define TESTFS LittleFS
11-
//#define TESTFS SPIFFS
12-
//#define TESTFS SDFS
11+
// #define TESTFS SPIFFS
12+
// #define TESTFS SDFS
1313

1414
// How large of a file to test
1515
#define TESTSIZEKB 512

libraries/Netdump/examples/Netdump/Netdump.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <ESP8266WiFi.h>
55
#include <ESP8266WebServer.h>
66
#include <ESP8266mDNS.h>
7-
//#include <FS.h>
7+
// #include <FS.h>
88
#include <LittleFS.h>
99
#include <map>
1010

libraries/esp8266/examples/LowPowerDemo/LowPowerDemo.ino

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include <PolledTimeout.h>
4343
#include <include/WiFiState.h> // WiFiState structure details
4444

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

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

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

75-
//#define TESTPOINT // used to track the timing of several test cycles (optional)
75+
// #define TESTPOINT // used to track the timing of several test cycles (optional)
7676
#ifdef TESTPOINT
7777
#define testPointPin 4 // D2/GPIO4, you can use any pin that supports interrupts
7878
#define testPoint_HIGH digitalWrite(testPointPin, HIGH)

libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
// check for your nearest city in TZ.h
3232

3333
// espressif headquarter TZ
34-
//#define MYTZ TZ_Asia_Shanghai
34+
// #define MYTZ TZ_Asia_Shanghai
3535

3636
// example for "Not Only Whole Hours" timezones:
3737
// Kolkata/Calcutta is shifted by 30mn
38-
//#define MYTZ TZ_Asia_Kolkata
38+
// #define MYTZ TZ_Asia_Kolkata
3939

4040
// example of a timezone with a variable Daylight-Saving-Time:
4141
// demo: watch automatic time adjustment on Summer/Winter change (DST)

libraries/lwIP_enc28j60/src/utility/enc28j60.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,9 @@ bool ENC28J60::reset(void)
398398

399399
/* Wait for OST */
400400
PRINTF("waiting for ESTAT_CLKRDY\n");
401-
while ((readreg(ESTAT) & ESTAT_CLKRDY) == 0) { };
401+
while ((readreg(ESTAT) & ESTAT_CLKRDY) == 0)
402+
{
403+
};
402404
PRINTF("ESTAT_CLKRDY\n");
403405

404406
setregbank(ERXTX_BANK);

tests/clang-format-core.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ KeepEmptyLinesAtTheStartOfBlocks: false
66
SpaceAfterTemplateKeyword: false
77
SpaceBeforeInheritanceColon: false
88
SpacesBeforeTrailingComments: 2
9-
AlignTrailingComments: true
109
AllowShortBlocksOnASingleLine: Empty
1110
AllowShortFunctionsOnASingleLine: Empty
1211
AllowShortIfStatementsOnASingleLine: false

tests/restyle.sh

+8-13
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ root=$(git rev-parse --show-toplevel)
77
test -d ${root}/cores/esp8266
88
test -d ${root}/libraries
99

10-
# allow `env CLANG_FORMAT=clang-format-13`, or some other version
11-
# default to v13, latest stable version from https://apt.llvm.org
12-
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-13}
13-
14-
# TODO: waiting for llvm-14 to allow --style=file:<path-to-file>
15-
makeClangFormatStyle() {
16-
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
17-
}
10+
# allow `env CLANG_FORMAT=clang-format-N`, or some other version
11+
# default to v15, latest stable version from ubuntu-latest Github Actions image
12+
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15}
1813

1914
#########################################
2015
# 'all' variable should be "cores/esp8266 libraries"
@@ -37,14 +32,14 @@ tests
3732

3833
cd $root
3934

40-
style=$(makeClangFormatStyle ${root}/tests/clang-format-core.yaml)
35+
style=${root}/tests/clang-format-core.yaml
4136
for target in $all; do
4237
if [ -d "$target" ]; then
4338
find $target \
4439
'(' -name "*.cpp" -o -name "*.c" -o -name "*.h" ')' \
45-
-exec $CLANG_FORMAT --verbose --style="$style" -i {} \;
40+
-exec $CLANG_FORMAT --verbose --style="file:$style" -i {} \;
4641
else
47-
$CLANG_FORMAT --verbose --style="$style" -i $target
42+
$CLANG_FORMAT --verbose --style="file:$style" -i $target
4843
fi
4944
done
5045

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

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

6661
#########################################

0 commit comments

Comments
 (0)