ci(backend): standardize environment setup in CI steps

This commit is contained in:
Marc 2023-12-28 00:06:06 -05:00
parent 9110acfdba
commit c08b426dda
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 42 additions and 44 deletions

View file

@ -23,43 +23,18 @@ jobs:
name: Setup
steps:
- uses: actions/checkout@v4
- name: get-python-version
run: |
echo "python_version=$(cat .python-version)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
- uses: ./.github/workflows/setup-backend-environment
with:
python-version: ${{ steps.get-python-version.outputs.python_version }}
- uses: actions/cache@v3
id: cache-restore
with:
path: |
backend/.venv
key: ${{ runner.os }}-${{ hashFiles('**/requirements*.txt') }}-${{ steps.get-python-version.outputs.python_version }}
- name: Install dependencies
if: steps.cache-restore.outputs.cache-hit != 'true'
run: . script/bootstrap
task-version: ${{ inputs.task-version }}
lint:
runs-on: ubuntu-latest
name: Lint
needs: setup
steps:
- uses: actions/checkout@v4
- name: get-python-version
run: |
echo "python_version=$(cat .python-version)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
- uses: ./.github/workflows/setup-backend-environment
with:
python-version: ${{ steps.get-python-version.outputs.python_version }}
- name: Setup Task
uses: arduino/setup-task@v1
with:
version: ${{ inputs.task-version }}
- uses: actions/cache@v3
id: cache-restore
with:
path: |
backend/.venv
key: ${{ runner.os }}-${{ hashFiles('**/requirements*.txt') }}-${{ steps.get-python-version.outputs.python_version }}
task-version: ${{ inputs.task-version }}
- name: Lint
run: |
task be:lint
@ -69,22 +44,9 @@ jobs:
needs: setup
steps:
- uses: actions/checkout@v4
- name: get-python-version
run: |
echo "python_version=$(cat .python-version)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
- uses: ./.github/workflows/setup-backend-environment
with:
python-version: ${{ steps.get-python-version.outputs.python_version }}
- name: Setup Task
uses: arduino/setup-task@v1
with:
version: ${{ inputs.task-version }}
- uses: actions/cache@v3
id: cache-restore
with:
path: |
backend/.venv
key: ${{ runner.os }}-${{ hashFiles('**/requirements*.txt') }}-${{ steps.get-python-version.outputs.python_version }}
task-version: ${{ inputs.task-version }}
- name: Test
run: |
task be:test

View file

@ -0,0 +1,36 @@
#
# Standardized backend CI environment setup.
#
# This is expected to run before any step logic is executed.
#
name: 'Setup Backend Environment'
inputs:
task-version:
required: true
outputs:
python-version:
value: ${{ steps.setup-python.outputs.python-version }}
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- name: Setup Task
uses: arduino/setup-task@v1
with:
version: ${{ inputs.task-version }}
- uses: actions/setup-python@v5
id: setup-python
with:
python-version-file: './backend/pyproject.toml'
- uses: actions/cache@v3
id: cache-restore
with:
path: |
backend/.venv
key: ${{ runner.os }}-${{ hashFiles('**/requirements*.txt') }}-${{ steps.setup-python.outputs.python-version }}
- name: Install dependencies
if: steps.cache-restore.outputs.cache-hit != 'true'
run: . script/bootstrap
working-directory: backend
shell: bash