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
|
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
|
||||||
|
|
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