diff --git a/.github/workflows/backend-pipeline.yml b/.github/workflows/backend-pipeline.yml index 5b4c35d..ef020a8 100644 --- a/.github/workflows/backend-pipeline.yml +++ b/.github/workflows/backend-pipeline.yml @@ -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 diff --git a/.github/workflows/setup-backend-environment/action.yml b/.github/workflows/setup-backend-environment/action.yml new file mode 100644 index 0000000..1e1bc2b --- /dev/null +++ b/.github/workflows/setup-backend-environment/action.yml @@ -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