From 09b2ff746e0ed207f66abb5874df79348eb4dd49 Mon Sep 17 00:00:00 2001
From: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
Date: Thu, 13 Jan 2022 14:43:21 +0100
Subject: [PATCH 1/6] ci: Cache downloaded tools to avoid downloading them each
 run.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
---
 .github/workflows/push.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index b73b4d34c67..a1ed0e49325 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -22,6 +22,12 @@ jobs:
     - uses: actions/setup-python@v2
       with:
         python-version: '3.x'
+    - name: Cache tools
+      id: cache-linux
+      uses: actions/cache@v2
+      with:
+        path: ./tools/dist
+        key: ${{ runner.os }}-${{ hashFiles('package/package_esp32_index.template.json', 'tools/get.py') }}
     - name: Build Sketches
       run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15
 

From 7eabcd894096037d74ba7268ee0ba84c0ed4685f Mon Sep 17 00:00:00 2001
From: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
Date: Thu, 13 Jan 2022 14:48:57 +0100
Subject: [PATCH 2/6] ci: Cancel duplicated, in progress jobs.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
---
 .github/workflows/push.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index a1ed0e49325..fb0c468f5c8 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -7,6 +7,10 @@ on:
     - release/*
   pull_request:
 
+concurrency:
+  group: build-${{github.event.pull_request.number || github.ref}}
+  cancel-in-progress: true
+
 jobs:
   
   # Ubuntu

From 4045cb4f70097927bbbf1be16aa210a9ec543bf8 Mon Sep 17 00:00:00 2001
From: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
Date: Thu, 13 Jan 2022 15:16:47 +0100
Subject: [PATCH 3/6] ci: Use the current repo when linking the core,
 regardless if it's a fork or not. This allows forks to run workflows with
 their own code.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
---
 .github/scripts/install-arduino-core-esp32.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/scripts/install-arduino-core-esp32.sh b/.github/scripts/install-arduino-core-esp32.sh
index 374d0401547..7b03f2d3262 100755
--- a/.github/scripts/install-arduino-core-esp32.sh
+++ b/.github/scripts/install-arduino-core-esp32.sh
@@ -15,7 +15,7 @@ if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
 		pip install requests > /dev/null
 	fi
 
-	if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ];  then
+	if [ ! -z "$GITHUB_REPOSITORY" ];  then
 		echo "Linking Core..."
 		ln -s $GITHUB_WORKSPACE esp32
 	else

From b1e889c9a5310ef1274f5dee27e7f5e51ed0156c Mon Sep 17 00:00:00 2001
From: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
Date: Thu, 13 Jan 2022 15:29:33 +0100
Subject: [PATCH 4/6] ci: Cache arduino IDE.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
---
 .github/workflows/push.yml | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index fb0c468f5c8..d2d62422d7e 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -30,8 +30,12 @@ jobs:
       id: cache-linux
       uses: actions/cache@v2
       with:
-        path: ./tools/dist
-        key: ${{ runner.os }}-${{ hashFiles('package/package_esp32_index.template.json', 'tools/get.py') }}
+        path: |
+          ./tools/dist
+          ~/arduino_ide
+        key: ${{ runner.os }}-${{ hashFiles('package/package_esp32_index.template.json',
+                                            'tools/get.py',
+                                            '.github/scripts/install-arduino-ide.sh') }}
     - name: Build Sketches
       run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} 15
 

From dcda390f77964dbc429b38ee2e9ea17bf623fbe2 Mon Sep 17 00:00:00 2001
From: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
Date: Mon, 17 Jan 2022 16:43:15 +0100
Subject: [PATCH 5/6] ci: Trigger the build workflow manually.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
---
 .github/workflows/push.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index d2d62422d7e..35a399143ab 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -1,6 +1,7 @@
 name: ESP32 Arduino CI
 
 on:
+  workflow_dispatch:
   push:
     branches:
     - master

From e6cf5aebb15c9667b80bf37fc9340da3515017ef Mon Sep 17 00:00:00 2001
From: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
Date: Mon, 17 Jan 2022 17:12:22 +0100
Subject: [PATCH 6/6] push.yml: Remove trailing spaces.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
---
 .github/workflows/push.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 35a399143ab..b5afd130dbd 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -13,7 +13,7 @@ concurrency:
   cancel-in-progress: true
 
 jobs:
-  
+
   # Ubuntu
   build-arduino-linux:
     name: Arduino ${{ matrix.chunk }} on ubuntu-latest
@@ -21,7 +21,7 @@ jobs:
     strategy:
       matrix:
         chunk: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
-    
+
     steps:
     - uses: actions/checkout@v2
     - uses: actions/setup-python@v2
@@ -47,7 +47,7 @@ jobs:
     strategy:
       matrix:
         os: [windows-latest, macOS-latest]
-    
+
     steps:
     - uses: actions/checkout@v2
     - uses: actions/setup-python@v2
@@ -63,7 +63,7 @@ jobs:
     strategy:
       matrix:
         os: [ubuntu-latest, windows-latest, macOS-latest]
-    
+
     steps:
     - uses: actions/checkout@v2
     - uses: actions/setup-python@v2