|
| 1 | +name: Deploy Production Version to Lambda Feedback |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version-bump: |
| 7 | + description: 'Version bump type' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + default: patch |
| 15 | + branch: |
| 16 | + description: 'Branch to release from' |
| 17 | + required: true |
| 18 | + type: string |
| 19 | + default: 'main' |
| 20 | +jobs: |
| 21 | + test: |
| 22 | + name: Test |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + actions: read |
| 27 | + checks: write |
| 28 | + pull-requests: write |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + python-version: [ "3.12" ] |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: Set up Python ${{ matrix.python-version }} |
| 40 | + id: python-setup |
| 41 | + uses: actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: ${{ matrix.python-version }} |
| 44 | + |
| 45 | + - name: Load cached Poetry installation |
| 46 | + id: poetry-cache |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/.local |
| 50 | + key: poetry-0 |
| 51 | + |
| 52 | + - name: Install and configure Poetry |
| 53 | + if: steps.poetry-cache.outputs.cache-hit != 'true' |
| 54 | + uses: snok/install-poetry@v1 |
| 55 | + with: |
| 56 | + virtualenvs-in-project: true |
| 57 | + |
| 58 | + - name: Load cached venv |
| 59 | + id: dependencies-cache |
| 60 | + uses: actions/cache@v3 |
| 61 | + with: |
| 62 | + path: .venv |
| 63 | + key: venv-${{ runner.os }}-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + if: steps.dependencies-cache.outputs.cache-hit != 'true' |
| 67 | + run: | |
| 68 | + poetry install --no-interaction --no-root |
| 69 | +
|
| 70 | + # TODO: add linting / black / flake8 |
| 71 | + # - name: Lint with flake8 |
| 72 | + # run: | |
| 73 | + # source .venv/bin/activate |
| 74 | + # # stop the build if there are Python syntax errors or undefined names |
| 75 | + # flake8 ./evaluation_function --count --select=E9,F63,F7,F82 --show-source --statistics |
| 76 | + # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 77 | + # flake8 ./evaluation_function --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 78 | + |
| 79 | + - name: Run tests |
| 80 | + if: always() |
| 81 | + run: | |
| 82 | + source .venv/bin/activate |
| 83 | + pytest --junit-xml=./reports/pytest.xml --tb=auto -v |
| 84 | +
|
| 85 | + - name: Upload test results |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + if: always() |
| 88 | + with: |
| 89 | + name: test-results |
| 90 | + path: ./reports/pytest.xml |
| 91 | + if-no-files-found: warn |
| 92 | + deploy: |
| 93 | + uses: lambda-feedback/evaluation-function-workflows/.github/workflows/deploy.yml@deploy-request |
| 94 | + with: |
| 95 | + template-repository-name: "lambda-feedback/evaluation-function-boilerplate-python" |
| 96 | + build-platforms: 'aws' |
| 97 | + environment: "eval-production" |
| 98 | + version-bump: ${{ inputs.version-bump }} |
| 99 | + branch: ${{ inputs.branch }} |
| 100 | + secrets: |
| 101 | + aws-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }} |
| 102 | + aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET}} |
| 103 | + function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY}} |
| 104 | + gcp_credentials: ${{ secrets.GCP_DEPLOY }} |
0 commit comments