From 2797f03caec45f2aae8a1f6cb90e9b9a9dcc2a1b Mon Sep 17 00:00:00 2001 From: Joe Stafford <126921281+joe-stafford@users.noreply.github.com> Date: Fri, 26 Jan 2024 10:35:57 -0800 Subject: [PATCH] feat: Feature/secureli 394 gh cache action (#405) secureli-394 This PR enables github caching for various build and testing steps ## Changes * Update .github/workflows/build_and_test.yml with caching options * Update .github/workflows/integration_testing.yml with caching options ## Testing * No new tests ## Clean Code Checklist - [X] Meets acceptance criteria for issue - [ ] New logic is covered with automated tests - [ ] Appropriate exception handling added - [ ] Thoughtful logging included - [ ] Documentation is updated - [ ] Follow-up work is documented in TODOs - [ ] TODOs have a ticket associated with them - [X] No commented-out code included --- .github/workflows/build_and_test.yml | 10 ++++- .github/workflows/integration_testing.yml | 51 +++++++++++++++++++++-- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 65a296d3..8f76fcbe 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -18,15 +18,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Poetry + run: pip install poetry + - name: Set up Python 3.9 id: setup-python uses: actions/setup-python@v4 with: python-version: "3.9" + cache: 'poetry' - name: Set Up Project run: | - pip install poetry poetry install - name: Run Tests @@ -48,15 +51,18 @@ jobs: - name: Validate Branch name run: ./scripts/get-current-branch.sh + - name: Set up Poetry + run: pip install poetry + - name: Set up Python 3.9 id: setup-python uses: actions/setup-python@v4 with: python-version: "3.9" + cache: 'poetry' - name: Set Up Project run: | - pip install poetry poetry install - name: Install BATS for e2e tests diff --git a/.github/workflows/integration_testing.yml b/.github/workflows/integration_testing.yml index b9c2f80e..71afaef6 100644 --- a/.github/workflows/integration_testing.yml +++ b/.github/workflows/integration_testing.yml @@ -18,12 +18,25 @@ jobs: with: python-version: "3.10" + - name: Cache pip repo + id: cache-pip-repo-windows + uses: actions/cache@v4 + with: + path: pip + key: ${{ runner.os }}-repo-pip + + - uses: actions/checkout@v4 + if: steps.cache-pip-repo-windows.outputs.cache-hit != 'true' + with: + repository: pypa/pip + path: pip + fetch-depth: 0 + - name: Install seCureLI # Note that this is a powershell script run: | pip3 --version pip3 install secureli - git clone https://github.com/pypa/pip pip cd pip secureli init --yes @@ -40,6 +53,13 @@ jobs: - name: Test with Homebrew run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + - name: Cache homebrew + id: cache-homebrew-mac + uses: actions/cache@v4 + with: + path: ~/Library/Caches/Homebrew + key: ${{ runner.os }}-homebrew-cache + - name: Preinstall Formula Dependencies env: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -58,11 +78,19 @@ jobs: run: | brew install --display-times --verbose secureli - - name: Checkout test repo - uses: actions/checkout@v4 + - name: Cache pip repo + id: cache-pip-repo-mac + uses: actions/cache@v4 + with: + path: pip + key: ${{ runner.os }}-repo-pip + + - uses: actions/checkout@v4 + if: steps.cache-pip-repo-mac.outputs.cache-hit != 'true' with: repository: pypa/pip path: pip + fetch-depth: 0 - name: Init seCureLI run: | @@ -80,13 +108,28 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.11" + + - name: Cache pip repo + id: cache-pip-repo-mac + uses: actions/cache@v4 + with: + path: pip + key: ${{ runner.os }}-repo-pip + + - uses: actions/checkout@v4 + if: steps.cache-pip-repo-mac.outputs.cache-hit != 'true' + with: + repository: pypa/pip + path: pip + fetch-depth: 0 + - name: Install seCureLI from Pypi run: | pip3 --version # Validate python/pip version pip3 install secureli + - name: Scan repo with Pypi seCureLI package run: | - git clone https://github.com/pypa/pip pip cd pip secureli init --yes # In the future, we should use specific exit codes to differentiate between exit reasons