From 247647517487b80580cc11123c9ac091bc3811b0 Mon Sep 17 00:00:00 2001 From: Jens L Date: Sat, 4 Sep 2021 14:55:54 +0200 Subject: [PATCH] ci: attempt to cache pipenv (#1347) Signed-off-by: Jens Langhammer --- .github/workflows/ci-main.yml | 63 +++++++++++++++++++++++++++++++++++ scripts/ci_prepare.sh | 6 ++-- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 1e836eb80..7f31e0a8c 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -23,7 +23,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - name: run pylint run: pipenv run pylint authentik tests lifecycle @@ -34,7 +41,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - name: run black run: pipenv run black --check authentik tests lifecycle @@ -45,7 +59,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - name: run isort run: pipenv run isort --check authentik tests lifecycle @@ -56,7 +77,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - name: run bandit run: pipenv run bandit -r authentik tests lifecycle @@ -83,7 +111,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - name: run migrations run: pipenv run python -m lifecycle.migrate @@ -99,7 +134,14 @@ jobs: # Copy current, latest config to local cp authentik/lib/default.yml local.env.yml git checkout $(git describe --abbrev=0 --match 'version/*') + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - name: run migrations to stable run: pipenv run python -m lifecycle.migrate @@ -117,7 +159,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - uses: testspace-com/setup-testspace@v1 with: @@ -139,7 +188,14 @@ jobs: - uses: actions/setup-python@v2 with: python-version: '3.9' + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: scripts/ci_prepare.sh - uses: testspace-com/setup-testspace@v1 with: @@ -172,7 +228,14 @@ jobs: - uses: testspace-com/setup-testspace@v1 with: domain: ${{github.repository_owner}} + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} - name: prepare + env: + INSTALL: ${{ steps.cache-pipenv.outputs.cache-hit }} run: | scripts/ci_prepare.sh docker-compose -f tests/e2e/ci.docker-compose.yml up -d diff --git a/scripts/ci_prepare.sh b/scripts/ci_prepare.sh index 3816ab004..2df5adbd6 100755 --- a/scripts/ci_prepare.sh +++ b/scripts/ci_prepare.sh @@ -1,7 +1,9 @@ -#!/bin/bash +#!/bin/bash -xe docker-compose -f scripts/ci.docker-compose.yml up -d sudo apt update sudo apt install -y libxmlsec1-dev pkg-config sudo pip install -U wheel pipenv -pipenv install --dev +if [[ "$INSTALL" != "true" ]]; then + pipenv install --dev +fi pipenv run python -m scripts.generate_ci_config