Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Jun 12, 2024
2 parents 5eda2d1 + e382746 commit 94c17e5
Show file tree
Hide file tree
Showing 26 changed files with 308 additions and 98 deletions.
3 changes: 2 additions & 1 deletion .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function run_test() {
fi
fi
done
printf "\n"
printf "Test return code: $error\n"
return $error
}

Expand Down Expand Up @@ -250,6 +250,7 @@ else

exit_code=0
run_test $target $sketch $options $erase || exit_code=$?
echo "Sketch $sketch exit code: $exit_code"
if [ $exit_code -ne 0 ]; then
error=$exit_code
fi
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
description: 'Chip to build tests for'
required: true

concurrency:
group: tests-build-${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}
cancel-in-progress: true

jobs:
build-tests:
name: Build ${{ inputs.type }} tests for ${{ inputs.chip }}
Expand Down Expand Up @@ -47,11 +43,24 @@ jobs:
echo "enabled=$enabled" >> $GITHUB_OUTPUT
- name: Checkout Repository
uses: actions/checkout@v4
- name: Checkout user repository
if: ${{ steps.check-build.outputs.enabled == 'true' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
/*
!.github
# To avoid giving unknown scripts elevated permissions, download them from the master branch
- name: Get CI scripts from master
if: ${{ steps.check-build.outputs.enabled == 'true' }}
run: |
mkdir -p .github
cd .github
curl https://codeload.github.com/${{ github.repository }}/tar.gz/master | tar -xz --strip=2 arduino-esp32-master/.github
- name: Get libs cache
uses: actions/cache@v4
Expand Down
32 changes: 21 additions & 11 deletions .github/workflows/hw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
description: 'Chip to run tests for'
required: true

concurrency:
group: tests-hw-${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}
cancel-in-progress: true

jobs:
hardware-test:
name: Hardware ${{ inputs.chip }} ${{ inputs.type }} tests
Expand Down Expand Up @@ -49,18 +45,32 @@ jobs:
echo "enabled=$enabled" >> $GITHUB_OUTPUT
- name: Checkout repository
- name: Checkout user repository
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
/*
!.github
- uses: actions/setup-python@v5
if: steps.check-tests.outputs.enabled == 'true'
with:
cache-dependency-path: tests/requirements.txt
cache: 'pip'
python-version: '3.10.1'
# To avoid giving unknown scripts elevated permissions, download them from the master branch
- name: Get CI scripts from master
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: |
mkdir -p .github
cd .github
curl https://codeload.github.com/${{ github.repository }}/tar.gz/master | tar -xz --strip=2 arduino-esp32-master/.github
# setup-python currently only works on ubuntu images
# - uses: actions/setup-python@v5
# if: ${{ steps.check-tests.outputs.enabled == 'true' }}
# with:
# cache-dependency-path: tests/requirements.txt
# cache: 'pip'
# python-version: '3.10.1'

- name: Install dependencies
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
- name: Set up Python 3
uses: actions/setup-python@v5
with:
cache-dependency-path: tools/pre-commit/requirements.txt
cache: 'pip'
python-version: "3.x"

- name: Get Python version hash
Expand All @@ -41,11 +43,10 @@ jobs:
with:
path: |
~/.cache/pre-commit
~/.cache/pip
key: pre-commit|${{ env.PY_HASH }}|${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml') }}
key: pre-commit-${{ env.PY_HASH }}-${{ hashFiles('.pre-commit-config.yaml', '.github/workflows/pre-commit.yml', 'tools/pre-commit/requirements.txt') }}

- name: Install python dependencies
run: python -m pip install pre-commit docutils
run: python -m pip install -r tools/pre-commit/requirements.txt

- name: Get changed files
id: changed-files
Expand All @@ -61,7 +62,6 @@ jobs:
with:
path: |
~/.cache/pre-commit
~/.cache/pip
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

- name: Push changes using pre-commit-ci-lite
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
build_all: ${{ steps.set-chunks.outputs.build_all }}
build_libraries: ${{ steps.set-chunks.outputs.build_libraries }}
build_static_sketches: ${{ steps.set-chunks.outputs.build_static_sketches }}
build_idf: ${{ steps.set-chunks.outputs.build_idf }}
build_platformio: ${{ steps.set-chunks.outputs.build_platformio }}
Expand Down Expand Up @@ -103,6 +104,7 @@ jobs:
build_platformio=${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
build_idf=${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
build_libraries=${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
build_static_sketches=${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
core_changed=${{ steps.changed-files.outputs.core_any_changed == 'true' }}
Expand Down Expand Up @@ -136,9 +138,6 @@ jobs:
fi
echo ""
done
else
echo "Unhandled change triggered the build. This should not happen."
exit 1
fi
if [[ -n $sketches ]]; then
Expand All @@ -164,14 +163,15 @@ jobs:
chunks+="]"
echo "build_all=$build_all" >> $GITHUB_OUTPUT
echo "build_libraries=$build_libraries" >> $GITHUB_OUTPUT
echo "build_static_sketches=$build_static_sketches" >> $GITHUB_OUTPUT
echo "build_idf=$build_idf" >> $GITHUB_OUTPUT
echo "build_platformio=$build_platformio" >> $GITHUB_OUTPUT
echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
echo "chunks=$chunks" >> $GITHUB_OUTPUT
- name: Upload sketches found
if: ${{ steps.set-chunks.outputs.build_all == 'false' }}
if: ${{ steps.set-chunks.outputs.build_all == 'false' && steps.set-chunks.outputs.build_libraries == 'true' }}
uses: actions/upload-artifact@v4
with:
name: sketches_found
Expand All @@ -182,6 +182,7 @@ jobs:
# Ubuntu
build-arduino-linux:
name: Arduino ${{ matrix.chunk }} on ubuntu-latest
if: ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_libraries == 'true' }}
needs: gen-chunks
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -213,13 +214,13 @@ jobs:
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ env.MAX_CHUNKS }} 1

- name: Download sketches found
if: ${{ needs.gen-chunks.outputs.build_all == 'false' }}
if: ${{ needs.gen-chunks.outputs.build_all == 'false' && needs.gen-chunks.outputs.build_libraries == 'true' }}
uses: actions/download-artifact@v4
with:
name: sketches_found

- name: Build selected sketches
if: ${{ needs.gen-chunks.outputs.build_all == 'false' }}
if: ${{ needs.gen-chunks.outputs.build_all == 'false' && needs.gen-chunks.outputs.build_libraries == 'true' }}
run: bash ./.github/scripts/on-push.sh ${{ matrix.chunk }} ${{ needs.gen-chunks.outputs.chunk_count }} 1 sketches_found.txt

#Upload cli compile json as artifact
Expand Down Expand Up @@ -274,7 +275,10 @@ jobs:
build-esp-idf-component:
name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
needs: gen-chunks
if: ${{ needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_idf == 'true' }}
if: |
needs.gen-chunks.outputs.build_all == 'true' ||
needs.gen-chunks.outputs.build_libraries == 'true' ||
needs.gen-chunks.outputs.build_idf == 'true'
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand Down
37 changes: 23 additions & 14 deletions .github/workflows/qemu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ on:
required: true
type: string

concurrency:
group: qemu-${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}
cancel-in-progress: true

jobs:
qemu-test:
name: QEMU ${{ inputs.chip }} ${{ inputs.type }} tests
Expand Down Expand Up @@ -45,35 +41,48 @@ jobs:
echo "enabled=$enabled" >> $GITHUB_OUTPUT
- name: Checkout repository
- name: Checkout user repository
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
uses: actions/checkout@v4
if: steps.check-tests.outputs.enabled == 'true'
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
/*
!.github
# To avoid giving unknown scripts elevated permissions, download them from the master branch
- name: Get CI scripts from master
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: |
mkdir -p .github
cd .github
curl https://codeload.github.com/${{ github.repository }}/tar.gz/master | tar -xz --strip=2 arduino-esp32-master/.github
- uses: actions/setup-python@v5
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
with:
cache-dependency-path: tests/requirements.txt
cache: 'pip'
python-version: '3.x'

- name: Install Python dependencies
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: |
pip install -U pip
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
- name: Install APT dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.4.2
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
with:
packages: libpixman-1-0 libnuma1 libglib2.0-0 libslirp0 libsdl2-2.0-0
version: 1.0

- name: Get QEMU version
uses: pozetroninc/github-action-get-latest-release@v0.7.0
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
id: get-qemu-version
with:
token: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -84,14 +93,14 @@ jobs:
- name: Cache QEMU
id: cache-qemu
uses: actions/cache@v4
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
with:
path: |
~/qemu
key: qemu-${{ steps.get-qemu-version.outputs.release }}-${{ hashFiles('.github/workflows/qemu.yml') }}

- name: Download QEMU
if: steps.cache-qemu.outputs.cache-hit != 'true' && steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.cache-qemu.outputs.cache-hit != 'true' && steps.check-tests.outputs.enabled == 'true' }}
run: |
cd ${{ env.QEMU_INSTALL_PATH }}
underscore_release=$(echo ${{ steps.get-qemu-version.outputs.release }} | sed 's/\-/_/g')
Expand All @@ -103,7 +112,7 @@ jobs:
echo "QEMU_PATH=${{ env.QEMU_INSTALL_PATH }}/qemu" >> $GITHUB_ENV
- name: Get binaries
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
id: cache-build-binaries
uses: actions/cache/restore@v4
with:
Expand All @@ -115,7 +124,7 @@ jobs:
~/.arduino/tests/**/build*.tmp/*.json
- name: Run Tests
if: steps.check-tests.outputs.enabled == 'true'
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: QEMU_PATH="${{ env.QEMU_INSTALL_PATH }}" bash .github/scripts/tests_run.sh -c -type ${{inputs.type}} -t ${{inputs.chip}} -i 0 -m 1 -Q

- name: Upload ${{ inputs.chip }} ${{ inputs.type }} QEMU results as cache
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ on:
- '!libraries/**.txt'
- '!libraries/**.properties'
- 'package/**'
- '.github/workflows/tests.yml'
- '.github/workflows/build_tests.yml'
- '.github/workflows/hw.yml'
- '.github/workflows/wokwi.yml'
- '.github/workflows/qemu.yml'
- '.github/scripts/install-*.sh'
- '.github/scripts/tests_*.sh'
- '.github/scripts/sketch_utils.sh'
schedule:
- cron: '0 2 * * *'

Expand Down Expand Up @@ -167,7 +159,7 @@ jobs:
clean:
name: Clean objects
needs: unit-test-results
if: always() && ${{ github.event_name }} == 'pull_request_target' && ${{ github.event.action }} != 'closed'
if: always()
permissions:
actions: write
runs-on: ubuntu-latest
Expand All @@ -179,6 +171,11 @@ jobs:
const ref = '${{ github.event.pull_request.number || github.ref }}';
const key_prefix = 'tests-' + ref + '-';
if ('${{ github.event_name }}' == 'pull_request_target' && '${{ github.event.action }}' != 'closed') {
console.log('Skipping cache cleanup for open PR');
return;
}
await github.paginate(github.rest.actions.getActionsCacheList, {
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
Loading

0 comments on commit 94c17e5

Please sign in to comment.