From a33dda53a31d8e086659bda8018f3b7af986383a Mon Sep 17 00:00:00 2001 From: Gabryel Reyes Date: Mon, 5 Aug 2024 10:40:48 +0200 Subject: [PATCH] Improved Pip caching and setup in the CI --- .github/workflows/main.yml | 99 +++++++----------------------- .github/workflows/requirements.txt | 2 + 2 files changed, 25 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86ef6fa4..7422669c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,29 +37,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Cache PlatformIO - uses: actions/cache@v4 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.9' + cache: 'pip' + cache-dependency-path: .github/workflows/requirements.txt - - name: Install PlatformIO + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install --upgrade platformio + pip install -r .github/workflows/requirements.txt - name: Compile ${{ matrix.environment }} firmware run: platformio run --environment ${{ matrix.environment }} @@ -77,29 +64,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Cache PlatformIO - uses: actions/cache@v4 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.9' + cache: 'pip' + cache-dependency-path: .github/workflows/requirements.txt - - name: Install PlatformIO + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install --upgrade platformio + pip install -r .github/workflows/requirements.txt - name: Perform static checks on ${{ matrix.environment }} run: platformio check --environment ${{ matrix.environment }} --fail-on-defect=medium --fail-on-defect=high @@ -114,29 +88,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Cache PlatformIO - uses: actions/cache@v4 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.9' + cache: 'pip' + cache-dependency-path: .github/workflows/requirements.txt - - name: Install PlatformIO + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install --upgrade platformio + pip install -r .github/workflows/requirements.txt - name: Run tests on native environment run: platformio test --environment TestSim -vvv @@ -154,29 +115,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Cache PlatformIO - uses: actions/cache@v4 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.9' - - - name: Install PlatformIO + cache: 'pip' + cache-dependency-path: .github/workflows/requirements.txt + + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install --upgrade platformio + pip install -r .github/workflows/requirements.txt - name: Set up graphviz uses: ts-graphviz/setup-graphviz@v2 @@ -196,23 +144,22 @@ jobs: # The type of runner that the job will run on. runs-on: ubuntu-latest needs: intro - strategy: - matrix: - python-version: ["3.9", "3.10", "3.11"] # Steps represent a sequence of tasks that will be executed as part of the job. steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - + python-version: '3.9' + cache: 'pip' + cache-dependency-path: .github/workflows/requirements.txt + - name: Install dependencies run: | - pip install pylint + pip install -r .github/workflows/requirements.txt - name: Analysing the code with pylint run: | diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt new file mode 100644 index 00000000..c9299626 --- /dev/null +++ b/.github/workflows/requirements.txt @@ -0,0 +1,2 @@ +platformio==6.1.15 +pylint==3.2.6