ci(backend): standardize environment setup in CI steps
This commit is contained in:
parent
9110acfdba
commit
c08b426dda
2 changed files with 42 additions and 44 deletions
50
.github/workflows/backend-pipeline.yml
vendored
50
.github/workflows/backend-pipeline.yml
vendored
|
@ -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
|
||||
|
|
36
.github/workflows/setup-backend-environment/action.yml
vendored
Normal file
36
.github/workflows/setup-backend-environment/action.yml
vendored
Normal 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
|
Reference in a new issue