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 name: Setup
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: get-python-version - uses: ./.github/workflows/setup-backend-environment
run: |
echo "python_version=$(cat .python-version)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
with: with:
python-version: ${{ steps.get-python-version.outputs.python_version }} task-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 }}
- name: Install dependencies
if: steps.cache-restore.outputs.cache-hit != 'true'
run: . script/bootstrap
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Lint name: Lint
needs: setup needs: setup
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: get-python-version - uses: ./.github/workflows/setup-backend-environment
run: |
echo "python_version=$(cat .python-version)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
with: with:
python-version: ${{ steps.get-python-version.outputs.python_version }} task-version: ${{ inputs.task-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 }}
- name: Lint - name: Lint
run: | run: |
task be:lint task be:lint
@ -69,22 +44,9 @@ jobs:
needs: setup needs: setup
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: get-python-version - uses: ./.github/workflows/setup-backend-environment
run: |
echo "python_version=$(cat .python-version)" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
with: with:
python-version: ${{ steps.get-python-version.outputs.python_version }} task-version: ${{ inputs.task-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 }}
- name: Test - name: Test
run: | run: |
task be:test 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