Skip to content

Commit

Permalink
ci: Add option to run tests with esp-flasher-stub
Browse files Browse the repository at this point in the history
  • Loading branch information
dobairoland committed Mar 15, 2024
1 parent dad0edc commit 0dd5c7e
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ cache:
paths:
- "$CI_PROJECT_DIR/.cache/pip"

.use_esp_flasher_stub: &use_esp_flasher_stub |
if [[ "$CI_USE_ESP_FLASHER_STUB" = "1" ]]
then
apt-get update && apt-get install -y jq
wget https://api.github.com/repos/esp-rs/esp-flasher-stub/releases/latest -O /tmp/esp_flasher_stub.json
echo "esp-flasher-stub version:"; cat /tmp/esp_flasher_stub.json | jq -r .tag_name
mkdir /tmp/assets
cat /tmp/esp_flasher_stub.json | jq -r .assets[].browser_download_url | while read -r url; do wget $url -P /tmp/assets; done
for f in /tmp/assets/*.json; do fname=$(basename $f); cp $f esptool/targets/stub_flasher/stub_flasher_${fname#esp}; done
echo "These are the changes in the repository:"
git diff --stat
fi

.test_template: &test_template
stage: test
image: python:3.7-bullseye
Expand All @@ -59,6 +72,8 @@ version_check:
.host_tests_template: &host_tests_template
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
artifacts:
when: always
paths:
Expand Down Expand Up @@ -125,6 +140,8 @@ host_tests_hsm:
run_pre_commit_hooks:
stage: test
image: python:3.7-bullseye
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
tags:
- host_test
script:
Expand All @@ -145,6 +162,8 @@ run_pre_commit_hooks:
# Check all the scripts can run when installed, collect coverage
check_install_coverage:
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
artifacts:
when: always
paths:
Expand All @@ -161,6 +180,8 @@ check_install_coverage:
# Check all the scripts can run when installed
check_install:
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
before_script:
- pip install .
script:
Expand All @@ -169,6 +190,8 @@ check_install:
# Check all the scripts can run when installed in editable mode
check_install_editable:
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
before_script:
- pip install -e .
script:
Expand All @@ -177,6 +200,8 @@ check_install_editable:
# Check all the scripts can run when installed in Python user install directory
check_install_system:
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
before_script:
- pip install --user .
script:
Expand All @@ -190,6 +215,8 @@ check_install_system:
# Check all the scripts can run when installed in virtual environment
check_install_venv:
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
before_script:
- python -m venv test_env
- source test_env/bin/activate
Expand All @@ -201,6 +228,8 @@ check_install_venv:
# as the one embedded in esptool
check_stub_build:
<<: *test_template
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
artifacts:
when: always
paths:
Expand Down Expand Up @@ -234,6 +263,7 @@ check_stub_build:
- pip install -e .[dev] --prefer-binary
# libffi (needed for espsecure) version keeps changing in python docker images. Add a symlink to the installed version on Raspberry Pi
- if [ $(uname -m) = "armv7l" ]; then ln -sfn /usr/lib/arm-linux-gnueabihf/libffi.so.7.1.0 /usr/lib/arm-linux-gnueabihf/libffi.so.6; fi
- *use_esp_flasher_stub
artifacts:
reports:
junit: test/report.xml
Expand Down Expand Up @@ -393,6 +423,8 @@ target_esp32p4:
PYTEST_ADDOPTS: "-sv --junitxml=test/report.xml --color=yes"
PYTHONPATH: "$PYTHONPATH:${CI_PROJECT_DIR}/test"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/test/.covconf"
rules:
- if: $CI_USE_ESP_FLASHER_STUB != "1"
before_script:
- pip install -e .[dev] --prefer-binary
artifacts:
Expand Down Expand Up @@ -458,6 +490,8 @@ build_docs:
tags:
- build_docs
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_USE_ESP_FLASHER_STUB == "1"
when: never
- changes:
- "docs/**/*"
- "CONTRIBUTING.rst"
Expand Down Expand Up @@ -491,7 +525,7 @@ deploy_docs_preview:
extends:
- .deploy_docs_template
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
- if: $CI_COMMIT_REF_NAME == "master" || ($CI_PIPELINE_SOURCE == "schedule" && $CI_USE_ESP_FLASHER_STUB == "1")
when: never
- changes:
- "docs/**/*"
Expand Down

0 comments on commit 0dd5c7e

Please sign in to comment.