From ea23c6efff4b8fe4c014f23e9327a10df9bf9ac7 Mon Sep 17 00:00:00 2001 From: Arnault Chazareix Date: Fri, 18 Aug 2023 21:40:33 +0200 Subject: [PATCH 1/2] speed(ci): cache poetry install in ~/.local to speedup poetry install --- .github/workflows/actions/install_dependencies/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/actions/install_dependencies/action.yml b/.github/workflows/actions/install_dependencies/action.yml index 0eda964..1ceefe5 100644 --- a/.github/workflows/actions/install_dependencies/action.yml +++ b/.github/workflows/actions/install_dependencies/action.yml @@ -13,6 +13,11 @@ inputs: runs: using: composite steps: + - name: Load cached .local containing poetry installation + uses: actions/cache@v3 + with: + path: ~/.local + key: dotlocal-${{ runner.os }}-${{ inputs.poetry_version }} - name: Install Poetry uses: snok/install-poetry@v1 with: From 6b726c704f479fc58bbae61ccb17ed1e2c15a5e0 Mon Sep 17 00:00:00 2001 From: Arnault Chazareix Date: Fri, 18 Aug 2023 22:06:43 +0200 Subject: [PATCH 2/2] speed(ci): cache results and share the job to build both sessions matrix --- .github/workflows/tests.yml | 50 ++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 31076ab..bfa56cc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,24 +14,45 @@ concurrency: jobs: - list_nox_test_sessions: + list_nox_sessions_groups: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Cache sessions results + id: sessions-cache + uses: actions/cache@v3 + with: + path: | + format-sessions + test-sessions + key: sessions-${{ hashFiles('noxfile.py') }} - uses: ./.github/workflows/actions/install_dependencies - - name: list all test sessions - id: test_sessions - run: echo "matrix=$(poetry run python commands/list_nox_manifest.py --sessions tests --json)" >> $GITHUB_OUTPUT + if: steps.sessions-cache.outputs.cache-hit != 'true' + + - name: List all format sessions + if: steps.sessions-cache.outputs.cache-hit != 'true' + run: echo "matrix=$(poetry run python commands/list_nox_manifest.py --sessions black isort lint coverage --json)" >> format-sessions + - name: List all test sessions + if: steps.sessions-cache.outputs.cache-hit != 'true' + run: echo "matrix=$(poetry run python commands/list_nox_manifest.py --sessions tests --json)" >> test-sessions + + - name: Export format sessions + id: export-format-sessions + run: cat format-sessions >> $GITHUB_OUTPUT + - name: Export test sessions + id: export-test-sessions + run: cat test-sessions >> $GITHUB_OUTPUT outputs: - test_sessions: ${{ steps.test_sessions.outputs.matrix }} + format_sessions: ${{ steps.export-format-sessions.outputs.matrix }} + test_sessions: ${{ steps.export-test-sessions.outputs.matrix }} run_all_tests: - needs: list_nox_test_sessions + needs: list_nox_sessions_groups strategy: fail-fast: false matrix: include: - ${{ fromJson(needs.list_nox_test_sessions.outputs.test_sessions) }} + ${{ fromJson(needs.list_nox_sessions_groups.outputs.test_sessions) }} name: Run tests session ${{ matrix.session }} runs-on: ubuntu-latest steps: @@ -45,24 +66,13 @@ jobs: with: nox_session: ${{ matrix.session }} - list_nox_format_sessions: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/workflows/actions/install_dependencies - - name: list all format sessions - id: format_sessions - run: echo "matrix=$(poetry run python commands/list_nox_manifest.py --sessions black isort lint coverage --json)" >> $GITHUB_OUTPUT - outputs: - format_sessions: ${{ steps.format_sessions.outputs.matrix }} - format: - needs: list_nox_format_sessions + needs: list_nox_sessions_groups strategy: fail-fast: false matrix: include: - ${{ fromJson(needs.list_nox_format_sessions.outputs.format_sessions) }} + ${{ fromJson(needs.list_nox_sessions_groups.outputs.format_sessions) }} name: Run format session ${{ matrix.session }} runs-on: ubuntu-latest steps: