From c087c95ac1b305a03cda4026bb6fc359be619413 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Wed, 20 Oct 2021 21:23:31 -0700 Subject: [PATCH] ci: simplify workflow to use actions --- .github/workflows/pull.yml | 37 +++++++++++++++++++++----- .github/workflows/push.yml | 37 +++++++++++++++++++++----- .github/workflows/semantic_release.yml | 8 ------ 3 files changed, 60 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index ae722ae3..977daf4c 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -36,14 +36,37 @@ jobs: steps: - name: Check out code from GitHub uses: "actions/checkout@v2" - - name: Setup Python - uses: "actions/setup-python@v1" + - name: Set up Python 3.9 + uses: actions/setup-python@v2 with: - python-version: "3.8" - - name: Install poetry - run: python3 -m pip install poetry - - name: Install requirements - run: poetry install + python-version: 3.9 + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + #---------------------------------------------- + # install your root project, if required + #---------------------------------------------- + - name: Install library + run: poetry install --no-interaction - name: Run tests run: | poetry run pytest \ diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ccbcf9e3..c8de1800 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -39,14 +39,37 @@ jobs: steps: - name: Check out code from GitHub uses: "actions/checkout@v2" - - name: Setup Python - uses: "actions/setup-python@v1" + - name: Set up Python 3.9 + uses: actions/setup-python@v2 with: - python-version: "3.8" - - name: Install poetry - run: python3 -m pip install poetry - - name: Install requirements - run: poetry install + python-version: 3.9 + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + #---------------------------------------------- + # install your root project, if required + #---------------------------------------------- + - name: Install library + run: poetry install --no-interaction - name: Run tests run: | poetry run pytest \ diff --git a/.github/workflows/semantic_release.yml b/.github/workflows/semantic_release.yml index f26c8d12..4ebfef9d 100644 --- a/.github/workflows/semantic_release.yml +++ b/.github/workflows/semantic_release.yml @@ -33,14 +33,6 @@ jobs: # - name: Move new translations # run: | # cp /tmp/lokalise/locale/* /home/runner/work/alexa_media_player/alexa_media_player/custom_components/alexa_media/translations/ - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install python-semantic-release - name: Setup Git run: | git config --global user.name "semantic-release"