Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(action): Use cache #1891

Merged
merged 2 commits into from
Apr 4, 2023
Merged

feat(action): Use cache #1891

merged 2 commits into from
Apr 4, 2023

Conversation

henrikstranneheim
Copy link
Contributor

@henrikstranneheim henrikstranneheim commented Apr 2, 2023

Description

Added

Changed

  • Use cache in actions

Fixed

How to prepare for test

  • Ssh to relevant server (depending on type of change)
  • Use stage: us
  • Paxa the environment: paxa
  • Install on stage (example for Hasta):
    bash /home/proj/production/servers/resources/hasta.scilifelab.se/update-tool-stage.sh -e S_main -t cg -b [THIS-BRANCH-NAME] -a

How to test

  • Actions run using cached deps

Expected test outcome

  • Take a screenshot and attach or copy/paste the output.

Review

  • "Merge and deploy" approved by @ChrOertlin
    Thanks for filling in who performed the code review and the test!

This version is a

  • MAJOR - when you make incompatible API changes
  • MINOR - when you add functionality in a backwards compatible manner
  • PATCH - when you make backwards compatible bug fixes or documentation/instructions

Implementation Plan

  • Document in ...
  • Deploy this branch on ...
  • Inform to ...

@henrikstranneheim henrikstranneheim requested a review from a team April 2, 2023 14:40
Copy link
Contributor

@ChrOertlin ChrOertlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a pip cache to avoid re-downloading packages when running an action! Looks good!

@seallard
Copy link
Contributor

seallard commented Apr 3, 2023

actions/setup-python#330

I think it is worth considering using this action to actually store the installed dependencies as well

https://github.com/actions/cache

@seallard
Copy link
Contributor

seallard commented Apr 3, 2023

This modified workflow caches the installed dependencies based on the hash of the requirements file.

name: CG Installation tests

on: ["pull_request"]

jobs:
  installations:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.7]

    steps:
      # Check out cg code
      - name: Check out git repository
        uses: actions/checkout@v3

      # Set up python
      - name: Set up Python ${{ matrix.python-version}}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version}}

      # Cache the installed dependencies
      - name: Cache pip packages
        uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-${{ matrix.python-version }}-
            ${{ runner.os }}-pip-

      - name: Install pip
        # Make sure that we have correct python version and pip version
        # For details see .github/workflows/server_info.md
        run: |
          python -m pip install --upgrade pip
          echo $PYTHON_VERSION
          pip --version
        env:
          PYTHON_VERSION: ${{ matrix.python-version}}

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@henrikstranneheim
Copy link
Contributor Author

Screenshot 2023-04-04 at 14 25 53

I think this action saves the dependencies in the requirements file
Screenshot 2023-04-04 at 14 28 40

@henrikstranneheim henrikstranneheim merged commit e95aa41 into master Apr 4, 2023
@henrikstranneheim henrikstranneheim deleted the cache_actions branch April 4, 2023 12:35
@henrikstranneheim
Copy link
Contributor Author

Nothing to deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants